Skip to content

MLG-SERBUR/dumcord-voice-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dumcord Voice Translator Bot

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.

Features

  • 🎤 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

Prerequisites

  • Java 17 or higher
  • Maven 3.6 or higher
  • Ollama installed and running locally
  • Discord Bot Token

Setup

1. Install Ollama

Download and install Ollama from https://ollama.ai

2. Install Required Models

# Install Whisper for speech-to-text
ollama pull whisper

# Install a language model for translation (e.g., llama2)
ollama pull llama2

3. Create Discord Bot

  1. Go to Discord Developer Portal
  2. Create a new application
  3. Go to the "Bot" section
  4. Create a bot and copy the token
  5. Enable the following intents:
    • Message Content Intent
    • Server Members Intent
  6. Invite the bot to your server with the following permissions:
    • Send Messages
    • Connect
    • Speak
    • Use Voice Activity

4. Configure the Bot

  1. Copy src/main/resources/application.conf to src/main/resources/application.conf
  2. Replace YOUR_BOT_TOKEN_HERE with your actual bot token
  3. Adjust other settings if needed

5. Build and Run

# Build the project
mvn clean package

# Run the bot
java -jar target/voice-translator-1.0.0.jar

Usage

Commands

  • !join - Bot joins your current voice channel
  • !leave - Bot leaves the current voice channel
  • !status - Shows bot status and configuration

How It Works

  1. Use !join to make the bot join your voice channel
  2. The bot will start listening to audio in the voice channel
  3. 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

Configuration

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
}

Troubleshooting

Common Issues

  1. 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
  2. Transcription fails

    • Check if Ollama is running: ollama list
    • Verify Whisper model is installed: ollama pull whisper
    • Check Ollama URL in configuration
  3. Translation fails

    • Verify the translation model is installed: ollama pull llama2
    • Check Ollama service availability
  4. Audio not being processed

    • Ensure the bot is in a voice channel
    • Check if the voice channel has active speakers
    • Verify audio permissions

Logs

The bot uses SLF4J with Logback. Logs are written to the console and can be configured in src/main/resources/logback.xml.

Development

Project Structure

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

Building from Source

# Clone the repository
git clone <repository-url>
cd dumcord-voice-translator

# Build with Maven
mvn clean compile

# Run tests
mvn test

# Package
mvn package

Limitations

  • 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.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For issues and questions:

  1. Check the troubleshooting section
  2. Create an issue on GitHub
  3. Check Ollama documentation for model-specific issues

About

ai lemayo. Create a discord bot that listens in a voice channel, transcribes what is said, sends the transcription to the voice chat channel, and also translates the transcription to English. Write in java. Use free or AI like ollama for transcribing and translating. (if you use ollama, it will already be setup on the machine).

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages