I am creating a speech recognition grammar using XML. I have the following XML code below. When a speech is recognized, I want to retrieve two tags. The person addressed and what greeting was used. I am unable to get any tags except for the latest generated tag for the speechEngine.result. How do I get both tags?
<grammar version="1.0" xml:lang="en-US" mode="voice" root="topLevel"
tag-format="semantics/1.0" xmlns="http://www.w3.org/2001/06/grammar">
<rule id="topLevel" scope="public">
<one-of>
<item><ruleref uri="#helloSequence" /></item>
</one-of>
</rule>
<rule id="helloSequence" scope="public">
<item><ruleref uri="#greetinglist"/></item>
<item><ruleref uri="#personlist"/></item>
</rule>
<rule id="personlist" scope="public">
<one-of>
<item>miyuki<tag>out.person="miyuki";</tag></item>
<item>lily<tag>out.person="lily";</tag></item>
</one-of>
</rule>
<rule id="greetinglist" scope="public">
<one-of>
<item>hey<tag>out.greeting="hey";</tag></item>
<item>hi<tag>out.greeting="hi";</tag></item>
</one-of>
</rule>
</grammar>
My Code for reading semantic values:
static void speechEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
//DEBUG DATA
Console.WriteLine("Recognized text:\t" + e.Result.Text);
Console.WriteLine("Confidence score:\t" + e.Result.Confidence);
Console.WriteLine("Semantic Count:\t\t" + e.Result.Semantics.Count);
if (e.Result.Semantics.ContainsKey("greeting"))
{
Console.WriteLine("TAG DATA\t\tGreeting tag:\t" + e.Result.Semantics["greeting"].Value.ToString());
}
else
{
Console.WriteLine("TAG DATA\t\tGreeting tag:\tNO GREETING TAG VALUE");
}
if (e.Result.Semantics.ContainsKey("person"))
{
Console.WriteLine("TAG DATA\t\tPerson tag:\t" + e.Result.Semantics["person"].Value.ToString());
}
else
{
Console.WriteLine("TAG DATA\t\tPerson Tag:\tNO PERSON TAG VALUE");
}
}
So if I input "hey lily", I only get
Recognized text: hey lily
Confidence score: 0.99
Semantic Count: 1
Greeting tag: NO GREETING TAG VALUE
Person tag: lily
Any help is greatly appreciated!!
No comments:
Post a Comment