title: I want to send voice to voice chat using discord.py
body: <h3>Premise · What you want to realize</h3>
  
  <p>I am running python source code on raspberry pi and creating a bot for discord.</p>
  
  <p>I wanted to realize the function like TTSbot.
  bot gets the contents of text chat and outputs sound using AquesTalkPi.</p>
  
  <p>Then, I thought that I wanted raspberry pi's microphone input as bot's microphone input.</p>
  
  <h3>Problems occurring</h3>
  
  <p>At this stage, this program can take a text chat and play it from a raspberry pi speaker.And I confirmed that the USB microphone connected to the raspberry pie is functioning properly.
  However, I did not understand exactly how to make bot connect to voice chat and make raspberry pie microphone input play bot.</p>
  
  <p>I also read some programs that realize the same thing, but I could not understand it because the level was too high.</p>
  
  <h3>Corresponding source code</h3>
  
  <p>db_cog.py</p>
  
  <pre class="lang-py prettyprint-override"><code>import discord
  from discord.ext import commands
  from discord.ext.commands import Bot
  from discord.voice_client import VoiceClient
  import traceback
  import subprocess
  
  INITIAL_COGS = ['cog.cog']
  client=discord.Client()
  
  class Mybot(commands.Bot):
      def __init__(self,command_prefix):
          super().__init__(command_prefix)
          for cog in INITIAL_COGS:
              try:
                  self.load_extension(cog)
              except Exception:
                  traceback.print_exc()
  
      async def on_ready(self):
          print('login')
          print(self.user.name)
          print(self.user.id)
          print('------')
          #channel=client.get_channel("VOICE_CHANNEL_ID")
          voice = await client.join_voice_channel(client.get_channel("VOICE_CHANNEL_ID"))
          #voice=await client.connect(channel)
  
      async def on_message(self,message):
          if message.author.bot:
              return
          await self.process_commands(message)
          txtcmd="./AquesTalkPi '"+str(message.content)+"' | aplay"
          print(txtcmd)
          subprocess.Popen(txtcmd,shell=True,stdout=subprocess.PIPE)
  
  
  if __name__=="__main__":
      bot=Mybot(command_prefix='$')
      bot.run('MYTOKEN')
  
  
  </code></pre>
  
  <h3>Supplemental information (FW / tool version etc.)</h3>
  
  <p>python 3.5.3
  discord.py 1.0.0a
  Raspbian Stretch with desktop November 2018</p>