Click here to Skip to main content
15,896,540 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
VB
Public Class Form1
    Dim engine As New SpeechRecognitionEngine
    Dim gram As Grammar
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        Dim choices = New Recognition.Choices()
 
        choices.Add("Red")
        choices.Add("Blue")
        choices.Add("Green")
        choices.Add("Yellow")
        Dim gb = New GrammarBuilder()
 
        gb.Append(choices)
 
        Dim doc = New Speech.Recognition.SrgsGrammar.SrgsDocument(gb)
        IO.Directory.CreateDirectory("C:\Test")
        IO.Directory.CreateDirectory("C:\Test\Speech")
        Dim xWriter = System.Xml.XmlWriter.Create("C:\Test\Speech\mygrammar.xml")
 
        doc.WriteSrgs(xWriter)
        xWriter.Close()
 
        Dim compiledFile = New FileStream("C:\Test\Speech\mycompiledgrammar.cfg", FileMode.OpenOrCreate)
 
        Speech.Recognition.SrgsGrammar.SrgsGrammarCompiler.Compile("C:\Test\Speech\mygrammar.xml", compiledFile)
        compiledFile.Close()
 
        gram = New Grammar("C:\Test\Speech\mygrammar.xml")    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If gram IsNot Nothing Then
            engine.LoadGrammar(gram)
            engine.SetInputToWaveFile("D:\record.wav")
        Else
            ' The grammar wasn't loaded...
            ' Do something about the condition or notify the user.
        End If
    End Sub
End Class
Posted
Updated 8-Aug-13 4:41am
v4
Comments
Member 10194584 8-Aug-13 8:53am    
i saw this code on same site.

I need help to print the text from record.wav "engine.SetInputToWaveFile("D:\record.wav")".

Can someone help me with syntax.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900