Skip to main content

Synthesis and playback errors

On-Premise

In a call, the bot can play phrases:

  • Using speech synthesis. For example:

    a: Hello!
  • Using a pre-recorded audio file. For example:

    audio: https://example.com/hello.wav

If a synthesis error or file playback error occurs, the bot by default skips the phrase and moves on to the next reaction.

You can enable handling of such errors. The handling allows you:

info

Synthesis and playback error handling is only available in on-premise JAICP installations.

Backup audio file

Enable error handling and add a backup audio file. See the instruction in the On-Premise documentation.

If handling is enabled, the bot uses a backup audio file every time there is a synthesis or playback error.

Take a look at the script:

state: Promo
q!: Tell me about current offers
a: We have a new special offer!
audio: https://example.com/audio.wav
a: Would you like to participate?

Let’s assume that the audio file at https://example.com/audio.wav is unavailable. If the bot transitions to the Promo state, then it:

  1. Says: We have a new special offer!.
  2. Tries to play the https://example.com/audio.wav audio file. An error occurs and the bot plays the backup audio file instead of this phrase.
  3. Says: Would you like to participate?.

speechInvalid event

The speechInvalid event is triggered when a synthesis or playback error occurs.

Considerations

In the state with the speechInvalid event:

  • Reactions start to execute immediately after the error occurs. They are executed asynchronously to the reactions of the current state.
  • If you specify bot phrases, they will not be played.
  • Use the noContext = true parameter to prevent the bot context from transitioning to this state.
state: Promo
q!: Tell me about current offers
a: We have a new special offer!
audio: https://example.com/audio.wav
a: Would you like to participate?

state: Error || noContext = true
event!: speechInvalid
script:
$analytics.setComment("Synthesis or audio problem");

Let’s assume that the audio file at https://example.com/audio.wav is unavailable. If the bot transitions to the Promo state, then it:

  1. Says: We have a new special offer!.
  2. Tries to play the https://example.com/audio.wav audio file. An error occurs and the bot plays the backup audio file instead of this phrase.
  3. Starts executing reactions from the Error state. The bot writes a comment to analytics: Synthesis or audio problem.
  4. Says: Would you like to participate?.
  5. Waits for the next user request or a new event in the Promo state, as the Error state has the noContext parameter enabled.

Stop the following phrases

If an error occurs, you can stop all the following phrases using the $dialer.continueSpeech method. The bot will not play phrases using synthesis or from audio files until it receives a new user request or event.

Use this method only in a state with the speechInvalid event. Pass false as an argument:

state: Promo
q!: Tell me about current offers
a: We have a new special offer!
audio: https://example.com/audio.wav
a: Would you like to participate?

state: Error || noContext = true
event!: speechInvalid
script:
$dialer.continueSpeech(false);
$analytics.setComment("Synthesis or audio problem");

Let’s assume that the audio file at https://example.com/audio.wav is unavailable. If the bot transitions to the Promo state, then it:

  1. Says: We have a new special offer!.

  2. Tries to play the https://example.com/audio.wav audio file. An error occurs and the bot plays the backup audio file instead of this phrase.

  3. Starts executing reactions from the Error state:

    1. Gets the value set by the $dialer.continueSpeech method, which is false.
    2. Writes a comment to analytics: Synthesis or audio problem.
  4. Does not say: Would you like to participate?.

  5. Waits for the next user request or a new event in the Promo state, as the Error state has the noContext parameter enabled.

tip

If you want the bot to continue playing phrases, do not specify $dialer.continueSpeech in the state with the speechInvalid event. Or specify $dialer.continueSpeech(true) in this state: in both cases the behavior will be the same.