Interface CachedTTSService

All Superinterfaces:
TTSService
All Known Implementing Classes:
AbstractCachedTTSService

@NonNullByDefault public interface CachedTTSService extends TTSService
TTSService extended with additional methods to support caching TTS results in a TTSCache.
Author:
Gwendal Roulleau - Initial contribution
  • Method Details

    • getCacheKey

      String getCacheKey(String text, Voice voice, AudioFormat requestedFormat)
      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.
      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.
    • synthesizeForCache

      AudioStream synthesizeForCache(String text, Voice voice, AudioFormat requestedFormat) throws TTSException
      Returns an AudioStream containing the TTS results. Note, one can only request a supported Voice and AudioStream or an exception is thrown. The result will be cached if the TTSCacheService is activated.
      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