SpeechRecognition issue

Posted by Leosa99 _ on Stack Overflow See other posts from Stack Overflow or by Leosa99 _
Published on 2014-08-23T16:07:27Z Indexed on 2014/08/23 16:20 UTC
Read the original article Hit count: 220

Filed under:

I'm creating a Speech Recognition Application like Siri in vb.net. I have found a database of words (in a .txt file) and i want to insert them in my application but its not working .

Here my code :

Dim WithEvents reco As New Recognition.SpeechRecognitionEngine Dim IA_VOICE As New SpeechSynthesizer Dim List_Word As New Recognition.SrgsGrammar.SrgsOneOf("IN database.")

Public Sub New()

    reco.SetInputToDefaultAudioDevice()

    Dim gram As New Recognition.SrgsGrammar.SrgsDocument

    Dim WORD_RULE As New Recognition.SrgsGrammar.SrgsRule("MOT")

    LOAD_DATABSE(Application.StartupPath & "\RECO_WORD\DataBase.txt")

    WORD_RULE.Add(List_Word)

    gram.Rules.Add(WORD_RULE)

    gram.Root = WORD_RULE
    reco.LoadGrammar(New Recognition.Grammar(gram))

    reco.RecognizeAsync()

End Sub

Private Sub reco_RecognizeCompleted(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognizeCompletedEventArgs) Handles reco.RecognizeCompleted
    reco.RecognizeAsync()
End Sub

   Private Sub reco_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognitionEventArgs) Handles reco.SpeechRecognized
    If e.Result.Text = "hi" Then
        MsgBox("HI!")
    End If
End Sub

Sub LOAD_DATABSE(Database_PATH As String)
    Dim lines() As String = File.ReadAllLines(Database_PATH)
    Dim numberLinesTotal = lignes.Length

    Dim numberlignedone As Integer = 0

    Dim MOT As New StreamReader(BDD_PATH)

    While numberlignedone <> numberLinesTota
        numberlignedone += 1
        Dim ITEM As New Recognition.SrgsGrammar.SrgsItem(MOT.ReadLine)
        Word_List.Items.Add(ITEMS)  'I think its here that its not working. 
    End While
    MsgBox("END LOADING")
End Sub</code>

If you know why its not working... Thanks.

© Stack Overflow or respective owner

Related posts about vb.net