This project is a Discord bot that can join voice channels, record audio for a specified duration, process the recorded audio, and send API requests to generate text responses. The bot can also play these text responses as audio back in the voice channel. Additionally, it supports various slash commands for interaction.
- Joins voice channels in a Discord server.
- Records audio and converts it to text.
- Sends API requests based on the transcribed text and retrieves responses.
- Plays the API response as audio in the voice channel.
- Supports slash commands for easy interaction.
-
Clone this repository or download the zip file:
git clone https://github.com/yourusername/discord-ai-bot.git cd discord-ai-bot
-
Install the required Python packages using the
requirements.txt
file:pip install -r requirements.txt
-
Create a
.env
file in the project root directory and add your Discord bot token and application ID:DISCORD_TOKEN=your_discord_bot_token
-
Run the bot:
python bot.py
/join
- Invites the bot to join your current voice channel./leave
- Commands the bot to leave the current voice channel./listen
- Records audio from the voice channel for a specified duration (in seconds) and processes the audio./help
- Displays the help menu with all available commands.
discord-ai-bot/
│
├── bot.py # Main bot file to run the bot
├── commands/
│ ├── __init__.py # Initializes the commands package
│ ├── join.py # /join command
│ ├── leave.py # /leave command
│ ├── listen.py # /listen command
│ └── help.py # /help command
├── utils/
│ ├── __init__.py # Initializes the utils package
│ ├── audio.py # Audio processing utilities
│ ├── api.py # API request utilities
│ └── microphone.py # Microphone-related utilities
├── .env # Environment variables (not included in the repo)
├── requirements.txt # Python package requirements
└── README.md # Project documentation
- Python 3.10+
discord.py
- Discord API wrapper for Pythonrequests
- To handle API requestsgtts
- Google Text-to-Speech for generating audio from textspeechrecognition
- For speech-to-text processingpython-dotenv
- For loading environment variables from a.env
file
This project is licensed under the MIT License. See the LICENSE
file for more details.