A real-time speech translation application that converts spoken English to Tamil and vice versa, powered by Ollama's local LLM (Llama 3.2) for translation, with text-to-speech playback functionality.
- Speak in English or Tamil and get instant translation
- Local LLM-powered translation using Ollama (Llama 3.2)
- Automatic bidirectional translation (English β Tamil)
- Listen to the translated speech output
- Save Translations - Store your translations to a local file
- Clean, modern UI using CustomTkinter
- Threaded processing for smooth performance
- Privacy-focused - All translation happens locally
This version replaces cloud-based translation APIs with local LLM translation using Ollama:
- 100% offline translation (after initial model download)
- No API costs or rate limits
- Enhanced privacy - your data never leaves your machine
- Customizable - Easy to switch between different Ollama models
- High-quality translations powered by Llama 3.2
The application provides a user-friendly graphical interface for real-time voice translation:
Before running this application, ensure you have:
- Python 3.7 or higher
- A working microphone
- Audio output device for playback
- Ollama installed and running locally (see installation steps below)
- Internet connection (only for initial Ollama model download and speech recognition)
Ollama is required for local LLM-based translation.
-
Visit ollama.com and download the installer for your OS
-
Install Ollama following the platform-specific instructions:
- Windows: Run the installer
- macOS: Drag to Applications folder
- Linux: Follow the command line installation
-
Verify Ollama installation:
ollama --version- Pull the Llama 3.2 model (used by default):
ollama pull llama3.2:latest- Start the Ollama server (if not already running):
ollama serveNote: The Ollama server should be running at http://localhost:11434 (default). The application will connect to this endpoint.
Option A: Using VS Code Terminal
- Open Visual Studio Code
- Open a new terminal (Terminal β New Terminal or `Ctrl+Shift+``)
- Navigate to your desired directory:
cd path/to/your/desired/folder- Clone the repository:
git clone https://github.com/Sharan-Kumar-R/Talk2Translate.git- Open the project folder:
cd Talk2Translate- Open the project in VS Code:
code .Option B: Using VS Code Git Integration
- Open Visual Studio Code
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) - Type "Git: Clone" and select it
- Paste the repository URL:
https://github.com/Sharan-Kumar-R/Talk2Translate.git - Choose a folder location and click "Select Repository Location"
- Click "Open" when prompted
- In the VS Code terminal, create a virtual environment:
python -m venv venv- Activate the virtual environment:
- Windows:
venv\Scripts\activate- macOS/Linux:
source venv/bin/activateInstall the required packages:
pip install -r requirements.txtIf you don't have a requirements.txt file, install packages individually:
pip install customtkinter SpeechRecognition gTTS pygame ollamaThe SpeechRecognition library requires PortAudio for microphone functionality.
macOS:
brew install portaudioWindows:
- Download the appropriate PyAudio wheel file from Unofficial Windows Binaries
- Install using pip:
pip install PyAudio-0.2.11-cp39-cp39-win_amd64.whlAlternatively, install Microsoft C++ Build Tools if needed.
Linux (Debian/Ubuntu):
sudo apt-get install portaudio19-dev python3-pyaudioollama servepython Bilingual.py- Choose "English β Tamil" to speak in English
- Choose "Tamil β English" to speak in Tamil
- Click the "π§ Start Listening" button
- Speak clearly into your microphone
- Wait for the LLM translation to appear
- Click "πΎ Save Translation" to save the current translation
- Translations are saved to
translations.txtin the application directory
You can customize the Ollama configuration by editing these variables in Bilingual.py:
OLLAMA_HOST = "http://localhost:11434" # Ollama server address
OLLAMA_MODEL = "llama3.2:latest" # Model to use for translationYou can experiment with different models:
# Smaller, faster model
ollama pull llama3.2:1b
# Default model (balanced)
ollama pull llama3.2:latest
# Larger, more capable model
ollama pull llama3.1:8b
# Or other multilingual models
ollama pull mistralUpdate the OLLAMA_MODEL variable in the code to switch models.
- Speech Capture: The application listens to your microphone input
- Speech-to-Text: Converts your speech to text using Google Speech Recognition
- LLM Translation: Translates the text using local Ollama LLM (Llama 3.2)
- Text-to-Speech: Converts the translated text to speech using gTTS
- Playback: Plays the audio translation automatically
Talk2Translate/
β
βββ Bilingual.py # Main application file (uses google translator)
βββ Bilingualllm.py # Main application file (uses local llm)
βββ Talk2Translate.png # Demo image
βββ requirements.txt # Python dependencies
βββ translations.txt # Saved translations (auto-generated)
βββ README.md # This file
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
In case of any queries, please leave a message or contact me via the email provided in my profile.
β Star this repository if you found it helpful!
