Speech programming
-
Hi.. Ihave downloaded the microsoft SAPI SDK to make a simple speech Recognition C# application.After search the internet for examples i wrote the code: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using SpeechLib; using System.IO; namespace ReviewWinApp { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form {private SpSharedRecoContext objRecoContext; private SpeechLib.ISpeechRecoGrammar grammar; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.Button button1; private System.Windows.Forms.TextBox tbxOFile; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.RadioButton rdoEVoice; private System.Windows.Forms.MenuItem menuItem4; private System.Windows.Forms.Button button2; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.menuItem1 = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.menuItem3 = new System.Windows.Forms.MenuItem(); this.menuItem4 = new System.Windows.Forms.MenuItem(); this.button1 = new System.Windows.Forms.Button(); this.tbxOFile = new System.Windows.Forms.TextBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.rdoEVoice = new System.Windows.Forms.RadioButton(); this.button2 = new System.Windows.Forms.Button(); this.groupBox1.Sus
-
Hi.. Ihave downloaded the microsoft SAPI SDK to make a simple speech Recognition C# application.After search the internet for examples i wrote the code: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using SpeechLib; using System.IO; namespace ReviewWinApp { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form {private SpSharedRecoContext objRecoContext; private SpeechLib.ISpeechRecoGrammar grammar; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.Button button1; private System.Windows.Forms.TextBox tbxOFile; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.RadioButton rdoEVoice; private System.Windows.Forms.MenuItem menuItem4; private System.Windows.Forms.Button button2; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.menuItem1 = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.menuItem3 = new System.Windows.Forms.MenuItem(); this.menuItem4 = new System.Windows.Forms.MenuItem(); this.button1 = new System.Windows.Forms.Button(); this.tbxOFile = new System.Windows.Forms.TextBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.rdoEVoice = new System.Windows.Forms.RadioButton(); this.button2 = new System.Windows.Forms.Button(); this.groupBox1.Sus
From what I can see, you dont appear to have started
grammar
(I assumebutton2_Click
is the method that you want to start the recognition). Try placing the following code at the end of that method...grammar.DictationSetState(SpeechRuleState.SGDSActive);
Just a guess :)
“Accept that some days you are the pigeon, and some days you are the statue” -- David Brent Cheers, Will H
-
From what I can see, you dont appear to have started
grammar
(I assumebutton2_Click
is the method that you want to start the recognition). Try placing the following code at the end of that method...grammar.DictationSetState(SpeechRuleState.SGDSActive);
Just a guess :)
“Accept that some days you are the pigeon, and some days you are the statue” -- David Brent Cheers, Will H
You are right.. After i have added your code the dictation grammar worked..that helped me to find how to use the grammar in my file(tryRecog.xml) as a context free grammar (CFG) using the code:
grammar.CmdSetRuleIdState(0,SpeechRuleState.SGDSActive);
You found exactly where does the error exist in the whole code..That was realy impressive.Thank you very much. -
From what I can see, you dont appear to have started
grammar
(I assumebutton2_Click
is the method that you want to start the recognition). Try placing the following code at the end of that method...grammar.DictationSetState(SpeechRuleState.SGDSActive);
Just a guess :)
“Accept that some days you are the pigeon, and some days you are the statue” -- David Brent Cheers, Will H
-
Hi..iam happy to talk to you again. I want to use the CmdLoadFromResource() method of ths speech SDK 5.1 to make the xml file that includes the Grammar embeded but i dont know how to use this method in C#. Do you know how to use this method?
I'm sorry, but I have never used this method. I haven't used XML files for use with SAPI either. I think your best bet would be to ask again in the forums, or just try and attempt it and see what happens. Sorry I couldn't be of more help.
“Accept that some days you are the pigeon, and some days you are the statue” -- David Brent Cheers, Will H
-
I'm sorry, but I have never used this method. I haven't used XML files for use with SAPI either. I think your best bet would be to ask again in the forums, or just try and attempt it and see what happens. Sorry I couldn't be of more help.
“Accept that some days you are the pigeon, and some days you are the statue” -- David Brent Cheers, Will H