Loading...
const text = await transcribe(audio);
const answer = await complete(text);
const speech = await synthesize(answer);
play(speech);const text = await transcribeStream(micStream);
for await (const sentence of completeStream(text)) {
playQueued(synthesizeStream(sentence));
}Streaming the LLM answer into TTS sentence by sentence lets speech start before the full answer is generated.
Conversation feels natural when the reply starts within about a second after the user stops speaking. Longer gaps feel like the agent did not hear.
Measure from the end of user speech to the first audio byte played back, and log the time of each stage to see which one is slow.
A pipeline gives more control and easier debugging. Speech-to-speech gives lower latency and more natural tone, but less visibility into each step.