Skip to content

About

Improved Google translate the boosts the audio input, capture the audio with Live Transcribe and then to Google Translate.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

322 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GTranslate V4 - Real-time Speech Translation

Real-time speech translation web application using Google Cloud Speech-to-Text and Translation APIs. No timeout limitations, unlimited duration streaming.

Features

  • βœ… Unlimited Duration - No 5-minute timeout restrictions
  • 🎀 Multiple Audio Sources - Microphone or system audio (tab/screen)
  • 🌍 Multi-language Support - 10+ languages for speech recognition and translation
  • ⚑ Two Translation Modes
    • Talks Mode - 8-second translation intervals (4s pause fallback)
    • EarBuds Mode - 8-second intervals (4s pause fallback) optimized for listening with TTS
  • πŸ“Š Real-time Audio Monitoring - Visual level meter and adjustable gain control
  • πŸ“₯ Session Export - Download translations as JSON
  • πŸ”’ Production-Ready Security - CSP headers, CORS protection, rate limiting
  • 🐳 Docker Support - Containerized deployment ready

Quick Start

Prerequisites

  1. Node.js 14+ - Download
  2. Google Cloud Account with Speech-to-Text and Translation APIs enabled
  3. Service Account Credentials - See SETUP.md

Installation

# 1. Install dependencies
npm install

# 2. Place your Google Cloud credentials
# Save as: google-credentials.json

# 3. Start the server
npm start

# 4. Open browser
http://localhost:3003

Project Structure

GtranslateV4/
β”œβ”€β”€ server.js                       # Main server with Socket.IO, Google STT + Translation
β”œβ”€β”€ index.html                      # Web interface (HTML + CSS only, ~805 lines)
β”œβ”€β”€ audio-processor.js              # AudioWorklet processor for mic capture
β”‚
β”œβ”€β”€ Client JavaScript (loaded in order):
β”‚   β”œβ”€β”€ client-utils.js             # Shared utilities: sanitizeText, escapeHtml, SANITIZE_REGEX
β”‚   β”œβ”€β”€ client.js                   # GTranslateV4Client class: constructor, init*, addTranslation, updateStatus
β”‚   β”œβ”€β”€ client-audio.js             # Audio methods: wake lock, startRecording, stopRecording, updateAudioLevel
β”‚   β”œβ”€β”€ client-session.js           # Session methods: latency monitoring, billing, exportSession
β”‚   β”œβ”€β”€ client-tts.js               # TTS methods: speakTranslation, voice cache, processNextInQueue
β”‚   └── client-init.js              # App instantiation: new GTranslateV4Client()
β”‚
β”œβ”€β”€ translation-post-processor.js   # Pure functions: extractByWordLCP, applyTermMappings, verifyReligiousTerms, etc.
β”œβ”€β”€ translation-rules-engine.js     # Translation timing/dedup decision logic
β”œβ”€β”€ billing-db.js                   # Session billing database helpers
β”‚
β”œβ”€β”€ package.json                    # Dependencies
β”œβ”€β”€ docker-compose.yml              # Docker orchestration
β”œβ”€β”€ google-credentials.json         # Google Cloud credentials (you create)
β”‚
β”œβ”€β”€ docker/                         # Docker files
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ .dockerignore
β”‚   β”œβ”€β”€ DOCKER-DEPLOYMENT.md        # Full Docker guide
β”‚   └── README.md
β”‚
β”œβ”€β”€ glossaries/                     # Custom glossary files
β”‚   └── *.csv                       # Term translations
β”œβ”€β”€ build-glossary.js               # Glossary builder script
β”œβ”€β”€ GLOSSARY-GUIDE.md               # Glossary documentation
β”‚
β”œβ”€β”€ documents/                      # PDF source files for glossaries
β”‚   └── *.pdf
β”‚
β”œβ”€β”€ test/                           # Automated tests
β”‚   β”œβ”€β”€ translation-post-processor.test.js  # Unit tests for post-processing functions
β”‚   β”œβ”€β”€ mode-switching.integration.test.js
β”‚   └── translation-interval.test.js
β”‚
β”œβ”€β”€ archive/                        # Old versions (archived)
β”‚   └── old-versions/
β”‚
β”œβ”€β”€ SETUP.md                        # Setup instructions
└── README.md                       # This file

Client Module Architecture

The browser client is split into 6 files loaded sequentially as <script> tags (no bundler required). Each file after client.js uses Object.assign(GTranslateV4Client.prototype, {...}) to mix in methods before the app is instantiated:

File Contents ~Lines
client-utils.js sanitizeText, escapeHtml, SANITIZE_REGEX 20
client.js Class declaration, constructor, init* wiring, addTranslation, updateStatus 606
client-audio.js Wake lock, startRecording, stopRecording, updateAudioLevel 484
client-session.js Latency monitoring, trackBilling, exportSession 162
client-tts.js speakTranslation, voice cache, processNextInQueue 389
client-init.js const app = new GTranslateV4Client() 5

Technology Stack

Backend

  • Node.js - Server runtime
  • Express - Web framework
  • Socket.IO - Real-time WebSocket communication
  • @google-cloud/speech - Speech-to-Text API client
  • @google-cloud/translate - Translation API client
  • Winston - Logging

Frontend

  • Vanilla JavaScript - No framework dependencies
  • Web Audio API - Audio processing
  • AudioWorklet - Modern audio processing (with ScriptProcessor fallback for Safari < 14.1)
  • Socket.IO Client - Real-time communication

DevOps

  • Docker - Containerization
  • Docker Compose - Multi-container orchestration
  • Mocha + Chai - Testing framework

Security Features

  • βœ… Client-side input validation
  • βœ… Server-side path traversal protection
  • βœ… Audio data rate limiting (2MB/sec)
  • βœ… Content Security Policy (CSP) headers
  • βœ… Strengthened CORS with origin whitelist
  • βœ… Maximum connection limits (global & per-IP)
  • βœ… Session inactivity timeout (30 min default)
  • βœ… Maximum auto-restart attempts (10)

Docker Deployment

See docker/DOCKER-DEPLOYMENT.md for complete Docker deployment guide.

Quick Docker Start:

# 1. Ensure google-credentials.json is in project root
# 2. Start container
docker-compose up -d

# 3. View logs
docker-compose logs -f

# 4. Stop
docker-compose down

Configuration

Environment variables (optional):

Variable Default Description
PORT 3003 Server port
NODE_ENV development Environment
GOOGLE_APPLICATION_CREDENTIALS ./google-credentials.json Credentials path
MAX_CONNECTIONS 50 Max concurrent connections
MAX_CONNECTIONS_PER_IP 5 Max connections per IP
INACTIVITY_TIMEOUT 1800000 Session timeout (ms)

Custom Glossaries

Improve translation accuracy with custom glossaries. See GLOSSARY-GUIDE.md.

# Build glossaries from CSV files
node build-glossary.js

Testing

# Run all tests
npm test

# Run specific test suites
npm run test:unit
npm run test:integration

Browser Compatibility

  • βœ… Chrome/Edge - Full support with AudioWorklet
  • βœ… Firefox - Full support with AudioWorklet
  • βœ… Safari 14.1+ - Full support with AudioWorklet
  • βœ… Safari < 14.1 - Automatic fallback to ScriptProcessor
  • βœ… Mobile browsers - Microphone support only (no system audio)

API Usage & Costs

This application uses Google Cloud APIs which incur costs:

  • Speech-to-Text API - ~$0.006 per 15 seconds
  • Translation API - ~$20 per 1M characters

Estimate: ~$0.50-2.00 per hour of continuous use (depending on speech density)

See Google Cloud Pricing for current rates.

Troubleshooting

No audio detected

  1. Check browser microphone permissions
  2. Verify audio source selection (Microphone vs System Audio)
  3. Adjust gain control slider (1x-20x)
  4. Check audio level meter for input

WebSocket connection issues

  1. Check firewall/proxy settings
  2. Verify port 3003 is accessible
  3. Check browser console for errors

Translation errors

  1. Verify Google Cloud credentials are valid
  2. Check APIs are enabled in Google Cloud Console
  3. Review server logs: logs/gtranslate-v4.log

Docker issues

See docker/DOCKER-DEPLOYMENT.md

Development

# Install dependencies
npm install

# Start development server (auto-reload with nodemon)
npm run dev

# Run tests with watch mode
npm run test:watch

Contributing

This is a personal project, but suggestions are welcome:

  1. Check existing issues
  2. Create feature branch
  3. Test thoroughly
  4. Submit pull request

License

MIT License - See LICENSE file for details

Support

For issues and questions:

Acknowledgments

  • Google Cloud Platform for Speech-to-Text and Translation APIs
  • Socket.IO for real-time communication
  • The open-source community

Version: v169 Last Updated: March 2026

About

Improved Google translate the boosts the audio input, capture the audio with Live Transcribe and then to Google Translate.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages