Introduction
TextToSpeech SDK Overview
The TextToSpeech SDK provides an API for synthesizing and playing text as speech. Third-party apps integrate with the Pleos Connect Speech Service through the TextToSpeech SDK. When a third-party app requests text-to-speech synthesis, the Speech Service processes it and plays the synthesized speech through the vehicle's audio system.
This guide is based on TextToSpeech SDK v3.3.1.
Speech synthesis modes
The TextToSpeech SDK provides the following three speech synthesis modes.
HYBRID: The default mode. It prioritizes server-based streaming TextToSpeech and automatically switches to the On-device engine if the network connection fails. App registration with My Project credentials from Pleos Playground is required.SERVER: Uses server-based streaming TextToSpeech only. It requires a network connection and app registration. If the network connection fails, it does not switch to the On-device engine and instead delivers an error event.ON_DEVICE: Runs streaming TextToSpeech on the vehicle's On-device engine. It does not require a network connection, and app registration is not required when using this mode only.
Entry point
The ai.pleos.playground.tts.TextToSpeech class is the entry point for accessing TextToSpeech SDK features. Create an instance by passing the application Context and an operating Mode to the constructor. If you omit Mode, the SDK uses HYBRID.
A typical usage sequence is as follows.
- Create a
TextToSpeechinstance. - Initialize the SDK with
initialize(). - Register an event listener with
addEventListener(). - If needed, set the synthesis language/region with
setLocale(). - If using server-based synthesis modes (
HYBRID,SERVER), complete app registration. - In modes that require server connection, call
speak()afterOnServerConnectionListener.onConnected(). - When synthesis is done, call
stop(). - After use, remove listeners with
removeEventListener()and release resources withrelease().
Example: Create TextToSpeech instance
- Kotlin
- Java
import ai.pleos.playground.tts.TextToSpeech
import ai.pleos.playground.tts.constant.Mode
val textToSpeech = TextToSpeech(applicationContext, Mode.HYBRID)
import ai.pleos.playground.tts.TextToSpeech;
import ai.pleos.playground.tts.constant.Mode;
TextToSpeech textToSpeech =
new TextToSpeech(getApplicationContext(), Mode.HYBRID);
Emulator setup
To use the TextToSpeech SDK, install the Pleos Connect Emulator in Android Studio and configure an AVD.
- Check software development environment requirements
- Install the Pleos Connect Emulator
- Create and run an AVD
- Set up Pleos Connect Virtual Console
- Configure microphone access
- Configure cold boot