Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
Every voice agent, no matter how sophisticated the model behind it, decomposes into the same three stages: speech goes in and becomes text (automatic speech recognition), text goes through a reasoning step and becomes a reply (the LLM), and the reply becomes speech again (text-to-speech). If you can't name which stage is slow, which stage got the wrong answer, or which stage just crashed, you can't fix a voice agent in production — you can only restart it and hope. This module's job is to make that three-stage loop, and its newer single-model alternative you'll meet later in the course, a mental model you reach for automatically, the same way 'request, handler, response' is automatic for a backend builder. Skipping this and jumping straight to 'which SDK do I import' is how teams end up debugging a black box instead of a pipeline they actually understand.
The snippet below times a naive, fully blocking turn through all three stages, so you can see in milliseconds exactly where a real voice call spends its silence before the agent says a word back.
import time
def transcribe(audio_ms: int) -> str:
time.sleep(0.28) # network round trip + streaming ASR settle time
return "what's my order status"
def generate_reply(user_text: str) -> str:
time.sleep(0.65) # time-to-first-token + full generation, no streaming
return "Your order shipped this morning and should arrive Thursday."
def synthesize(reply_text: str) -> bytes:
time.sleep(0.42) # TTS time-to-first-byte + full synthesis
return b"AUDIO_BYTES"
def blocking_turn(audio_ms: int) -> bytes:
t0 = time.perf_counter()
text = transcribe(audio_ms)
t_asr = time.perf_counter()
reply = generate_reply(text)
t_llm = time.perf_counter()
audio = synthesize(reply)
t_tts = time.perf_counter()
print(f"ASR: {t_asr - t0:.2f}s")
print(f"LLM: {t_llm - t_asr:.2f}s")
print(f"TTS: {t_tts - t_llm:.2f}s")
print(f"TOTAL end-of-speech -> first audio byte: {t_tts - t0:.2f}s")
return audio
blocking_turn(1200)python3 main.py