Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:27:45+00:00 2026-06-11T17:27:45+00:00

I am trying to get a certain grammar working in my speech recognition. My

  • 0

I am trying to get a certain grammar working in my speech recognition.

My grammar definition is as follows:

<rule id="showFlight">
<example>Show me Alaska Airlines flight number 2117</example>
<example>Where is US Airways flight 45</example>
<item>
  <one-of>
    <item>show me</item>
    <item>where is</item>
  </one-of>
</item>
<item>
  <ruleref uri="#airline" />
  <tag>out.Carrier = rules.airline;</tag>
</item>
flight
<item repeat="0-1">number</item>
<item repeat="1-">
  <ruleref uri="#digit" />
  <tag>out.Number = rules.digit;</tag>
</item>
</rule>

My problem resides with the very last — the digits. I define that 1-or-more digits can exist in the grammer, and this works. But when I go to extract the value in my OnSpeechRecognized callback, I only get the last digit spoken.

    public override bool OnSpeechRecognized(object sender, Microsoft.Speech.Recognition.SpeechRecognizedEventArgs e)
    {
        String output = String.Format("Recognition Summary:\n" +
            "  Recognized phrase: {0}\n" +
            "  Confidence score {1}\n" +
            "  Grammar used: {2}\n",
            e.Result.Text, e.Result.Confidence, e.Result.Grammar.Name);
        Console.WriteLine(output);

        // Display the semantic values in the recognition result.
        Console.WriteLine("  Semantic results:");
        //Console.WriteLine(e.Result.Semantics["Flight"].Value);

        foreach (KeyValuePair<String, SemanticValue> child in e.Result.Semantics["ShowFlight"])
        {
            Console.WriteLine("    {0} is {1}",
              child.Key, child.Value.Value ?? "null");
        }
        Console.WriteLine();

...

Or, more directly:

e.Result.Semantics["ShowFlight"]["Number"].Value.ToString()

If I say “two-one-one-seven”, the only digit in [“Number”] is 7. Likewise, if I say “four-five” the only digit I get returned is 5.

How can I extract all the numbers that are spoken that are part of the flight number?

Also, is there a secret internal grammar I can load that will allow me to recognize both “four-five” and “fortyfive” easily?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:27:46+00:00Added an answer on June 11, 2026 at 5:27 pm

    You can simply replace the last ‘item’ element with the following:

      <tag>out.Number = &quot;&quot;</tag>
      <item repeat="1-">
        <ruleref uri="#digit" />
        <tag>out.Number += rules.digit;</tag>
      </item>
    

    This will concatenate all the recognized digits to out.Number.

    Regarding the second question, there is no such “secret internal grammar”, unfortunately. You will have to code it yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get col1 values for certain multiple col2 values. For example: I
I'm trying to get a simple example working with GCDAsyncSocket, and am discovering that
Ok im trying to get a MVC example page working and basically query where
I'm trying to get a certain data from mysql with fetchAll. I currently have
I'm trying to get a certain cookie in a java client by creating a
I've been trying to get a certain Google API to work for two days
Just trying to get diff to work better for certain kinds of documents. With
I'm trying to get some data from a certain web-based api using the libcurl
I am trying to get my posts tagged with a certain tag to render.
I'm trying to get all the input elements from a certain form from jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.