A Discord bot that listens to voice channels, transcribes speech using Ollama's Whisper model, and translates the transcription to English using Ollama's language models.
- 🎤 Voice Channel Listening: Joins voice channels and listens to audio
- 📝 Speech-to-Text: Transcribes audio using Ollama's Whisper model
- 🌍 Translation: Translates transcribed text to English using Ollama's language models
- 🔍 Language Detection: Automatically detects the source language
- 💬 Text Channel Integration: Sends transcriptions and translations to text channels
- Java 17 or higher
- Maven 3.6 or higher
- Ollama installed and running locally
- Discord Bot Token
Download and install Ollama from https://ollama.ai
# Install Whisper for speech-to-text
ollama pull whisper
# Install a language model for translation (e.g., llama2)
ollama pull llama2- Go to Discord Developer Portal
- Create a new application
- Go to the "Bot" section
- Create a bot and copy the token
- Enable the following intents:
- Message Content Intent
- Server Members Intent
- Invite the bot to your server with the following permissions:
- Send Messages
- Connect
- Speak
- Use Voice Activity
- Copy
src/main/resources/application.conftosrc/main/resources/application.conf - Replace
YOUR_BOT_TOKEN_HEREwith your actual bot token - Adjust other settings if needed
# Build the project
mvn clean package
# Run the bot
java -jar target/voice-translator-1.0.0.jar!join- Bot joins your current voice channel!leave- Bot leaves the current voice channel!status- Shows bot status and configuration
- Use
!jointo make the bot join your voice channel - The bot will start listening to audio in the voice channel
- Every 5 seconds, it processes the audio and:
- Transcribes it using Whisper
- Detects the language
- Translates it to English
- Sends both transcription and translation to the text channel
Edit src/main/resources/application.conf:
bot {
token = "YOUR_BOT_TOKEN_HERE"
}
ollama {
url = "http://localhost:11434"
transcription_model = "whisper"
translation_model = "llama2"
}
audio {
chunk_size = 4096
sample_rate = 48000
max_duration_seconds = 30
}-
Bot doesn't respond to commands
- Check if the bot token is correct
- Ensure the bot has the necessary permissions
- Verify the bot is online
-
Transcription fails
- Check if Ollama is running:
ollama list - Verify Whisper model is installed:
ollama pull whisper - Check Ollama URL in configuration
- Check if Ollama is running:
-
Translation fails
- Verify the translation model is installed:
ollama pull llama2 - Check Ollama service availability
- Verify the translation model is installed:
-
Audio not being processed
- Ensure the bot is in a voice channel
- Check if the voice channel has active speakers
- Verify audio permissions
The bot uses SLF4J with Logback. Logs are written to the console and can be configured in src/main/resources/logback.xml.
src/main/java/com/dumcord/
├── VoiceTranslatorBot.java # Main bot class
├── config/
│ └── BotConfig.java # Configuration management
└── services/
├── OllamaService.java # Ollama API integration
└── VoiceService.java # Voice channel handling
# Clone the repository
git clone <repository-url>
cd dumcord-voice-translator
# Build with Maven
mvn clean compile
# Run tests
mvn test
# Package
mvn package- Audio Capture: The current implementation uses a placeholder for audio capture. In a production environment, you would need to implement proper Discord audio capture.
- Model Performance: Transcription and translation quality depends on the Ollama models used.
- Rate Limiting: The bot processes audio every 5 seconds to avoid overwhelming the Ollama service.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check the troubleshooting section
- Create an issue on GitHub
- Check Ollama documentation for model-specific issues