Package org.openhab.core.voice.tts
Class AbstractCachedTTSService
java.lang.Object
org.openhab.core.voice.tts.AbstractCachedTTSService
- All Implemented Interfaces:
CachedTTSService,TTSService
@NonNullByDefault
public abstract class AbstractCachedTTSService
extends Object
implements 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.tts.CachedTTSService
synthesizeForCacheMethods inherited from interface org.openhab.core.voice.tts.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.Upon requesting an unsupported
VoiceorAudioFormat, aTTSExceptionis 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: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 interfaceCachedTTSService- 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.
-