Sharan-Kumar-R/Talk2Translate
The application uses SpeechRecognition, GoogleTranslator, and gTTS to convert spoken English or Tamil into the opposite language, display the translated text, and play the audio output.
๐ English โ Tamil Speech Translator (Ollama LLM)
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.
Features
- 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
What's New - Ollama Integration
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
๐ธ Demo / Output
The application provides a user-friendly graphical interface for real-time voice translation:
Prerequisites
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)
Installation
Step 1: Install Ollama
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.
Step 2: Clone the Repository
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
Step 3: Create a Virtual Environment (Recommended)
- 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/activateStep 4: Install Python Dependencies
Install 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 ollamaStep 5: Install PortAudio (Required for Microphone Input)
The 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-pyaudioUsage
1. Start Ollama Server (if not already running)
ollama serve2. Run the Application
python Bilingual.py3. Select Translation Mode
- Choose "English โ Tamil" to speak in English
- Choose "Tamil โ English" to speak in Tamil
4. Start Listening
- Click the "๐ง Start Listening" button
- Speak clearly into your microphone
- Wait for the LLM translation to appear
5. Save Translations
- Click "๐พ Save Translation" to save the current translation
- Translations are saved to
translations.txtin the application directory
Configuration
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 translationAvailable Ollama Models for Translation
You 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.
How It Works
- 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
Project Structure
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
Contributing
- 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!
