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:
- To play a backup audio file if an error occurs.
- To get the
speechInvalid
event. - To stop the playback of the following bot phrases.
Synthesis and playback error handling is only available in on-premise Tovie Platform 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:
- Says:
We have a new special offer!
. - 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. - Says:
Would you like to participate?
.
speechInvalid event
The speechInvalid
event is triggered when a synthesis or playback error occurs.
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:
- Says:
We have a new special offer!
. - 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. - Starts executing reactions from the
Error
state. The bot writes a comment to analytics:Synthesis or audio problem
. - Says:
Would you like to participate?
. - Waits for the next user request or a new event in the
Promo
state, as theError
state has thenoContext
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:
-
Says:
We have a new special offer!
. -
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. -
Starts executing reactions from the
Error
state:- Gets the value set by the
$dialer.continueSpeech
method, which isfalse
. - Writes a comment to analytics:
Synthesis or audio problem
.
- Gets the value set by the
-
Does not say:
Would you like to participate?
. -
Waits for the next user request or a new event in the
Promo
state, as theError
state has thenoContext
parameter enabled.
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.