Show / Hide Table of Contents

Interface ITextToSpeechCache

A caching mechanism for TTS. TTS generated will be stored as a wav file so that future calls will not have to call the TTS process again. Two files are created. A wav file and a text file. The wav file contains the TTS wav stream and the text contains the text message.

In order to skip TTS generation, the wav file must exist and the text in the text file must match the text message.

If a wav file path is not specified, no caching will happen and TTS will run every time.

Namespace: ivrToolkit.Core.Interfaces
Assembly: ivrToolkit.Core.dll
Syntax
public interface ITextToSpeechCache

Methods

| Edit this page View Source

GenerateCacheAsync(CancellationToken)

If the cache has changed, will run the TTS and cache the new value.

Declaration
Task GenerateCacheAsync(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken

A token to monitor for cancellation requests.

Returns
Type Description
Task
| Edit this page View Source

GetCacheFileName()

Gets the name of the cached wav file or null if one wasn't specified.

Declaration
string? GetCacheFileName()
Returns
Type Description
string
| Edit this page View Source

GetOrGenerateCacheAsync(CancellationToken)

Gets or generates the TTS audio and caches it. This method will use the wav file that is cached if it hasn't changed, or it will generate the TTS audio and cache it.

Declaration
Task<WavStream> GetOrGenerateCacheAsync(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken

A token to monitor for cancellation requests.

Returns
Type Description
Task<WavStream>

The WavStream from the cache.

Extension Methods

ValidationExtensions.ThrowIfNull<T>(T, string)
  • View Source
In this article
Back to top Generated by DocFX