Reference for the StreamingSynthesisConnection class in the Python SDK v1
append_text
as text is produced
and to iterate over the object to read audio. Make sure to call finish()
when you’re done submitting the entire text snippet.
To create an instance of this class, use the synthesize_streaming
method on the Speech
class.
async append_text(text)
Sends additional text to synthesize to the server. The text can be split at any point. For example, the two snippets
below are semantically equivalent:
async __aiter__()
async __anext__()
Iterates over data returned from the server. See the notes below for details on the object format. Here’s a short
snippet that shows how to iterate over the data:
return_extras
was set to true
in when the connection was created.return_extras
was set to true
in when the connection was created, this will include any warnings about the synthesis.
async flush()
Call this when you want to trigger the server to synthesize all the text it
currently has and return the audio data. Audio will be returned via the
async iterator. This is recommended to be used only sparingly, if at all,
as it can result in a less natural sounding speech. This could be useful if
you are sure you have sent text that comes at a natural stop and want all the
audio returned without closing the connection.
async finish()
Call this function when you’ve written all the text you’re expecting to submit. It will flush any remaining data on the server and return the
last chunks of audio via the async iterator. The connection will also be closed.