2

我试图找出我是否可以System.Speech.SpeechRecognitionEngine 在 5 秒的时间间隔内使用来计算音节或单词。

我一直在SpeechRecognitionEngine使用 、DictationGrammarSpeechRecognized事件进行一些测试。

我需要创建一个应用程序,让你知道你是否说得太慢了,这就是为什么我想计算每 5 秒说多少字。

任何帮助将不胜感激

谢谢

4

1 回答 1

1

我不是 100% 确定您要使用什么平台,但这似乎是 windows。

因此,MSDN 上的代码示例将是开始获取识别事件信息和获取音频信息的好地方。

http://msdn.microsoft.com/en-us/library/system.speech.recognition.recognitionresult.aspx

// Display information about the words in the recognition result.
  foreach (RecognizedWordUnit word in e.Result.Words)
  {
    RecognizedAudio audio = e.Result.GetAudioForWordRange(word, word);
    Console.WriteLine(" {0,-10} {1,-10} {2,-10} {3} ({4})",
      word.Text, word.LexicalForm, word.Pronunciation,
      audio.Duration, word.DisplayAttributes);
  }

但是,也可以使用 AudioSignalProblem 枚举来检测一个人是否说话太慢。唯一的缺点是它不可配置。此链接中的代码:http: //msdn.microsoft.com/en-us/library/system.speech.recognition.audiosignalproblem.aspx

// Initialize the speech recognition engine.
private void Initialize()
{
  sre = new SpeechRecognitionEngine();

  // Add a handler for the AudioSignalProblemOccurred event.
  sre.AudioSignalProblemOccurred += new EventHandler<AudioSignalProblemOccurredEventArgs>(sre_AudioSignalProblemOccurred);
}

// Gather information when the AudioSignalProblemOccurred event is raised.
void sre_AudioSignalProblemOccurred(object sender, AudioSignalProblemOccurredEventArgs e)
{
  StringBuilder details = new StringBuilder();

  details.AppendLine("Audio signal problem information:");
  details.AppendFormat(
    " Audio level:               {0}" + Environment.NewLine +
    " Audio position:            {1}" + Environment.NewLine +
    " Audio signal problem:      {2}" + Environment.NewLine +
    " Recognition engine audio position: {3}" + Environment.NewLine,
    e.AudioLevel, e.AudioPosition, e.AudioSignalProblem,
    e.recoEngineAudioPosition);

  // Insert additional event handler code here.
}
于 2013-05-05T16:23:29.520 回答