GitHubContribute in GitHub: Edit online

copyright: years: 2017, 2018 lastupdated: "2018-04-04"


Reducing response time to the Text to Speech service

To reduce the response time from the Watson Text to Speech service, you can configure the Media Relay to cache responses from the Text to Speech service, which results in quicker responses to the caller. Typically, you might use this capability to cache welcome messages, general questions, and any often-used responses that don't contain sensitive information or dynamic information, such as account numbers.

By default, the Media Relay does not cache any Text to Speech responses. When caching is enabled, the Media Relay caches all Text to Speech responses. Therefore, configuring response caching requires two parts: enabling caching for the Media Relay container and excluding responses with sensitive or dynamic information from the cache. In addition to these steps, it's recommended that you encrypt the disk where Voice Gateway is deployed to protect all cached responses.

  1. Enable caching by setting the TTS_CACHE_TIME_TO_LIVE environment variable to the number of hours you want the cached responses to live.

    For example, with following configuration, responses from the Text to Speech service that were not used within the past 336 hours (2 weeks) are removed from the cache.

TTS_CACHE_TIME_TO_LIVE=336


1. Exclude responses that contain sensitive or dynamic information from being cached by setting the `vgwActExcludeFromTTSCache` action tag on each respective node in the Watson Assistant dialog.

  ```json
{
  "output": {
    "vgwAction": {
      "command": "vgwActExcludeFromTTSCache"
    }
  }
}
Be sure to not cache responses that contain Protected Health Information (PHI), personally identifiable information (PII), or PCI Data Security Standard (PCI DSS) data so that the security of the information is maintained.

Dynamic information, such as any response that changes based on the customer or date, should not be cached because each unique response that is added fills the cache with data that is rarely reused.

Creating a persistent cache by using Docker volumes

Within the Media Relay container, cached responses are saved in the /vgw-media-relay/tmp/text-to-speech/ directory. By default, the cache for Text to Speech is deleted whenever the Media Relay container is removed. For the cache to persist, you'll need to use a Docker volume. The cached responses will be stored in the Docker volume and can be easily reused.

For Docker Engine

To mount a local directory as a Docker volume, open the docker-compose.yml file and define a local directory to store the cache.

media.relay:
  ...
  volumes:
    - ./text-to-speech-cache/:/vgw-media-relay/tmp/text-to-speech