# Non-blocking (default), ready captured lazily during recv
async with client.tts_realtime(
voice_id="YTpq7expH9539ERJ",
output_format="pcm"
) as stream:
# stream.ready is None here, start sending immediately
await stream.send_text("Hello")
await stream.send_eos()
async for msg in stream:
# stream.ready gets populated when the ready message arrives
if msg["type"] == "audio":
process_audio(msg["audio"])
# Blocking, wait for ready before sending
async with client.tts_realtime(
voice_id="YTpq7expH9539ERJ",
output_format="pcm",
wait_for_ready_on_start=True
) as stream:
# stream.ready is populated here
print(f"Server ready: {stream.ready}")
await stream.send_text("Hello")