0

We are using the Twilio Studio for managing our IVR flows, and have come across an issue when recognising particular numbers.

Example: A verification code that has 22 in it, is being recognised by Twilio as "tutu"

Aside from changing the settings like "recognition language", I'd like to get Twilio to recognise numbers more than other inputs. There is the option for "Speech Recognition Hints" which is a comma separate list of values - but what should you put in there? The documentation just talks about a comma separated list, nothing else!

Any help gratefully received.

Thanks in advance

Nunners
  • 15
  • 5

1 Answers1

0

You could see if entering $OOV_CLASS_DIGIT_SEQUENCE in the hints section has any impact on the captured SpeechResult.

Another option is to run the result through a normalization Twilio Function that converts tutu to 22.

I would recommend DTMF when capturing digits, to avoid this.

// 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;
}
Alan
  • 10,465
  • 2
  • 8
  • 9
  • We're are supporting both DTMF and voice, as we have a number of users who's DTMF signalling doesn't work. When you say $OOC_CLASS_DIGIT_SEQUENCE - is that within Studio or is that Functions? Thanks – Nunners May 19 '21 at 18:31
  • Within Studio Gather Widgets Hints. Recommendation is your right some code to normalize the responses you get. – Alan May 19 '21 at 19:45
  • Would you happen to have an example please? :) – Nunners May 21 '21 at 08:36
  • 1
    Just an FYI... DTMF digits are preferred, but we have a number of end users who are on speaker phones, whose DTMF signals don't work, hence the speec requirement. We've now built a "voice" parser, which does very similar to the above, but also includes a number of other entries - e.g. tutu => 22! Thanks – Nunners Jun 23 '21 at 17:03