Real-time speech translation web application using Google Cloud Speech-to-Text and Translation APIs. No timeout limitations, unlimited duration streaming.
- β 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
- Node.js 14+ - Download
- Google Cloud Account with Speech-to-Text and Translation APIs enabled
- Service Account Credentials - See SETUP.md
# 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:3003GtranslateV4/
βββ 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
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 |
- 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
- 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
- Docker - Containerization
- Docker Compose - Multi-container orchestration
- Mocha + Chai - Testing framework
- β 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)
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 downEnvironment 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) |
Improve translation accuracy with custom glossaries. See GLOSSARY-GUIDE.md.
# Build glossaries from CSV files
node build-glossary.js# Run all tests
npm test
# Run specific test suites
npm run test:unit
npm run test:integration- β 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)
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.
- Check browser microphone permissions
- Verify audio source selection (Microphone vs System Audio)
- Adjust gain control slider (1x-20x)
- Check audio level meter for input
- Check firewall/proxy settings
- Verify port 3003 is accessible
- Check browser console for errors
- Verify Google Cloud credentials are valid
- Check APIs are enabled in Google Cloud Console
- Review server logs:
logs/gtranslate-v4.log
See docker/DOCKER-DEPLOYMENT.md
# Install dependencies
npm install
# Start development server (auto-reload with nodemon)
npm run dev
# Run tests with watch mode
npm run test:watchThis is a personal project, but suggestions are welcome:
- Check existing issues
- Create feature branch
- Test thoroughly
- Submit pull request
MIT License - See LICENSE file for details
For issues and questions:
- Check SETUP.md for setup instructions
- Check GLOSSARY-GUIDE.md for glossary help
- Check docker/DOCKER-DEPLOYMENT.md for Docker issues
- Review logs in
logs/gtranslate-v4.log
- 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