import discord
from discord.ext import commands
import speech_recognition as sr
description = 'Tutorial Bot'
bot_prefix = '?'
client = commands.Bot(description=description, command_prefix=bot_prefix)
@client.event
async def on_message(message):
if message.content.startswith("Alice"):
msg = await client.send_message(message.channel, 'Hello')
@client.event
async def on_voice_state_update():
with sr.Microphone() as source:
r = sr.Recognizer()
audio = r.listen(source)
command = r.recognize_google(audio)
msg = await client.send_message(message.channel, comman)
async def joinVoiceChannel():
channel = client.get_channel("FILL")
await client.join_voice_channel(channel)
@client.event
async def on_ready():
print("Logged in")
print("Name : {}".format(client.user.name))
print("ID : {}".format(client.user.id))
print(discord.__version__)
await joinVoiceChannel()
client.run("FILL")
我正在尝试制作一个机器人,它可以加入呼叫,在麦克风启动时听到声音,并使用语音识别模块输出 字符串形式的消息。不过,我有困难,机器人加入呼叫,我还没有找到一种方法,采取音频输入从不和谐。在
已登录
名称:BOOS MUSIC
编号:37089338
0.16.8
忽略on_ready中的异常
回溯(最近一次呼叫):
文件“C:\Users\LMEBA21\AppData\Local\Programs\Python35-32\lib\site packages\discord\客户端.py“,第307行,在运行事件中
getattr(self,event)的产量(*args,**kwargs)
文件“C:/Users/LMEBA21/AppData/Local/Programs/Python/Python35-32/α.py“,第28行,在安丘准备好了
等待joinVoiceChannel()
文件“C:/Users/LMEBA21/AppData/Local/Programs/Python/Python35-32/α.py“,第21行,在joinVoiceChannel中
等待client.join_voice_频道(频道)
文件“C:\Users\LMEBA21\AppData\Local\Programs\Python35-32\lib\site packages\discord\客户端.py“,3190行,在join_voice_频道
e升起
文件“C:\Users\LMEBA21\AppData\Local\Programs\Python35-32\lib\site packages\discord\客户端.py“,第3186行,在join_voice_频道
从会话idasyncio.wait(会话\u id_future,超时=10.0,循环=自循环)
文件“C:\Users\LMEBA21\AppData\Local\Programs\Python\Python35-32\lib\asyncio\任务.py“,390号线,等待
提高期货.超时错误()
同期期货._基本时间错误在
我想评论一下,但不能,因为低代表,你犯的两个最大的错误是,你应该保存你的声音对象如下:
由于您无疑需要稍后引用它,而且第二Discord当前不支持录制来自其他用户的音频,为此,您可能需要编写自己的Discord包装器并以某种方式集成录音(这有点令人毛骨悚然)。在
相关问题 更多 >
编程相关推荐