Package org.openhab.core.voice
Class AbstractCachedTTSService
java.lang.Object
org.openhab.core.voice.AbstractCachedTTSService
- All Implemented Interfaces:
org.openhab.core.voice.internal.cache.CachedTTSService
,TTSService
@NonNullByDefault
public abstract class AbstractCachedTTSService
extends Object
implements org.openhab.core.voice.internal.cache.CachedTTSService
Implements cache functionality for the TTS service extending this class.
- Author:
- Gwendal Roulleau - Initial contribution
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetCacheKey
(String text, Voice voice, AudioFormat requestedFormat) Construct a uniquely identifying string for the request.synthesize
(String text, Voice voice, AudioFormat requestedFormat) Returns anAudioStream
containing the TTS results.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.openhab.core.voice.internal.cache.CachedTTSService
synthesizeForCache
Methods inherited from interface org.openhab.core.voice.TTSService
getAvailableVoices, getId, getLabel, getSupportedFormats
-
Constructor Details
-
AbstractCachedTTSService
-
-
Method Details
-
synthesize
public AudioStream synthesize(String text, Voice voice, AudioFormat requestedFormat) throws TTSException Description copied from interface:TTSService
Returns anAudioStream
containing the TTS results. Note, one can only request a supportedVoice
andAudioStream
or an exception is thrown.- Specified by:
synthesize
in interfaceTTSService
- Parameters:
text
- The text to convert to speechvoice
- The voice to use for speechrequestedFormat
- The audio format to return the results in- Returns:
- AudioStream containing the TTS results
- Throws:
TTSException
- Ifvoice
and/orrequestedFormat
are not supported or another error occurs while creating anAudioStream
-
getCacheKey
Description copied from interface:org.openhab.core.voice.internal.cache.CachedTTSService
Construct a uniquely identifying string for the request. Could be overridden by the TTS service if it uses some unique external parameter and wants to identify variability in the cache.- Specified by:
getCacheKey
in interfaceorg.openhab.core.voice.internal.cache.CachedTTSService
- Parameters:
text
- The text to convert to speechvoice
- The voice to use for speechrequestedFormat
- The audio format to return the results in- Returns:
- A likely unique key identifying the combination of parameters and/or internal state, as a string suitable to be part of a filename. This will be used in the cache system to store the result.
-