Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello,
I'm trying to get DTMF Recognition to work.
I have a wav file that has a the number 1 recored from my phone. It's repeated 6 times and is recorded in 8K 16 bit linear PCM single channel. No recognition occurs Result = null). If I change the Mode to SrgsGrammarMode.Voice and the grammar to DictationGrammar I do get some random recognition. The wav file plays perfectly in media player.
I've looked all over the web and can't find much samples or help. Hopefully someone here has some experience.
thanks
Jim
Code snippet:
C#
string srgsDocumentFile = Path.Combine(Path.GetTempPath(), "srgsDocumentFile.xml");
SrgsDocument document = null;
GrammarBuilder builder = null;
Grammar grammar = null;

Choices firstThree = new Choices(new string[] { "1", "2", "3" });
Choices nextThree = new Choices(new string[] { "4", "5", "6" });
Choices lastThree = new Choices(new string[] { "7", "8", "9" });

Choices keyPadChoices = new Choices(new GrammarBuilder[] { firstThree, nextThree, lastThree, new Choices("0") });

builder = new GrammarBuilder(keyPadChoices);
document = new SrgsDocument(builder);

document.Mode = SrgsGrammarMode.Dtmf;
grammar = new Grammar(document);

RecognitionEngine.SetInputToWaveFile(@"c:\111111.wav");
RecognitionEngine.LoadGrammar(grammar);
RecognitionResult Result = RecognitionEngine.Recognize();
if (null != Result)
{
StringBuilder Output = new StringBuilder();
foreach (RecognizedWordUnit Word in Result.Words)
{
	Output.Append(Word.Text + " ");
}

}
Posted
Updated 19-Jun-12 7:55am
v2
Comments
Bernhard Hiller 20-Jun-12 2:17am    
What about
Choices firstThree = new Choices(new string[] { "one", "two", "three" });
and so on?
co2chicken 8-Oct-15 16:12pm    
Hey--

I know this post is old, but did you come to a resolution to make this code piece work? I'm trying to do the same thing with no luck (or documentation).

Thanks,
Ben

1 solution

Thanks Bernard
Just gave your suggestion a try and no joy.

Jim
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900