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
Constructors -
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 anAudioStreamcontaining the TTS results.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openhab.core.voice.internal.cache.CachedTTSService
synthesizeForCacheMethods 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:TTSServiceReturns anAudioStreamcontaining the TTS results. Note, one can only request a supportedVoiceandAudioStreamor an exception is thrown.- Specified by:
synthesizein 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- Ifvoiceand/orrequestedFormatare not supported or another error occurs while creating anAudioStream
-
getCacheKey
Description copied from interface:org.openhab.core.voice.internal.cache.CachedTTSServiceConstruct 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:
getCacheKeyin 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.
-