Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 472
  • Last Modified:

Voice Recognition coding for .net

Greetings to all,

I would like to develop a function which is voice recognition, eg. I can say “open program”, then the program will be open etc.

Anyone have resources on this?

TQ
0
JYnet
Asked:
JYnet
  • 2
  • 2
  • 2
1 Solution
 
AaronReamsCommented:
I'm not sure how much of this you'll want to do yourself as its pretty complicated.  If possible I'd consider using a third party voice recoginition SDK.  I've used SpeechWorks Dragon before and it worked out fairly well.  Training the system always improves accuracy.

http://www.scansoft.com/naturallyspeaking/sdk/client/

Or your could always just use the Microsoft speech SDK but I'm not as familiar with their product.

http://www.microsoft.com/downloads/details.aspx?FamilyId=5DAAE9C4-188C-4547-A9D6-1671132A39A1&displaylang=en&EventType=hp

0
 
JYnetAuthor Commented:
no need too complicated, only record my voice, like "open word", then it will compare the wave, then open MS word.
0
 
AaronReamsCommented:
Hmmm, sounds tricky to me.

You might try and look at this article for vocal stress analysis.  Perhaps you can extrapolate some functionality for your project from this source code.

http://www.codeproject.com/netcf/ShakyVoice.asp

Anyway, Good luck.  If you don't mind, let me know if you get it all working.  It sounds kewl.

Regards,
Aaron
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
thedude112286Commented:
The math required for voice recognition is well above my head but Microsoft's Speech API (SAPI) does the job for you.  I think it comes pre-installed on most Windows computers but you might want to check MSDN on that.  If you want to recieve commands by voice, try this:

// project created on 8/8/2003 at 9:38 PM
using System;
using System.Windows.Forms;
using SpeechLib;

namespace SAPI_tester
{
      class Reco      {
            private SpSharedRecoContext context;

            public Reco()
            {
                  //SR
                  context = new SpSharedRecoContext();
                                    
                  //setup event sync                  
                  context.EventInterests = SpeechRecoEvents.SRERecognition;
                  context.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(OnRecognition);
                                                Init();
            }
            
            protected void Init() {
                  //Free dictation
                  /*ISpeechRecoGrammar grammar = context.CreateGrammar(1);
                  
                  grammar.DictationLoad("", SpeechLoadOption.SLOStatic);
                  grammar.DictationSetState(SpeechRuleState.SGDSActive);*/
                  
                  //Grammar, Rule-Based C&C
                  string fileName = Application.StartupPath + @"\grammar.xml";
                  int ruleID = 0;
                  
                  ISpeechRecoGrammar grammar = context.CreateGrammar(1);
                  grammar.CmdLoadFromFile(fileName, SpeechLoadOption.SLOStatic);
                  grammar.DictationSetState(SpeechRuleState.SGDSInactive);
                  grammar.CmdSetRuleIdState(ruleID, SpeechRuleState.SGDSActive);
            }
            
            public void OnRecognition(int streamNumber, object streamPosition, SpeechRecognitionType recognitionType, ISpeechRecoResult result)
            {
                  string txt = result.PhraseInfo.GetText(0, result.PhraseInfo.Elements.Count, false);
            }
      }                  
}


And an example grammar.xml file:

<GRAMMAR>
<!--      
      <RULE ID="0" NAME="main" TOPLEVEL="ACTIVE">
            <P PROPNAME="StuffPreNumber"><O>*+</O></P>
            <RULEREF NAME="number" />
      </RULE>
      
      <RULE ID="1" NAME="number">
            <L PROPNAME="number">
                  <P VAL="0">zero</P>
                  <P VAL="1">one</P>
                  <P VAL="2">two</P>
            </L>
      </RULE>
-->
      <RULE ID="0" NAME="Main" TOPLEVEL="ACTIVE">
            <L PROPNAME="CommandType">
                  <P VAL="SingleArgument">
                        <RULEREF NAME="NoArgumentCommand" />
                  </P>
                  <P VAL="TwoArgument">
                        <RULEREF NAME="SingleArgumentCommand" />
                  </P>
            </L>
      </RULE>
      
      <RULE ID="1" NAME="NoArgumentCommand">
            *+
            <RULEREF NAME="NoArgumentAction" />
      </RULE>
      
      <RULE ID="2" NAME="SingleArgumentCommand">
            *+
            <RULEREF NAME="SingleArgumentAction" />
            <P PROPNAME="Argument">*+</P>
      </RULE>
      
      <RULE ID="3" NAME="NoArgumentAction">
            <L PROPNAME="NoArgumentAction">
                  <P VAL="Play">Play</P>
                  <P VAL="Stop">Stop</P>
                  <P VAL="Pause">Pause</P>
                  <P VAL="LastTrack">
                        <L>                        
                              <O>Go to the</O>
                              <O>Play the</O>
                        </L>
                        <L>
                              <P>last</P>
                              <P>previous</P>
                        </L>
                        <L>
                              <P>track</P>
                              <P>song</P>
                        </L>
                  </P>
                  <P VAL="NextTrack">
                        <L>                        
                              <O>Go to the</O>
                              <O>Play the</O>
                        </L>
                        next
                        <L>
                              <P>track</P>
                              <P>song</P>
                        </L>
                  </P>
                  <P VAL="SongName">
                        <L>
                              <P>What song is this</P>
                              <P>What's this song called</P>
                              <P>What is this song called</P>
                              <P>What's the name of this song</P>
                              <P>What is the name of this song</P>
                        </L>
                  </P>
                  <P VAL="Artist">
                        <L>
                              <P>Who *+</P>
                              <P>What band *+</P>
                              <P>Which band *+</P>
                              <P>What group *+</P>
                              <P>Which group *+</P>
                              <P>What artist *+</P>
                              <P>Which artist *+</P>
                        </L>
                  </P>
            </L>
      </RULE>
      
      <RULE ID="4" NAME="SingleArgumentAction">
            <L PROPNAME="NoArgumentAction">
                  <P VAL="Play">Play</P>
                  <P VAL="Stop">Stop</P>
            </L>
      </RULE>      
</GRAMMAR>
0
 
JYnetAuthor Commented:
Dude,

do i need to download and install SAPI before i can run ur code? or just open a new c# project and paste ur code to compile like that?
0
 
thedude112286Commented:
SAPI must be installed on the user's computer and you will need SpeechLib.dll, the managed interface (Interop Assembly).  If you need help finding them, just ask.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now