A children's Arabic voice chatbot was taking 15-20 seconds to respond. A child won't wait that long. We got it to 5-7 seconds, and the single biggest win was removing work that shouldn't have been there in the first place.
What we inherited
The client had an existing voice chatbot for kids learning Egyptian Arabic. The previous vendor's architecture looked like this:
- Capture audio in the browser
- Speech-to-Text: Arabic audio to Arabic text
- Translate Arabic to English
- English LLM generates a response
- Translate English back to Arabic
- Text-to-Speech: Arabic text to audio
Six API calls, executed serially. Steps 3 and 5 existed because of the assumption that LLMs cannot handle Arabic in Egyptian dialect. Each translation round-trip added 2-4 seconds. The whole pipeline clocked 15-20 seconds end-to-end.
The fix seems obvious in hindsight: use an LLM that supports Arabic with Egyptian dialect and skip the translation entirely. But the implementation had enough sharp edges to make it interesting.
The 4-step pipeline
We replaced the six-step chain with four steps:
- Capture audio (browser MediaRecorder)
- Google Cloud STT V2 with Chirp 3 for Egyptian Arabic transcription
- Gemini 2.5 Flash for Arabic-native response generation
- Google Cloud TTS with WaveNet for Arabic speech synthesis
No translation. The LLM reads Arabic, thinks in Arabic, responds in Arabic. Here's roughly what the orchestration looks like in backend/src/routes/voice.js:
// Step 1: Speech-to-Text
const sttStart = Date.now();
const transcript = await transcribeAudio(req.file.buffer);
timings.stt = Date.now() - sttStart;
// Step 2: LLM (Gemini)
const llmStart = Date.now();
const responseText = await generateResponse(transcript, sessionId);
timings.llm = Date.now() - llmStart;
// Step 3: Text-to-Speech
const ttsStart = Date.now();
const audioBase64 = await synthesizeSpeech(responseText);
timings.tts = Date.now() - ttsStart;
Every request logs per-step timings in milliseconds, and the response includes a timings object so the frontend can display them during demos. This was how we figured out which step to go after next.
Where the time actually goes
Here's the observed latency budget:
| Step | Time | Notes |
|---|---|---|
| Audio upload | 200-400ms | ~20-40KB for a typical 5-10s recording at 32kbps |
| STT (Chirp 3) | 1500-3000ms | The slowest step by far |
| LLM (Gemini 2.5 Flash) | 500-1500ms | Variable on free tier |
| TTS (WaveNet) | 80-200ms | Surprisingly fast |
| Audio download | 100-300ms | Small MP3 responses |
| Overhead | 500-1500ms | HTTP round-trip, JSON serialization, multer parsing, base64 decode, frontend audio object creation |
| Total | ~2.9-6.9s | Observed 5-7s end-to-end |
Two things stand out. STT dominates. And TTS is nearly free if you pick the right voice.
Choices that mattered
STT: Chirp 3 with the EU endpoint
Google's STT V2 with Chirp 3 handles Egyptian Arabic (ar-EG) natively, not just Modern Standard Arabic. We pointed it at the EU endpoint (eu-speech.googleapis.com) because that's geographically closest to Egypt, shaving roughly 100-200ms of network latency versus the US default.
We used synchronous Recognize rather than streaming. Children's utterances are short (5-15 seconds), so streaming would have added complexity without a meaningful latency improvement for this use case.
LLM: Gemini 2.5 Flash, with an English system prompt
We tried Gemini 3 Flash Preview first. It was roughly 8 seconds per response on the free tier. Gemini 2.5 Flash was significantly faster. For a POC on free-tier infrastructure, model generation speed matters more than marginal quality improvements.
The part we didn't expect: writing the system prompt in English produced better Arabic responses than writing it in Arabic. We tested both. The Arabic system prompt led to noticeably worse response quality. The working prompt is straightforward:
const SYSTEM_PROMPT = `You are a smart and helpful assistant. Always respond in the Egyptian Arabic. Do not translate or switch languages. `;
TTS: Chirp3
We stayed within the Google provider to keep the POC simple and not expensive. ElevenLabs was the first thing we wanted to explore, which offered 200-250ms responses. Though the output speech wasn’t in the Egyptian dialect, this was a quick way for us to prove that the latency issue was solvable.
The translation removal was the biggest win. The raw time saved by cutting two translation API calls is 4-8 seconds. But the indirect benefit matters just as much: fewer serial network round-trips means fewer opportunities for variable latency to compound. A six-step serial pipeline with each step taking 1-3 seconds has a much wider variance band than a four-step pipeline.
What we'd do differently
STT is the bottleneck at 1.5-3 seconds. If we were taking this past POC stage, we'd look at streaming recognition, where the transcription starts before the user finishes speaking. For children's short utterances, the gain is modest, but for any use case with longer inputs, it becomes the obvious next optimization.
We'd also move off Gemini's free tier. The ~10 RPM limit and variable priority result in inconsistent latency. A paid tier with dedicated capacity would make the LLM step more predictable.
The entire POC runs on Google Cloud free tiers, meaning zero infrastructure cost with minimal charge for STT and TTS services. That's appropriate for a demo, but the latency numbers would tighten up with paid APIs and a warm connection pool.
The transferable lesson
The 3x latency improvement didn't come from exotic optimization. It came from questioning an architectural assumption: that Arabic language processing requires a translation layer. Multilingual LLM quality has improved rapidly over the past few years. The previous vendor may have assumed that the model cannot handle Egyptian Arabic dialect well enough for children's speech when they originally built the system, or may not have evaluated that option. Either way, the architecture hadn't been revisited.
If you have a pipeline with serial API calls, look at each step and ask whether it still needs to exist or what can be done differently. The fastest API call is the one you don't make.



