开发者

speech-to-text disable windows auto handler and write what i say

开发者 https://www.devze.com 2023-03-16 22:03 出处:网络
I\'ve started using .NET speech-to-text library (SpeechRecognizer) While googling and searching this site i found this code sample:

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 GrammarBu开发者_开发技巧ilder(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.


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


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消