How can I generate a half second pause in TwiML?

回眸只為那壹抹淺笑 提交于 2019-12-10 14:42:05

问题


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.


回答1:


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.




回答2:


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.




回答3:


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;
}


来源:https://stackoverflow.com/questions/12628933/how-can-i-generate-a-half-second-pause-in-twiml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!