public abstract class SpeechOutput extends TTSComponent implements AutoCloseable, TTSListener
This is the audio output interface for the Spokestack framework. Implementers receive an audio URL provided by a TTS service and must interact with a media player to play that audio, pausing the speech pipeline while the resulting audio plays if desired and then resuming it when playback is over.
SpeechOutput implementers are TTSListeners by definition;
thus, if a TTS subsystem has an output class, additional listeners are not
required. SpeechOutput components do publish their own events using
the same interface, however, so an app may wish to include a listener
component to receive media player events or errors. A separate listener is
also useful for re-opening the microphone (activating the speech pipeline)
when playback is complete.
To be used in a TTS subsystem, an implementing class must provide a
constructor that accepts a SpeechConfig instance.
TTSComponent| Constructor and Description |
|---|
SpeechOutput() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
audioReceived(AudioResponse response)
Notifies the component that audio is available for immediate playback or
caching at the specified location.
|
void |
eventReceived(TTSEvent event)
A notification that a TTS event has occurred.
|
abstract void |
setAndroidContext(android.content.Context androidContext)
Sets the output's Android context.
|
abstract void |
stopPlayback()
Stops playback of any currently playing and queued synthesis results and
clears the play queue.
|
addListener, dispatch, removeListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclosepublic void eventReceived(@NonNull
TTSEvent event)
TTSListenereventReceived in interface TTSListenerevent - The event from the TTS system.public abstract void audioReceived(AudioResponse response)
response - The TTS response containing the URI of the synthesized
audio.public abstract void stopPlayback()
public abstract void setAndroidContext(android.content.Context androidContext)
androidContext - The Android context.Copyright © 2021. All rights reserved.