首页 > 解决方案 > Twilio Studio 说/收集提示

问题描述

我们正在使用 Twilio Studio 来管理我们的 IVR 流,并且在识别特定数字时遇到了问题。

示例:其中包含 22 的验证码被 Twilio 识别为“tutu”

除了更改“识别语言”之类的设置之外,我想让 Twilio 比其他输入更能识别数字。有一个“语音识别提示”选项,它是一个逗号分隔的值列表——但你应该在里面放什么?该文档仅讨论逗号分隔的列表,仅此而已!

感激地收到任何帮助。

提前致谢

标签: twiliospeech-recognitionivrtwilio-studio

解决方案


您可以查看进入$OOV_CLASS_DIGIT_SEQUENCE提示部分是否对捕获的SpeechResult.

另一种选择是通过将 tutu 转换为 22 的标准化 Twilio 函数运行结果。

我会在捕获数字时推荐 DTMF,以避免这种情况。

// converts number words to integers (e.g. "one two three" => 123)

function convertStringToInteger( str ) {
    let resultValue = "";
    let arrInput = [];
    let valuesToConvert = {
        "one": "1",
        "two": "2",
        "to": "2",
        "three": "3",
        "four": "4",
        "five": "5",
        "six": "6",
        "seven": "7",
        "eight": "8",
        "nine": "9",
        "zero": "0"
    };

    str = str.replace(/[.,-]/g," ");  // sanitize string for punctuation

    arrInput = str.split(" ");      // split input into an array

    // iterate through array and convert values
    arrInput.forEach( thisValue => {
      if( ! isNaN(parseInt(thisValue)) ) {  // value is already an integer
        resultValue += `${parseInt(thisValue)}`;

      } else {  // non-integer
        if( valuesToConvert[thisValue] !== undefined) {
          resultValue +=  valuesToConvert[thisValue];
        } else {
          // we don't know how to interpret this number..
          return false;
        }
      }
    });

    console.log('value converted!', str, ' ====> ', resultValue);
    return resultValue;
}

推荐阅读