【问题标题】:How to get alternate single words during dictation in SAPI 5.4 using C#?如何使用 C# 在 SAPI 5.4 中听写期间获取备用单个单词?
【发布时间】:2013-01-04 00:01:29
【问题描述】:

我正在开展一项有关语音识别和新技术的用户研究。在实验室测试期间,我需要使用我编写的界面显示所有口述文本。

目前,我可以在 C# 中获取替代的整个句子,但我需要获取单个单词。例如,如果有人说“你好,我的名字是 Andrew”,我想得到“Hello”、“my”、“name”、“is”和“Andrew”的替代词,而不是完整的替代词句子。

这是我正在使用的处理程序的代码 sn-p。

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);
}

感谢任何想法。

【问题讨论】:

    标签: c# speech-recognition speech-to-text sapi


    【解决方案1】:

    您需要在 Result.Alternates 调用中指定元素计数和索引。

    例如,

    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);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-22
      • 1970-01-01
      • 2012-08-09
      • 1970-01-01
      • 2021-02-28
      • 1970-01-01
      相关资源
      最近更新 更多