简体   繁体   中英

SpeechRecognitionEngine AppendDictation verus DictationGrammar and numbers

I am trying to use the speechrecognitionengine to recognize a grammar that includes some choices from a specific set, followed by an arbitrary numeric value followed by a choice set. So "[Choice1,Choice2,Choice3] 1563 [ChoiceA,ChoiceB,ChoiceC]" Doing this with by appending a Choices array, AppendDictation() and Appending another Choices grammer works well, except that the number recognized in the AppendDictation portion comes through as "One thousand five hundred sixty-three" instead of 1563. This is counter intuitive to me because if you replace all of the above with a DictationGrammer, the number is recognized as 1563 instead of that long form example above. I would prefer to use the GrammarBuilder method with specific choice sets to increase the likelihood the right commands / phrase are recognized. Any help would be appreciated, thanks!

Also, I can't just add numbers into a Choices array because it would need to be massive due to the range of possible numbers.

Try this:

AppendDictation("spelling");

This workaround however, will not work if you say anything above 9, so for 1563 you will have to say out loud "one, five, six, three". The resulting text will be 1563.

Alternatively you could try what has been answered in this post: Converting words to numbers in PHP

Edit: Better answer in this post. Has the function to convert words into actual numbers Convert words (string) to Int

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM