如何听写过程中获得候补单词语的SAPI 5.4使用C#? [英] How to get alternate single words during dictation in SAPI 5.4 using C#?

查看:333
本文介绍了如何听写过程中获得候补单词语的SAPI 5.4使用C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行语音识别和新技术,用户研究。在实验室测试中,我需要用我编程接口来显示所有的听写文本。

I am running a user study with speech recognition and new technologies. During the laboratory tests, I need to display all the dictated text using an interface that I programmed.

目前,我可以在C#中备用整个句子,但我需要获得单个单词。例如,如果有人说你好,我的名字叫安德鲁,我想获得一个替代词你好,我的,姓名,是,并为完整的安德鲁,而不是替代判决。

Currently, I can get the alternate whole sentences in C# but I need to get the single words. For example, if someone says "Hello, my name is Andrew", I want to get an alternate word for "Hello", "my", "name", "is" and "Andrew", instead of an alternate for the complete sentence.

下面是我使用的处理程序的代码片段。

Here is a code snippet of the handler I'm using.

public void OnSpeechRecognition(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
{
    int NUM_OF_ALTERNATES = 5; // Number of alternates sentences to be read
    string recognizedSentence = Result.PhraseInfo.GetText(0, -1, true);

    // Get alternate sentences
    ISpeechPhraseAlternates phraseAlternates = Result.Alternates(NUM_OF_ALTERNATES);
}



任何想法表示赞赏。

Any ideas are appreciated.

推荐答案

您需要指定元素计数,并在Result.Alternates指数调用。

You need to specify the element count and index in the Result.Alternates call.

例如,

public void OnSpeechRecognition(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
{
    int NUM_OF_ALTERNATES = 5; // Number of alternates sentences to be read
    string recognizedSentence = Result.PhraseInfo.GetText(0, -1, true);

    // Get alternate sentences
    int elementCount = Result.PhraseInfo.Elements.Count();
    for (int i = 0; i < elementCount; ++i)
    {
          ISpeechPhraseAlternates phraseAlternates = Result.Alternates(NUM_OF_ALTERNATES, i, 1);
    }
}

这篇关于如何听写过程中获得候补单词语的SAPI 5.4使用C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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