How can I generate a half second pause in TwiML?
Asked Answered
P

3

5

I'm trying to use Twilio's <Say> verb to pronounce a sequence of digits clearly. I'm finding it is hard to generate a natural (half-second) pause between each digit. How do I do this correctly?

The <Pause> xml command only takes integer values for seconds, so it's too long to use.

Partee answered 27/9, 2012 at 19:44 Comment(0)
M
9

From here: Link

  • When saying numbers, '12345' will be spoken as "twelve thousand three hundred forty five." Whereas '1 2 3 4 5' will be spoken as "one two three four five."

  • Punctuation such as commas and periods will be interpreted as natural pauses by the speech engine.

  • If you want to insert a long pause try using the <Pause> verb. <Pause> should be placed outside <Say> tags, not nested inside them.

Manvell answered 28/9, 2012 at 13:16 Comment(2)
i used four periods to get the half second pause.Partee
I guess that classifies a "natural pause" as 125 milliseconds. :PManvell
C
5

For less then one second pause:

<Say language="en-US" voice="alice">
Your verification code is 1,,,,2,,,,3,,,,4,,,,5
</Say>

You can increase and decrease the number of commas according to you convenience.

Certitude answered 6/8, 2014 at 9:42 Comment(0)
C
1

This is tangentially related, but I figured people looking for something similar would end up on this question (like I did).

I wanted the Say verb to read a US phone number in a natural 3-3-4 cadence. Here is some C# that does just that. I'm sure you can figure out how to translate it to other languages:

private static string SayNaturalNumber(string digits)
{
    var newNumber = "";
    for (int i = 0; i < digits.Length; i++)
    {
        if (i == 0)
            newNumber += digits[i];
        else
            newNumber += " " + digits[i];

        if (i == 2) //after third digit
            newNumber += ",,,,";

        if (i == 5) //after sixth digit
            newNumber += ",,,,";
    }
    return newNumber;
}
Cardwell answered 23/10, 2015 at 18:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.