语音转文本禁用 Windows 自动处理程序并写下我所说的

发布于 2024-11-17 23:04:21 字数 641 浏览 4 评论 0原文

我已经开始使用 .NET 语音转文本库 (SpeechRecognizer)

在谷歌搜索和搜索此站点时,我发现了此代码示例:

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;

这帮助我开始了。 更改了这两行

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

我根据需要

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

但是,当我说“关闭”时,Windows 的语音识别器会关闭我的应用程序!

另外,有没有比创建自己的字典更好的识别语音的方法?我希望用户说这样的话:“给自己写一张便条”,然后用户会说话,我会写。

抱歉,在同一个问题上问了两个问题,这两个问题似乎都与我的一个问题相关。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白日梦 2024-11-24 23:04:21

您正在使用共享语音识别器(SpeechRecognizer)。当你实例化时
SpeechRecognizer 为您提供了一个可以由其他应用程序共享的识别器,通常用于构建应用程序来控制窗口和桌面上运行的应用程序。

听起来您想使用自己的私有识别引擎(SpeechRecognitionEngine)。因此,请实例化 SpeechRecognitionEngine。

请参阅SpeechRecognizer 类

禁用内置语音识别命令?也可能有一些有用的信息。

微软的桌面识别器包括一种称为听写语法的特殊语法,可用于转录用户所说的任意单词。您可以使用听写语法进行转录风格识别。请参阅 DictationGrammar 类SAPI 和 Windows 7 问题

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

卷耳 2024-11-24 23:04:21

我有一个更好的答案....

尝试向您的识别器添加听写语法...它似乎禁用所有内置命令,如选择/删除/关闭等..

然后您需要使用语音识别事件和 SendKeys向页面添加文本。到目前为止,我的发现表明 SAPI 蛋糕不能鱼与熊掌兼得。

我认为如果您还没有解决(或继续),上面的解决方案应该适合您。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文