Reputation: 31
While sending a response to the user how do I add a pause/break of few seconds? Here is an example:
Response text: "The answer to the question is < Pause-For-2-Seconds > answer"
I tried the <break = "2s" />
and that do not work for me.
Upvotes: 3
Views: 3536
Reputation: 3486
For voice agents its often important to use Speech Synthesis Markup Language (SSML) in their responses to make their output sound more natural.
For Dialogflow-CX that works when the fullfillment response comes from a webhook request. That works like following: Your Dialogflow agent sends a WebhookRequest to your servers. The called route responds with an WebhookResponse object containing a FullfillmentResponse with an according ResponseMessage that got outputAudioText property set with proper ssml key set up. Your agent will use that response and e.g. make a pause after certain word like in my example following.
To clearify that a bit I will show you an example WebhookResponse object and how it could look:
const returnObject: WebhookResponse = {
fulfillmentResponse: {
messages: [
{
responseType: ResponseType.RESPONSE_TYPE_UNSPECIFIED,
channel: 'default',
outputAudioText: {
allowPlaybackInterruption: false,
ssml: `<speak>Okay, vielen Dank! Wir übermitteln Ihren Namen, Rufnummer
und Ihre gewünschte Rückrufzeit an unser Vertriebsteam und versuchen Sie
am $session.params.date um $session.params.time Uhr zu erreichen <break time="1s"/>Auf wiedersehen</speak>`,
},
},
],
mergeBehavior: MergeBehavior.REPLACE,
},
sessionInfo: {
session: body.sessionInfo.session,
parameters: {
time: '12:30',
date: '11.1.2024',
},
},
}
Here you can see the bespoke fullfillment response and the use of SMLL to further instruct the TTS system on how to act. Furthermore $session parameters are overwritten via the sessionInfo property. This overwritten paramters are also used in the agent response created via our SMLL expression.
Upvotes: 0
Reputation: 329
You have to use SSML on your answer, to do that just wrap what your response is with <speak>
tag then add another tag <break time="2s"/>
, like this:
<speak>The answer to the question is <break time="2s"/> answer</speak>
For a more complete information on SSML check this.
Upvotes: 6