0

I am trying to use speech recognition to trigger reco.speechrecognized events on ANY number announcement

currently I have had success with using dictionary

    reco.SetInputToDefaultAudioDevice()

    Dim gram As New Recognition.SrgsGrammar.SrgsDocument

    Dim callRule As New Recognition.SrgsGrammar.SrgsRule("numbers)

    Dim termList As New Recognition.SrgsGrammar.SrgsOneOf("one", "two", "three", "four", "five")

    callRule.Add(termList)

    gram.Rules.Add(callRule)

    gram.Root = callRule

    reco.LoadGrammar(New Recognition.Grammar(gram))

    reco.RecognizeAsync()

obviously that would be horrible to create an entire dictionary of 0 to 5000

then operating a recognition sub

Private Sub reco_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognitionEventArgs) Handles reco.SpeechRecognized

Select Case e.Result.Text
    Case "one"
        'action
    Case "two"
        'action
    'etc
End select

End sub

I ideally want to fire these events regardless of what number was spoken. I essentially would need a statement to replace the select

if e.Result.Text (is a number) then
    'number
else
    'some other command
end if

is there a better way of doing this

James Stafford
  • 1,034
  • 1
  • 15
  • 41

1 Answers1

0

I think you might be able convert a bunch of numbers to text using the answers to the following question. Using the strings you should be able to add these strings into your grammer.

How can I convert an integer into its verbal representation?

converting numbers in to words C#

Community
  • 1
  • 1
Travis
  • 2,105
  • 2
  • 26
  • 35