How can i add pause to Twilio studio Say/Play widget

前端 未结 3 1652
渐次进展
渐次进展 2021-01-14 05:06

I have a say widget

> \"Hello ... Thanks\"

I\'ve tried add a pause string like twilML to that element like so

> \"He         


        
相关标签:
3条回答
  • 2021-01-14 05:43

    Really somebody at Twilio should create a PAUSE widget for Studio.

    Until then if you're happy using an ugly hack... here it is:

    Since you can add a function widget in the flow, create a Twilio "Runtime Function" (I called it "Pause")


        exports.handler = function(context, event, callback) {
    
            const duration = event.duration || 1500; 
    
            setTimeout(
                function() {
                    // console.log(duration);
                    callback();          
                } , duration);
    
        };
    

    then, replace one "Say" widget with "Say" widget + "Pause" function widget + "Say" widget.

    When you add the "Pause" widget configure it with parameters, add a duration parameter with a value that is no more than about 3000 to 4000 (I don't know exactly how to explain why but functions will 'runtime timeout' if the function takes more than 5 seconds to execute).

    When you add parameters, make sure they are in fact added..., I had some trouble until I figured out that you need to click on "Add Parameter" link after you fill the "Key", "Value" fields, instead I was clicking on the big "Save" button.

    Since you are looking for a 10 seconds pause, you might try to cascade 3 "Pause" widgets with duration parameter (3000, 3000, 4000), between your "Say" widgets.

    I've tested this and I was able to make a pause between 2 "Say" widgets of 7 seconds by inserting one 3000 pause and one 4000 pause functions.

    I hope it helps.

    0 讨论(0)
  • 2021-01-14 06:00

    Got this from Twilio support

    The spaced out periods only works for the legacy voices (man, woman, alice).

    If you're using the new Polly voices, you need to embed SSML in the Say text area, such as:

    <speak>Hello. <break time="5s"/> Goodbye.</speak>
    

    Worked fine for me.

    0 讨论(0)
  • 2021-01-14 06:05

    According to Twilio documentation on widgets, pauses can be added by placing space separated periods, where 15 of these is equivalent to 1 second delay.

    So, the following Text to say would have a 1 second delay between sentences:

    Hello, John!
     . . . . . . . . . . . . . . .
    Today is a very nice day.
    
    0 讨论(0)
提交回复
热议问题