Speech SDK 5.1 Grammar Problem


I am new to speech technologies and trying to develop a calculator application with speech recognition with c#.
As for now i encountered two major problems which i couldn't overcome.

The first one is while writing an xml grammar for the speech api i couldn't add recursive context free grammar rules to the grammar. Every time i added such a rule and compiled the grammar file i received compilation error because of circular referencing. Is there a way to implement recursive CFG grammars.The recursive part of my grammar is like :

<RULE ID = "OperationExpr">
      <RULEREF REFID="Operation"/>
      <RULEREF REFID="Operators"/>
      <RULEREF REFID="Operation"/>
<RULE ID = "Operation">
            <L PROPID="Operation_Value">
                  <RULEREF REFID="OperationExpr"/>
                  <RULEREF REFID="NUMBER"/>

The second problem is about accessing values of recognized phrases.
For example in the code when defining two child phrases like

<P DISP="1">one</P>
<P DISP="2">two</P>

is there a way to make the grammar such that i can add the return values of these two phrases and make the speech engine return me "3" as recognized phrase. I need to implement this function in the xml grammar not as a program functionality in c#

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't think you can have the kind of recursion that you're looking for.  Instead, I would define opperations like +, -, /, * and define numbers but don't include operationExpr in operation.  Then, define OperationExpr to contain operator-number sequences of arbitrary length.

For the return values, can't you just change the disp value?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozencozturkAuthor Commented:
>> Then, define OperationExpr to contain operator-number sequences of arbitrary length.
     Can you explain how I can do this for arbitrary length sequences without recursion?

>>For the return values, can't you just change the disp value?
    Basically what I am trying to do is to develop a grammar for recognizing numbers. (I couldn't find some structure in SAPI that recognizes numbers. If you know such a structure, I would be glad to know;) ) However when recognizing some numbers there are problems

For example, consider:

one thousand and one
one thousand and eleven
one thousand one hundred and eleven

and I have a grammar like:  

<rule name = "num100-1000">
     <ruleref refid = "digit"/>
     <p disp = ...>thousand</p>
     <ruleref refid = "num100">

if I write "" for disp, the grammar returns 11 for 1001 and 111 for 1011. Thus I need to have some value associated with childs and should use those values from parent nodes.

However I have found an alternative way (filling '0's at the beginning of a number ie: represent 1 as 0001) and if I can create sth like:

<rule name = "newRule">
      <p disp = "some string"><p>
      </ruleref refid = "existingrule">

my grammar will work. (Basically what I am trying to do here is to add some new string at the beginning of an existing rule. ie: 978 becomes 000978) However since SAPI does not allow <p disp = "some string"><p>, I cannot create my grammar this way either. It would be great if anyone knows how to do this in sapi.  




It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.