This project is a Twitch and Discord bot that connects to a Twitch channel, listens to messages, converts them to speech using Google Text-to-Speech (gTTS), and plays the generated audio in a Discord voice channel. The bot supports basic commands to join and leave voice channels in Discord.
Before you start, ensure you have the following installed on your machine:
- Python 3.8 or higher
- pip (Python package installer)
-
Clone the repository:
git clone https://github.com/andrxd/TwitchToDiscordVoiceBot.git
-
Navigate to the project directory:
cd TwitchToDiscordVoiceBot
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the project directory:TWITCH_TOKEN=your_twitch_token DISCORD_TOKEN=your_discord_token CHANNEL_NAME=your_twitch_channel_name VOICE_LANGUAGE=pt-br
Replace
your_twitch_token
,your_discord_token
,your_twitch_channel_name
, andpt-br
with your actual Twitch and Discord bot tokens, your desired Twitch channel name, and the language code for the voice language.You can customize the VOICE_LANGUAGE variable with the language code corresponding to the desired language for the Google Text-to-Speech output. For a list of supported language codes, you can refer to the gTTS documentation
-
Run the bot:
python twitch_discord_bot.py
The bot will connect to both Twitch and Discord.
-
In Discord, use the following commands:
!join
: Bot joins the voice channel of the user who issued the command.!leave
: Bot leaves the voice channel.
- Ensure that the bot has the necessary permissions to join and leave voice channels in Discord.
- Make sure that your Discord bot is added to the server where you want it to operate.
- The bot will automatically play the speech audio when a message is sent in the connected Twitch channel.
- discord.py (Discord API wrapper)
- gtts (Google Text-to-Speech API wrapper)
- twitchio (Twitch API wrapper)
- python-dotenv (Reads the key-value pair from a .env file)
This project is licensed under the MIT License - see the LICENSE file for details.