2

I've started using .NET speech-to-text library (SpeechRecognizer)

While googling and searching this site i found this code sample:

var c = new Choices();
for (var i = 0; i <= 100; i++)
  c.Add(i.ToString());
var gb = new GrammarBuilder(c);
var g = new Grammar(gb);
rec.UnloadAllGrammars();
rec.LoadGrammar(g);
rec.Enabled = true;

Which helped me to start. I changed these 2 lines

for (var i = 0; i <= 100; i++)
   c.Add(i.ToString());

to my need

c.Add("Open");
c.Add("Close");

But, when I say 'Close', the speech recognizer of windows closes my application!

In addition, Is there a better way to recognize speech than to create my own dictionary? I would like the user to say something like: "Write a note to myself" and then the user will speak and I'll write.

Sorry for asking 2 questions at the same question, both seem to be relevant to my one problem.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Oz Radiano
  • 779
  • 2
  • 11
  • 30

2 Answers2

1

I have a better answer....

Try adding a dictation Grammar to your recognizer... it seems to disable all built-in commands like select/delete/close etc..

You then need to use the speech recognized event and SendKeys to add text to the page. My findings so far indicate that you can't have your SAPI cake and eat it.

I think the solution above should work for you if you've not already solved it (or moved on).

WEFX
  • 8,298
  • 8
  • 66
  • 102
  • Actually, I moved on with this issue, but maybe someone else that have this problem will use your solution. Thanks anyway! – Oz Radiano Nov 19 '12 at 14:13
1

You are using the shared speech recognizer (SpeechRecognizer). When you instantiate SpeechRecognizer you get a recognizer that can be shared by other applications and is typically used for building applications to control windows and applications running on the desktop.

It sounds like you want to use your own private recognition engine (SpeechRecognitionEngine). So instantiate a SpeechRecognitionEngine instead.

see SpeechRecognizer Class.

Disable built-in speech recognition commands? may also have some helpful info.

Microsoft's desktop recognizers include a special grammar called a dictation grammar that can be used to transcribe arbitrary words spoken by the user. You can use the dictation grammar to do transcription style recognition. See DictationGrammar Class and SAPI and Windows 7 Problem

Community
  • 1
  • 1
Michael Levy
  • 13,097
  • 15
  • 66
  • 100