Search code examples
botsamazon-lex

Instead of taking an ordinal number [2nd] in voice recognition it is taking [second] as an audio input


In the Postal Address slot-type I want a user to speak output as a following way - "190 east 72nd street"

But it takes input as "190 east 70 second street" which is not appropriate.

So is there any way? I have tried doing with SSML tags but not getting proper output. Thank you.


Solution

  • We need to use a regular expression and we can replace the string with the correct output.

    import re if "0 second" in postal: y = re.sub("0 second","2nd",postal) elif "second" in postal: y = re.sub("second","2nd", postal) else: y = postal