Python SDK / Talk streams
Talk streams
A TalkStream feeds an utterance to the avatar
incrementally — ideal when text arrives a bit at a time (tokens
from your own model). The avatar starts speaking before the sentence is complete.
from zeli import TalkStreamA TalkStream is returned by
session.create_talk_stream(),
which requires the server's control gateway.
Sending text
await talk.send(text, *, start_of_speech=None, end_of_speech=False)The next chunk of the utterance to append.
Marks the start of the utterance. The first send is flagged
automatically, so you rarely set this.
Marks the final chunk. Exiting the async with block also ends the
utterance.
Recommended: as a context manager
create_talk_stream() supports async with, which closes the stream on exit:
async with session.create_talk_stream() as talk:
await talk.send("Hello ")
await talk.send("world.", end_of_speech=True)The first chunk is automatically flagged as the start of speech; mark the last one
with end_of_speech=True (or just exit the async with, which closes the
stream).
Members
| Member | Description |
|---|---|
send(text, *, start_of_speech=None, end_of_speech=False) | Append text. First call auto-flags start of speech. |
close() | Signal the end of the utterance if not already ended. |
correlation_id | Id tying this stream's chunks to the resulting transcript message. |
closed | Whether the stream has ended. |
Interleave await asyncio.sleep(...) between chunks to simulate
token-by-token arrival, or feed real tokens from your model as they generate.
Call session.interrupt() to
barge-in and stop playback.