LiveTranslator is a cutting-edge real-time speech translation system that seamlessly converts spoken language into text, translates it to target languages, and synthesizes it back into speech. Built with modern web technologies, this system provides instant multilingual communication capabilities through an intuitive web interface.
The system is built with a microservices architecture, featuring:
LiveTranslator/
βββ backend/ # FastAPI Backend Application
β βββ api/ # API Routes & WebSocket Handlers
β β βββ rest_routes.py # REST API endpoints
β β βββ ws_routes.py # WebSocket communication
β β βββ feedback_routes.py # User feedback endpoints
β β βββ file_routes.py # File upload/download handlers
β β βββ image_routers.py # Image processing routes
β βββ services/ # Core Business Logic
β β βββ stt_service.py # Speech-to-Text processing
β β βββ translation_service.py # Language translation engine
β β βββ tts_service.py # Text-to-Speech synthesis
β β βββ websocket_service.py # Real-time communication
β β βββ image_translation_service.py # Image text translation
β β βββ file_translate_service.py # Document translation
β β βββ draw_service.py # Drawing/annotation services
β β βββ punctuation.py # Text punctuation enhancement
β βββ models/ # Data Models & Schemas
β β βββ stt_model.py # STT request/response models
β β βββ translation_model.py # Translation data models
β β βββ tts_model.py # TTS configuration models
β β βββ feedback_model.py # User feedback models
β βββ utils/ # Utility Functions
β β βββ audio_utils.py # Audio processing utilities
β β βββ error_handler.py # Error handling middleware
β β βββ logger.py # Logging configuration
β βββ test/ # Test Suite
β β βββ test_stt_service.py # STT service tests
β β βββ test_translation_service.py # Translation tests
β β βββ test_tts_service.py # TTS service tests
β β βββ test_websocket_service.py # WebSocket tests
β βββ main.py # FastAPI application entry point
β βββ database.py # Database configuration
β βββ init_db.py # Database initialization
β βββ requirements.txt # Python dependencies
βββ frontend/ # Web Frontend
β βββ templates/ # HTML Templates
β β βββ index.html # Main application page
β β βββ live_translator.html # Real-time translation interface
β β βββ file_translator.html # File translation interface
β β βββ live_camera.html # Camera-based translation
β β βββ about.html # About page
β β βββ contact.html # Contact page
β βββ static/ # Static Assets
β β βββ css/
β β β βββ style.css # Main stylesheet
β β βββ js/
β β β βββ ws-client.js # WebSocket client
β β βββ img/ # Image assets
β βββ package.json # Frontend dependencies
β βββ README.md # Frontend documentation
βββ docs/ # Documentation
β βββ api.md # API documentation
β βββ setup.md # Setup guide
β βββ deploy.md # Deployment guide
βββ scripts/ # Development Scripts
β βββ setup.sh # Environment setup
β βββ dev.sh # Development server
βββ data/ # Data storage
βββ logs/ # Application logs
βββ Dockerfile # Docker configuration
βββ docker-compose.yml # Docker Compose setup
βββ render.yaml # Render deployment config
βββ README.md # This file
websockets librarylibrosa, soundfilegit clone https://github.com/yourusername/LiveTranslator.git
cd LiveTranslator
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r backend/requirements.txt
# Copy environment template
cp .env.example .env
# Edit .env file with your configuration
# Add API keys for your chosen services
# Start backend server
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000
# Access the application
# Backend API: http://localhost:8000
# Frontend: http://localhost:8000
# API Documentation: http://localhost:8000/docs
# Build and run with Docker Compose
docker-compose up --build
# Access the application
# http://localhost:8000
| Endpoint | Method | Description |
|---|---|---|
/stt | POST | Convert audio to text |
/translate | POST | Translate text between languages |
/tts | POST | Convert text to speech |
/feedback | POST | Submit user feedback |
/upload | POST | Upload files for translation |
| Endpoint | Description |
|---|---|
/ws/audio | Real-time audio streaming |
/ws/translate | Real-time translation streaming |
import requests
# Speech-to-Text
with open('audio.wav', 'rb') as f:
response = requests.post('http://localhost:8000/stt', files={'audio': f})
text = response.json()['text']
# Translation
response = requests.post('http://localhost:8000/translate', json={
'text': 'Hello world',
'source_lang': 'en',
'target_lang': 'vi'
})
translated = response.json()['translated_text']
# API Keys
OPENAI_API_KEY=your_openai_key
GOOGLE_CLOUD_CREDENTIALS=path_to_credentials.json
# Service Configuration
STT_SERVICE=whisper # whisper, google, openai
TRANSLATION_SERVICE=marianmt # marianmt, openai, google
TTS_SERVICE=gtts # gtts, openai
# Database
DATABASE_URL=sqlite:///./translator.db
# Logging
LOG_LEVEL=INFO
# Run all tests
pytest backend/test/
# Run specific test file
pytest backend/test/test_stt_service.py
# Run with coverage
pytest --cov=backend backend/test/
Environment Setup
# Set production environment variables
export ENVIRONMENT=production
export LOG_LEVEL=WARNING
Docker Deployment
docker-compose -f docker-compose.prod.yml up -d
Manual Deployment
# Install production dependencies
pip install -r backend/requirements.txt --no-dev
# Start with production server
gunicorn backend.main:app -w 4 -k uvicorn.workers.UvicornWorker
render.yaml for automatic deploymentWe welcome contributions from the community! Please follow these guidelines:
git checkout -b feature/amazing-feature
git commit -m "feat: add new translation service"
git push origin feature/amazing-feature
This project is licensed under the MIT License - see the LICENSE file for details.
LiveTranslator is a cutting-edge real-time speech translation system that seamlessly converts spoken language into text, translates it to target languages, and synthesizes it back into speech. Built with modern web technologies, this system provides instant multilingual communication capabilities through an intuitive web interface.
The system is built with a microservices architecture, featuring:
LiveTranslator/
βββ backend/ # FastAPI Backend Application
β βββ api/ # API Routes & WebSocket Handlers
β β βββ rest_routes.py # REST API endpoints
β β βββ ws_routes.py # WebSocket communication
β β βββ feedback_routes.py # User feedback endpoints
β β βββ file_routes.py # File upload/download handlers
β β βββ image_routers.py # Image processing routes
β βββ services/ # Core Business Logic
β β βββ stt_service.py # Speech-to-Text processing
β β βββ translation_service.py # Language translation engine
β β βββ tts_service.py # Text-to-Speech synthesis
β β βββ websocket_service.py # Real-time communication
β β βββ image_translation_service.py # Image text translation
β β βββ file_translate_service.py # Document translation
β β βββ draw_service.py # Drawing/annotation services
β β βββ punctuation.py # Text punctuation enhancement
β βββ models/ # Data Models & Schemas
β β βββ stt_model.py # STT request/response models
β β βββ translation_model.py # Translation data models
β β βββ tts_model.py # TTS configuration models
β β βββ feedback_model.py # User feedback models
β βββ utils/ # Utility Functions
β β βββ audio_utils.py # Audio processing utilities
β β βββ error_handler.py # Error handling middleware
β β βββ logger.py # Logging configuration
β βββ test/ # Test Suite
β β βββ test_stt_service.py # STT service tests
β β βββ test_translation_service.py # Translation tests
β β βββ test_tts_service.py # TTS service tests
β β βββ test_websocket_service.py # WebSocket tests
β βββ main.py # FastAPI application entry point
β βββ database.py # Database configuration
β βββ init_db.py # Database initialization
β βββ requirements.txt # Python dependencies
βββ frontend/ # Web Frontend
β βββ templates/ # HTML Templates
β β βββ index.html # Main application page
β β βββ live_translator.html # Real-time translation interface
β β βββ file_translator.html # File translation interface
β β βββ live_camera.html # Camera-based translation
β β βββ about.html # About page
β β βββ contact.html # Contact page
β βββ static/ # Static Assets
β β βββ css/
β β β βββ style.css # Main stylesheet
β β βββ js/
β β β βββ ws-client.js # WebSocket client
β β βββ img/ # Image assets
β βββ package.json # Frontend dependencies
β βββ README.md # Frontend documentation
βββ docs/ # Documentation
β βββ api.md # API documentation
β βββ setup.md # Setup guide
β βββ deploy.md # Deployment guide
βββ scripts/ # Development Scripts
β βββ setup.sh # Environment setup
β βββ dev.sh # Development server
βββ data/ # Data storage
βββ logs/ # Application logs
βββ Dockerfile # Docker configuration
βββ docker-compose.yml # Docker Compose setup
βββ render.yaml # Render deployment config
βββ README.md # This file
websockets librarylibrosa, soundfilegit clone https://github.com/yourusername/LiveTranslator.git
cd LiveTranslator
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r backend/requirements.txt
# Copy environment template
cp .env.example .env
# Edit .env file with your configuration
# Add API keys for your chosen services
# Start backend server
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000
# Access the application
# Backend API: http://localhost:8000
# Frontend: http://localhost:8000
# API Documentation: http://localhost:8000/docs
# Build and run with Docker Compose
docker-compose up --build
# Access the application
# http://localhost:8000
| Endpoint | Method | Description |
|---|---|---|
/stt | POST | Convert audio to text |
/translate | POST | Translate text between languages |
/tts | POST | Convert text to speech |
/feedback | POST | Submit user feedback |
/upload | POST | Upload files for translation |
| Endpoint | Description |
|---|---|
/ws/audio | Real-time audio streaming |
/ws/translate | Real-time translation streaming |
import requests
# Speech-to-Text
with open('audio.wav', 'rb') as f:
response = requests.post('http://localhost:8000/stt', files={'audio': f})
text = response.json()['text']
# Translation
response = requests.post('http://localhost:8000/translate', json={
'text': 'Hello world',
'source_lang': 'en',
'target_lang': 'vi'
})
translated = response.json()['translated_text']
# API Keys
OPENAI_API_KEY=your_openai_key
GOOGLE_CLOUD_CREDENTIALS=path_to_credentials.json
# Service Configuration
STT_SERVICE=whisper # whisper, google, openai
TRANSLATION_SERVICE=marianmt # marianmt, openai, google
TTS_SERVICE=gtts # gtts, openai
# Database
DATABASE_URL=sqlite:///./translator.db
# Logging
LOG_LEVEL=INFO
# Run all tests
pytest backend/test/
# Run specific test file
pytest backend/test/test_stt_service.py
# Run with coverage
pytest --cov=backend backend/test/
Environment Setup
# Set production environment variables
export ENVIRONMENT=production
export LOG_LEVEL=WARNING
Docker Deployment
docker-compose -f docker-compose.prod.yml up -d
Manual Deployment
# Install production dependencies
pip install -r backend/requirements.txt --no-dev
# Start with production server
gunicorn backend.main:app -w 4 -k uvicorn.workers.UvicornWorker
render.yaml for automatic deploymentWe welcome contributions from the community! Please follow these guidelines:
git checkout -b feature/amazing-feature
git commit -m "feat: add new translation service"
git push origin feature/amazing-feature
This project is licensed under the MIT License - see the LICENSE file for details.