#On the TTS websocket endpoint, what event do i listen for to tell me that the audio output is finis
1 messages · Page 1 of 1 (latest)
You can listen for the "isFinal" field in the data received from the TTS WebSocket. When this field is present and set to true, it indicates that the final audio chunk has been received, signaling the end of the audio output.
Here’s an example from the provided code snippet:
if data.get("isFinal"):
logger.info("Received final audio chunk.")
break
This event allows you to determine when the audio processing is complete.
The only isFinal I'm getting is as part of the audio data and even that is :
'isFinal': None
Other than that I'm never recieving isFinal as a standalone event
The isFinal attribute is expected to be True only in the final response when the audio generation is complete, and no audio data is included in the response. If you're receiving isFinal: None alongside audio data, this is the expected behavior for intermediate responses.
To ensure you receive the final response with isFinal: True, you need to send an End of Sequence (EOS) message by setting the "text" field to an empty string (""). This signals the server that the text input is complete, and it will return a final response with "isFinal: True" and no audio data.
Steps to Trigger the Final Response:
- Send Your Text: Send your text chunks as usual.
- Terminate the Stream (EOS): Send an empty string as the final message:
This will prompt the server to return the final response with{ "text": "" }"isFinal: True".
If you want to keep the WebSocket connection open for continuous sessions, you will need to manage reconnections or segment the text input appropriately, as the connection is expected to close after the EOS message.
Let me know if you need further clarification!
empty string like "" or " " (with a space)