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 Details

    • AbstractCachedTTSService

      protected AbstractCachedTTSService(TTSCache ttsCache)
  • Method Details

    • synthesize

      public AudioStream synthesize(String text, Voice voice, AudioFormat requestedFormat) throws TTSException
      Description copied from interface: TTSService
      Returns an AudioStream containing the TTS results. Note, one can only request a supported Voice and AudioStream or an exception is thrown.
      Specified by:
      synthesize in interface TTSService
      Parameters:
      text - The text to convert to speech
      voice - The voice to use for speech
      requestedFormat - The audio format to return the results in
      Returns:
      AudioStream containing the TTS results
      Throws:
      TTSException - If voice and/or requestedFormat are not supported or another error occurs while creating an AudioStream
    • getCacheKey

      public String getCacheKey(String text, Voice voice, AudioFormat requestedFormat)
      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 interface org.openhab.core.voice.internal.cache.CachedTTSService
      Parameters:
      text - The text to convert to speech
      voice - The voice to use for speech
      requestedFormat - 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.