目前,我正在尝试从 jackd 获取音频输出并将其传输到不和谐的语音聊天中。这个解决方案似乎不起作用,但是这据说解决方案有效。我的解决方案不起作用,而另一个解决方案却起作用,这是怎么回事?我可以制作一个与 github 存储库上的解决方案类似的解决方案吗?
import discord
from discord.ext import commands
from discord.utils import get
import os
#import jack
from discord.voice_client import VoiceClient
#start ffmpeg encoding magic.
os.system("ffmpeg -f jack -i stream_input -acodec libmp3lame -y stream.mp3 &> ffmpeg.log&")
# start jackd client stuff
#jack_client = jack.Client('Campfire')
#jack_client.inports.register('stream_input')
#Some variables. PLEASE ADJUST."
Client_Prefix= '>'
token= 'Nah'
client = commands.Bot(command_prefix = Client_Prefix)
#discord bot voice stuff
@client.event
async def on_ready():
print("Logged in as " + client.user.name + ".\n")
print("Prefix is " + Client_Prefix + "\n")
print('Status: armed')
print('-------------------------------------------------------')
@client.command(pass_context=True)
async def join(ctx):
await ctx.send('Joining the campfire.')
global voice
channel = ctx.message.author.voice.channel
voice = get(client.voice_clients, guild=ctx.guild)
if voice and voice.is_connected():
await voice.move_to(channel)
else:
voice = await channel.connect()
print("The bot has connected to a voice channel.")
@client.command(pass_context=True)
async def leave(ctx):
channel = ctx.message.author.voice.channel
voice = get(client.voice_clients, guild=ctx.guild)
if voice and voice.is_connected():
await voice.disconnect()
print("The bot has disconnected from a voice channel")
await ctx.send("Leaving the campfire")
else:
print("Error: I am not currently at a campfire")
await ctx.send("I am not currently at a campfire.")
@client.command(pass_context=True)
async def stoke(ctx):
song_there = os.path.isfile("stream.mp3")
#try:
#if song_there:
#os.remove("stream.mp3")
#print("Removed old campfire ashes.")
#await ctx.send("Removed old campfire ashes.")
#except PermissionError:
#print("Unable to remove old ashes. Bulldozing required.")
#await ctx.send("Unable to remove old ashes. Bulldozing required.")
#return
await ctx.send("Tuning the mystical instrument.")
voice = get(client.voice_clients, guild=ctx.guild)
voice.play(discord.FFmpegPCMAudio("stream.mp3"))
client.run(token)