ChromeTtsEngine class
class ChromeTtsEngine extends ChromeApi { static final JsObject _ttsEngine = chrome['ttsEngine']; ChromeTtsEngine._(); bool get available => _ttsEngine != null; /** * Routes a TTS event from a speech engine to a client. * * [event] The update event from the text-to-speech engine indicating the * status of this utterance. */ void sendTtsEvent(int requestId, TtsEvent event) { if (_ttsEngine == null) _throwNotAvailable(); _ttsEngine.callMethod('sendTtsEvent', [requestId, jsify(event)]); } /** * Called when the user makes a call to tts.speak() and one of the voices from * this extension's manifest is the first to match the options object. */ Stream<OnSpeakEvent> get onSpeak => _onSpeak.stream; final ChromeStreamController<OnSpeakEvent> _onSpeak = new ChromeStreamController<OnSpeakEvent>.threeArgs(_ttsEngine, 'onSpeak', _createOnSpeakEvent); /** * Fired when a call is made to tts.stop and this extension may be in the * middle of speaking. If an extension receives a call to onStop and speech is * already stopped, it should do nothing (not raise an error). If speech is in * the paused state, this should cancel the paused state. */ Stream get onStop => _onStop.stream; final ChromeStreamController _onStop = new ChromeStreamController.noArgs(_ttsEngine, 'onStop'); /** * Optional: if an engine supports the pause event, it should pause the * current utterance being spoken, if any, until it receives a resume event or * stop event. Note that a stop event should also clear the paused state. */ Stream get onPause => _onPause.stream; final ChromeStreamController _onPause = new ChromeStreamController.noArgs(_ttsEngine, 'onPause'); /** * Optional: if an engine supports the pause event, it should also support the * resume event, to continue speaking the current utterance, if any. Note that * a stop event should also clear the paused state. */ Stream get onResume => _onResume.stream; final ChromeStreamController _onResume = new ChromeStreamController.noArgs(_ttsEngine, 'onResume'); void _throwNotAvailable() { throw new UnsupportedError("'chrome.ttsEngine' is not available"); } }
Extends
ChromeApi > ChromeTtsEngine
Properties
final bool available #
Returns true if the API is available. The common causes of an API not being avilable are:
- a permission is missing in the application's manifest.json file
- the API is defined on a newer version of Chrome then the current runtime
bool get available => _ttsEngine != null;
final Stream onPause #
Optional: if an engine supports the pause event, it should pause the current utterance being spoken, if any, until it receives a resume event or stop event. Note that a stop event should also clear the paused state.
Stream get onPause => _onPause.stream;
final Stream onResume #
Optional: if an engine supports the pause event, it should also support the resume event, to continue speaking the current utterance, if any. Note that a stop event should also clear the paused state.
Stream get onResume => _onResume.stream;
final Stream<OnSpeakEvent> onSpeak #
Called when the user makes a call to tts.speak() and one of the voices from this extension's manifest is the first to match the options object.
Stream<OnSpeakEvent> get onSpeak => _onSpeak.stream;
final Stream onStop #
Fired when a call is made to tts.stop and this extension may be in the middle of speaking. If an extension receives a call to onStop and speech is already stopped, it should do nothing (not raise an error). If speech is in the paused state, this should cancel the paused state.
Stream get onStop => _onStop.stream;
Methods
void sendTtsEvent(int requestId, TtsEvent event) #
Routes a TTS event from a speech engine to a client.
event The update event from the text-to-speech engine indicating the status of this utterance.
void sendTtsEvent(int requestId, TtsEvent event) { if (_ttsEngine == null) _throwNotAvailable(); _ttsEngine.callMethod('sendTtsEvent', [requestId, jsify(event)]); }