Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
The most common way beginners accidentally build a slow voice agent is by treating it like a batch job: wait for the whole user utterance, wait for the whole LLM response, then generate the whole audio file, then play it. Each 'whole' in that sentence is a place where you're throwing away seconds you didn't have to spend. A properly streaming pipeline starts transcribing before the user finishes talking, starts generating the LLM's next sentence while TTS is already speaking the previous one, and starts playing audio before synthesis of the full reply is done. The difference isn't a nice-to-have optimization — it's the difference between a system that feels instant and one that feels like a walkie-talkie. This task exists to make that difference viscerally obvious in timing numbers before you touch a single real provider SDK.
Below, the same three-sentence reply is delivered two ways: fully batched (wait for everything, then play), and streamed sentence-by-sentence (synthesize and 'play' each sentence as soon as it's ready). Watch the time-to-first-audio gap.
import time
SENTENCES = [
"Your order shipped this morning.",
"It's on a truck headed to your city.",
"Expected delivery is Thursday by 5pm.",
]
def synthesize_sentence(s: str) -> None:
time.sleep(0.35) # per-sentence TTS latency, same cost either way
def batch_playback(sentences: list[str]) -> None:
t0 = time.perf_counter()
for s in sentences:
synthesize_sentence(s) # nothing plays until ALL are synthesized
first_audio = time.perf_counter()
print(f"BATCH: first audio at {first_audio - t0:.2f}s (whole reply synthesized first)")
def streamed_playback(sentences: list[str]) -> None:
t0 = time.perf_counter()
first_audio = None
for s in sentences:
synthesize_sentence(s)
if first_audio is None:
first_audio = time.perf_counter() # user hears this sentence immediately
print(f"STREAMED: first audio at {first_audio - t0:.2f}s (plays as each sentence finishes)")
batch_playback(SENTENCES)
streamed_playback(SENTENCES)python3 main.py