我试图找出是否可以使用System.Speech.SpeechRecognitionEngine
在5秒的时间间隔内计算音节或单词。
我一直在使用SpeechRecognitionEngine
进行一些测试
DictationGrammar
和SpeechRecognized
事件。
我需要创建一个应用程序,让您知道如果说话太慢, 这就是为什么我要计算每5秒钟说出多少个单词的原因。
任何帮助都是apreciated
由于
答案 0 :(得分: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.
}