Partilhar via


InlineGrammar Property

  Microsoft Speech Technologies Homepage

Gets or sets the text of the Grammar that is specified inline. Read/write.

Usage

ASP.NET markup: <speech:Grammar InlineGrammar="..." />
Get value: String = Grammar.InlineGrammar;
Set value: Grammar.InlineGrammar = String;
Data type: String
Required: No

Remarks

The grammar data in the InlineGrammar property must be HTML-encoded. Speech Grammar Editor, installed with the Speech Application SDK, performs HTML-encoding for authors automatically. Authors can also use the ASP.NET System.Web.HttpUtility.HtmlEncode method to perform this operation programmatically.

When creating a Grammar, it is the author's responsibility to specify a single grammar resource, either inline or referenced. Behavior of a Grammar that specifies more than one, or less than one grammar resource, is undefined.

The InlineGrammar property does not support the use of CDATA sections within inline grammars. At run time, the speech recognition engine renders the value of the InlineGrammar property as a CDATA section. If an inline grammar already contains a CDATA section, an error will occur.

Example

The following example uses this simple speech grammar:

<grammar root="DOMINTL" version="1.0" xmlns="http://www.w3.org/2001/06/grammar"
 lang="en-US" tag-format="semantics-ms/1.0">
  <rule id="DOMINTL" scope="public">
    <item>
      <one-of>
        <item>domestic</item> 
        <item>international</item> 
      </one-of>
    </item>
  </rule>
</grammar>

This code example illustrates the preceding grammar used in the InlineGrammar property.

<form id="Form1" method="post" runat="server">
  ...
  <Speech:SemanticMap id="TheSemanticMap" runat="server">
    <speech:semanticitem id="siDomIntl" runat="server" targetattribute="value" targetelement="tbDomIntl" ></speech:semanticitem>
  </Speech:SemanticMap>
  ...
  <speech:QA id="qaDomIntl" runat="server">
    <Prompt InlinePrompt="Would you like to book a domestic or an international flight?">
    </Prompt>
    <Answers>
      <speech:Answer SemanticItem="siDomIntl" XPathTrigger="./DOMINTL"></speech:Answer>
    </Answers>
    <Reco InitialTimeout="3000" BabbleTimeout="10000" EndSilence="1000" MaxTimeout="30000" ID="Reco2">
      <Grammars>

        <speech:Grammar InlineGrammar="&lt;grammar root='DOMINTL' version='1.0' xmlns='http://www.w3.org/2001/06/grammar'
         lang='en-US' tag-format='semantics-ms/1.0'&gt; 
          &lt;rule id='DOMINTL' scope='public'&gt;
          &lt;item&gt;
          &lt;one-of&gt;
          &lt;item&gt;domestic&lt;/item&gt;
          &lt;item&gt;international&lt;/item&gt;
          &lt;/one-of&gt;
          &lt;/item&gt;
          &lt;/rule&gt;
          &lt;/grammar&gt;">
        </speech:grammar>

      </Grammars>
    </Reco>
  </speech:QA>
  ...
</form>

See Also

Grammar Class | Grammar Constructor | Grammar Members | Grammar Properties | Grammar Methods | Grammar Events | Grammar Remarks