Start and stop synthesis
Send a synthesis request
Pass the text to read to speak() to start speech synthesis. When you can send the full text at once, omit the isFinal field or set it to true. In this case, the SDK treats the provided text as one complete request.
- Kotlin
- Java
textToSpeech.speak("Hello. How can I help you?")
textToSpeech.speak("Hello. How can I help you?", true);
When you send text in multiple parts, set the isFinal field to false for every call except the last, and set it to true on the last call. If you omit isFinal on a non-final call, the default value true is applied and the request ends with only the text sent up to that point.
textToSpeech.speak("Hello. ", isFinal = false)
textToSpeech.speak("This is the TextToSpeech SDK.", isFinal = true)
In modes that require app registration, make requests only after OnServerConnectionListener.onConnected() is called. For request progress and results, see Event listeners.
Stop synthesis and playback
Call stop() to stop speech synthesis and playback in progress.
- Kotlin
- Java
textToSpeech.stop()
textToSpeech.stop();
When the stop operation completes, the registered EventListener receives onStop().