
Use stream_input() when text arrives in fragments, such as output from a language model.
Python
stream = client.audio.speech.stream_input(
voice="default",
response_format="mp3",
quality="fast",
)Python
with stream:
stream.send_text("The first fragment ")
stream.send_text("and the final fragment.", flush=True)
stream.finish()
for event in stream:
if event.audio:
player.write(event.audio)
if event.is_final:
breakflush() completes the current utterance. finish() ends input and lets the remaining audio drain. Async sessions use awaited methods and async iteration.
| Option | Accepted values |
|---|---|
response_format | pcm or mp3 |
output_sample_rate | 8000–48000 Hz |
quality | fast or expressive |
seed | Optional integer |
chunk_length_schedule | Optional sequence of chunk targets |
auto_mode | True or False |
Alignment collections are wire-compatible placeholders, not timestamp data.
On this page