Carlos Lone
Carlos Lone

Reputation: 29

Use Speech Recognition to count syllables

I'm trying to find out if I can use System.Speech.SpeechRecognitionEngine to count syllables or words during a 5 sec time lapse.

I have been doing some tests with the SpeechRecognitionEngine, using the DictationGrammar and the SpeechRecognized event.

I need to create an App that let you know if you're speaking too slow, that's why I want to count how many words are being said every 5 seconds.

Any helps would be apreciated

Thanks

Upvotes: 2

Views: 996

Answers (1)

Matt Johnson
Matt Johnson

Reputation: 1931

I am not 100% sure what platform you are trying to use, but this appears to be windows.

So the code sample on MSDN would be a good place to start to get recognition event information and to get audio information.

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

However detecting if a person is speaking too slow can also be done with the AudioSignalProblem enumeration. The only drawback to this is that it is not configurable. Code from this link: 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.
}

Upvotes: 1

Related Questions