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")
I'm trying to make a bot that can join the call, hear audio when a microphone is activated and use the speech recognition module to output the message in string form. However I am having difficulties in the bot joining the call, and I haven't found a way to take an audio input from discord.
Logged in
Name : BOOS MUSIC
ID : 284760930837987338
0.16.8
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\LMEBA21\AppData\Local\Programs\Python\Python35-32\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:/Users/LMEBA21/AppData/Local/Programs/Python/Python35-32/ALPHA.py", line 28, in on_ready
await joinVoiceChannel()
File "C:/Users/LMEBA21/AppData/Local/Programs/Python/Python35-32/ALPHA.py", line 21, in joinVoiceChannel
await client.join_voice_channel(channel)
File "C:\Users\LMEBA21\AppData\Local\Programs\Python\Python35-32\lib\site-packages\discord\client.py", line 3190, in join_voice_channel
raise e
File "C:\Users\LMEBA21\AppData\Local\Programs\Python\Python35-32\lib\site-packages\discord\client.py", line 3186, in join_voice_channel
session_id_data = yield from asyncio.wait_for(session_id_future, timeout=10.0, loop=self.loop)
File "C:\Users\LMEBA21\AppData\Local\Programs\Python\Python35-32\lib\asyncio\tasks.py", line 390, in wait_for
raise futures.TimeoutError()
concurrent.futures._base.TimeoutError