如何培养谁在使用我的代码,它实现system.speech和SpeechRecognitionEngine用户 [英] How to train a user who is using my code which implements system.speech and SpeechRecognitionEngine

查看:1350
本文介绍了如何培养谁在使用我的代码,它实现system.speech和SpeechRecognitionEngine用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用System.Speech.Recognition命名空间和使用语法和SpeechRecognitionEngine一个XML文件SRGS编码。

I have already coded using the System.Speech.Recognition namespace and use a XML SRGS file for grammer and the SpeechRecognitionEngine.

我希望能够带领。用户通过这是我写的应用程序重要的词或短语训练

I want to be able to lead the user through a training of the words or phrases that are important for the app I have written.

我刚才看到和阅读的如何培养SAPI 我明白,这例如使用非托管API(此API公开多一点),但是是完全一样的,只要发动机而言。

I have just seen and read this How to train SAPI I understand that this example uses the unmanaged API (this api exposes a little more) but is exactly the same as far as the engine is concerned.

所以,如果我现在成立了一个形式按照指令从链接开始训练。我可以有我自己在窗体上的文本,并要求用户在阅读这段文字。然后得出结论:训练中的链接显示。此过程将训练,我已经与System.Speech.Recognition命名编码我的语音引擎。

So if I now set up a form and follow the instruction from the link to initiate training. Can i have my own text on the form and ask the user to read this text. Then conclude the training as indicated in the link. This procedure will train my speech engine that I have already coded with the System.Speech.Recognition namespace.

如果我是不正确的是下一个最好的,我得到一个用户打开他们的系统面板,启动语音识别,并让他们决定到也许记事本我的特殊的短语,直到它得到他们的权利的大部分时间。

If I am incorrect is the next best, that I get a user to open their system panel, start the speech recognizer and get them to dictate into maybe Notepad my special phrases until it gets them right most of the time.

或者我只能建议他们做的一般培训?

Or can i only suggest to them to do the general training?

结论与一些其它的东西
中的C / C ++的语音开发者参考有许多它更多的东西比自动化参考。当你从尤其是埃里克·布朗和他的博客这个论坛或其他人的帖子在这里看到他很可能指的是C / C ++方法的更多。

Conclusion and a few other things The C/C++ speech developers reference has many more things in it than the Automation reference. When you see here in this forum or others posts from especially Eric Brown and his blog he is more than likely referring to the C/C++ methods.

使用下面的代码上对于第一次Win 7的64位机使我得到一个未注册的类异常和谷歌没有帮助我解决问题。我需要至少指定值为anycpu。

Using the below code on a Win 7 x64 bit machine for the first time caused me to get a "Class not registered" exception and Google did not help me to solve the problem. I needed to target at least "anycpu".

否则,下面是完美的,它基本上开始,否则你将在语音识别界面得到UI的培训的一部分在控制面板中,除非你有你自己的话。这是完美的。

Otherwise the below is perfect, it basically starts the Training part of the UI that you would otherwise get from the Speech Recognizer interface in Control Panel, except you have your own words. This is perfect.

推荐答案

一个更简单的方法是用自己的训练文本运行现有的培训UI。自动化兼容的API(微软语音对象库,又名SpeechLib)公开的 IspRecognizer :: DisplayUI ,你可以调用用自己的训练文本

A simpler alternative is to run the existing training UI with your own training text. The automation-compatible APIs (Microsoft Speech Object Library, aka SpeechLib) expose IspRecognizer::DisplayUI, and you can call that with your own training text.

在训练文本必须是一个双零终止的字符串,也被称为多字符串。下面是一些字符串数组转换为多串代码:

The training text needs to be a double-null terminated string, also known as a multistring. Here's some code that converts a string array to a multistring:

static string StringArrayToMultiString(
    ICollection<string> stringArray
    )
{
    StringBuilder multiString = new StringBuilder();


    if (stringArray != null)
    {
        foreach (string s in stringArray)
        {
            multiString.Append(s);
            multiString.Append('\0');
        }
    }

    return multiString.ToString();
}



然后,为了真正的呼叫的DisplayUI,你会做这样的事情:

Then, to actually call DisplayUI, you would do something like this:

static void RunTraining(string[] TrainingText)
{
    SpSharedRecoContext RC = new SpSharedRecoContext();
    string Title = "My App's Additional Training";
    ISpeechRecognizer spRecog = RC.Recognizer;
    spRecog.DisplayUI(hWnd, Title, SpeechLib.SpeechUserTraining, StringArrayToMultiString(TrainingText);
}

这篇关于如何培养谁在使用我的代码,它实现system.speech和SpeechRecognitionEngine用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆