#how to get isFinal=True?
1 messages · Page 1 of 1 (latest)
To get the isFinal attribute set to true in the Web API, you need to send an End Of Sequence (EOS) message correctly. Here's how you can achieve this:
-
Send Text Chunks: Send your text chunks as usual for synthesis.
-
Terminate the Stream (EOS): To signal the end of the current text input, send a message with the
"text"field set to an empty string (""). This is the correct way to trigger the final response. For example:{ "text": "" }Avoid sending a flush message with a space (
" "), as this does not properly signal the end of the stream. -
Expected Behavior: When the server receives the EOS message (
{"text": ""}), it will return a final response where:"isFinal": true- The
audiofield is null, indicating that audio generation is complete.
Additional Notes:
- If you want the WebSocket connection to remain open during a session, ensure you manage inactivity by setting the
inactivity_timeoutparameter to a higher value (up to 180 seconds). - For continuous sessions, you may need to re-establish a new connection for each text segment or implement a heuristic to manage alignment data without relying on
isFinal.
Let me know if you need further clarification!
as a side note, if we put flush=True in the same message, this does not work!!!
To get isFinal=True in ElevenLabs' API responses, you need to ensure that the text-to-speech generation process has completed. The isFinal flag is typically included in the response to indicate that the audio generation is finalized and no further updates will be sent for that request.
Regarding your side note, if flush=True is included in the same message, it may not work as expected because flush=True is used to force the immediate generation of audio for the current input, bypassing any buffering or streaming optimizations. This can sometimes conflict with the finalization process, depending on how the API handles the request.
To troubleshoot this:
-
Check API Documentation: Review the API References to ensure you're using the correct parameters and sequence for your request.
-
Separate Requests: If
flush=Trueis causing issues, try removing it or testing without it to see ifisFinal=Trueis returned properly. -
Streaming Mode: If you're using streaming mode, ensure that your implementation correctly handles the final chunk of data, which should include
isFinal=True.
If you're still encountering issues, please provide more details about your setup or reach out to our support team for further assistance.
when i received isFinal=True, webscoket will be closed, right?