The TextToSpeech Component
The LightSensor component provides a straightforward interface for converting text to speech.
Playing Text-to-Speech#
To convert text to speech and play it:
Protobject.TextToSpeech.play("en", "Hello, world!");
You can specify the language and the text to be spoken.
Stopping Speech#
To stop the current speech playback:
Protobject.TextToSpeech.stop();
Handling Speech Completion#
To execute code when speech playback ends:
Protobject.TextToSpeech.onTTSEnd(() => {
console.log("Speech playback ended.");
});
Example Usage#
Protobject.TextToSpeech.onTTSEnd(() => {
console.log("Speech playback ended.");
});
Protobject.TextToSpeech.play("en", "Hello, world!");