Follow this guide to build your own voice translator agent!
May 05, 2025
.png)
This article walks through building a real-time voice translator using open-source AI tools like Whisper, LLaMA-3, and Coqui XTTS powered by GMI Cloud’s scalable infrastructure. It explains how to combine speech recognition, translation, and text-to-speech models into a fully functional browser-based app.
What you’ll learn:
| Step | Tool Used | Function | Why It Matters |
|---|---|---|---|
| Speech-to-Text | Whisper | Converts speech into text | Accurate multilingual ASR |
| Translation | LLaMA-3 | Translates text into target lang | Flexible, open-source LLM |
| Text-to-Speech | XTTS | Generates natural voice output | Fast, expressive TTS |
| Deployment | GMI Cloud | Runs models on GPU instances | Scalable, low-latency environment |
Based on an ODSC webinar by Grace Deng, Software Engineer at GMI Cloud
You can watch the original webinar recording here!
Imagine saying “hello” in English and hearing it spoken back in Mandarin—instantly, naturally, and with personality. That’s what real-time voice translation can do, and now, with open-source tooling and scalable infrastructure, anyone can build it.
In a recent ODSC webinar, Grace Deng, Software Engineer at GMI Cloud, walked through building a voice-to-voice translator in under an hour. This guide distills the key steps and open-source tooling used, so you can follow along and deploy your own in minutes.
A real-time voice translator listens to speech, converts it to text, translates that text into another language, and then speaks the translation out loud—usually in under a few seconds. In this guide, the pipeline is Whisper for speech-to-text, LLaMA-3 for translation, and XTTS for text-to-speech.
Because open-source AI now makes it possible to create near-instant translation experiences without relying on proprietary APIs or expensive services.
For businesses, this means breaking language barriers in real time whether during global meetings, customer support interactions, or live product demos. A self-built, open-source solution offers full control over data privacy, integration flexibility with existing systems, and lower operating costs compared to commercial APIs. It helps enterprises deliver inclusive, multilingual communication without sacrificing security or scalability.
You’ll create a real-time voice translator that has:
Use cases:
When should you build for the cloud, and when should you keep everything on-device?
While both deployment options have their strengths, your choice depends on use case and scale:
In short, cloud setups win on scale and capability, while on-device wins on independence and privacy developers can even combine both for hybrid reliability.
A complete voice-to-voice translator needs three core components: speech-to-text (Whisper), translation (LLaMA-3), and text-to-speech (XTTS). You then connect the pipeline with a lightweight UI layer like Gradio and deploy it on a GPU environment for low-latency inference.
Each model plays a distinct role: Whisper listens, LLaMA 3 understands, XTTS speaks, and Gradio connects it all. Together, they form a modular, customizable translation stack.
By breaking it into clear stages from setup to deployment you can replicate, modify, or scale the same workflow for your own applications.
Create your Python environment (Conda or venv), add the dependencies in your requirements.txt file, and install:
Here's a list of imported dependencies and why we want them.
This section prepares the hardware setup for running our Voice-to-Voice Translator by allocating GPU devices for two major tasks:
We aim to run each task on a separate GPU (if available) for optimal performance.
✅ Tip: When working with deep learning models like Whisper and TTS, spreading the workload across multiple GPUs can significantly improve runtime performance and reduce latency. Feel free to spread out the workload in a way that makes sense for your device. In this case, we use the last two GPU's.
In this section, we prepare the automatic speech recognition (ASR) component using OpenAI's Whisper Large V3 model, powered by Hugging Face Transformers.
OpenAI’s Whisper Large V3 sets the benchmark for real-time speech recognition in open-source AI. It’s not just accurate it’s robust, multilingual, and production-ready, making it ideal for enterprise-grade voice translation pipelines.
Noise-resilient and domain-flexible: Whether used in customer support, live meetings, or accessibility tools, Whisper maintains high Word Error Rate (WER) performance even with background noise or variable recording quality.
A voice translator feels real-time when transcription, translation, and speech synthesis overlap instead of running sequentially. Using audio chunking, voice activity detection, partial results, and parallel GPU execution keeps total round-trip latency under two seconds and conversations feeling natural.
How can you make your speech recognition feel truly real-time?
To achieve smooth live transcription, it’s important to handle streaming intelligently:
Implementing these techniques keeps your translator responsive and natural, especially for live conversation or accessibility use cases.
In this step, we bridge the gap between transcription and speech synthesis by introducing text translation.
To translate English transcripts into Chinese, we use a hosted LLaMA-3 model via a REST API (https://api.gmi-serving.com/v1/chat/completions). This function wraps the call to the API in Python and uses a POST request with the appropriate headers and payload.
The response is parsed as JSON. If the response is valid and successful (status_code == 200), the function extracts the translated message and returns it. Otherwise, it handles errors gracefully and logs useful debugging information.
✅ At this point, you can transcribe English audio, translate it to Chinese, and are now ready to generate Chinese audio output.
LLaMA-3 is ideal for powering production-grade translation pipelines because it combines linguistic precision with scalability and enterprise control:
Cost efficiency and flexibility: As an open-source LLM, LLaMA-3 avoids vendor lock-in and offers transparent control over deployment costs, performance, and compliance (hybrid / multi-cloud AI infrastructure).
In this section, we complete the voice-to-voice translation pipeline by generating audio from the translated text and connecting all components into a single function.
The multilingual TTS model xtts_v2 from Coqui TTS is loaded and moved to the designated TTS device (device_tts), ensuring fast inference using GPU if available.
We define a function text_to_speech that takes in translated text and generates a spoken audio file from it.
How do you make your translated voice sound natural and fast?
To improve perceived “real-time” flow:
Small adjustments here have a huge impact the smoother the TTS handoff, the more your app feels like a live human translator.
🔄 End-to-End Voice Translation Pipeline
The voice_to_voice() function integrates all stages:
Finally, it returns the path to the generated audio file.
✅ You now have a fully functioning voice-to-voice translator: English audio in → Chinese audio out!
In this final step, we wrap our voice-to-voice translation pipeline into a user-friendly interface using Gradio.
We create a gr.Interface instance to handle:
It gives you a plug-and-play web interface for testing your translator instantly, without writing extra front-end code.
Finally, we call .launch() with share=True to:
| Scenario | Stack Choice | Key Advantage | Note |
|---|---|---|---|
| Lightweight / Edge devices | Distilled models + VITS | Low compute cost | Sacrifices accuracy |
| Multilingual research use | Whisper + LLaMA-3 + XTTS | Flexibility, open-source | Runs well on 1 GPU |
| Enterprise real-time scale | Whisper + LLaMA-3 + XTTS (multi-GPU) | High concurrency | Supports thousands of users |
| High-accuracy translation | Whisper Large-v3 + M2M100 | Better translation BLEU | Requires more GPU resources |
How do you know if your translator is performing well?
Once your system runs end-to-end, it’s time to measure both accuracy and responsiveness:
Evaluating both quality and speed turns your translator from a prototype into a production-ready AI system and helps you answer the question “What’s the best AI voice translator?” with data.
Why these pro tips matter for you:
Each tip maps to a concrete benefit you’ll feel when you ship:
These practices help you stay within the latency targets already outlined above (ASR ~<700 ms, MT ~<500 ms, TTS ~<800 ms), improve output quality you don’t have to fix later, and trim avoidable GPU minutes better UX at lower cost whether you deploy on-device or via GMI Cloud endpoints.
GMI Cloud is here to help you get your AI project off the ground—fast. With GPU-ready APIs and hosted endpoints, you don’t need to wrangle infrastructure just to experiment.
Join the GMI Discord community to connect with other builders and share your creations.
The project combines several open-source components: Whisper for English speech recognition (ASR), LLaMA-3 for translating text into Chinese, and Coqui XTTS v2 for generating Chinese speech. It’s deployed using Gradio for an interactive web interface and accelerated with CUDA for multi-GPU performance. GMI Cloud’s API provides scalable endpoints for model inference.
The process begins when a user speaks into a microphone. The audio is captured and processed by Whisper, which transcribes it into English text. Then, LLaMA-3 translates the English text into Chinese. Finally, Coqui XTTS v2 converts the translated text into spoken audio, saving the result as audio.wav. The user can instantly listen to the output in the browser through Gradio’s interface.
Using multiple GPUs drastically reduces latency by distributing workloads. In the example, one GPU is dedicated to Whisper (speech-to-text) and another to XTTS (text-to-speech). Running these components simultaneously speeds up the translation process and ensures smoother real-time performance essential for live conversations or accessibility tools.
The script integrates GMI Cloud’s LLaMA-3 API, which receives English text and returns a Chinese translation. It uses the meta-llama/Llama-3.3-70B-Instruct model with a temperature of 0 to ensure consistent and accurate results. The API request includes a system instruction that specifies: “Translate the following English text into Chinese and return only the translation.” The output text is then sent to the TTS component for speech synthesis.
Grace Deng’s tutorial emphasizes using clean 16kHz audio input to improve Whisper’s accuracy. Setting temperature to 0 produces stable translations without random variations. For speech output, using the language code “zh-cn” in XTTS ensures natural pronunciation, and choosing a clear voice like “Ana Florence” helps create high-quality, human-like audio.
The project setup is simple: a few files (translator.py, requirements.txt, and audio.wav) and dependencies installed with pip install -r requirements.txt. The Gradio interface manages input and output audio in real time. Running demo.launch(share=True) starts the app locally and generates a public link for testing, making it easy to demonstrate or share your real-time voice translator online.
GMI Cloud helps you architect, deploy, optimize, and scale your AI strategies
