AppendRuleReference Method (String)

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

Appends a grammar definition file to the current sequence of grammar elements.

Namespace:  Microsoft.Speech.Recognition
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

Visual Basic (Declaration)
Public Sub AppendRuleReference ( _
	path As String _
)
Visual Basic (Usage)
Dim instance As GrammarBuilder
Dim path As String

instance.AppendRuleReference(path)
C#
public void AppendRuleReference(
	string path
)

Parameters

path
Type: System..::..String

A String containing the path or Universal Resource Identifier (URI) of the file that describes a speech recognition grammar in a supported format.

Remarks

The URI provided by the path argument may be local or remote. The application must have read access to the location of specified grammar files.

A W3C Speech Recognition Grammar Specification (SRGS) representation can define a root rule. This method appends the grammar, beginning with its root rule, to the current sequence of grammar elements. To append a specific grammar rule, use the AppendRuleReference(String, String) method.

Examples

The following C# example creates a speech recognition grammar that uses the rule named Cities in a local SRGS file, cities.grxml. The content of the cities.grxml file appears below the C# code example.

C# Copy imageCopy Code
private static Grammar CreateCitiesGrammar1()
{
  GrammarBuilder builder = new GrammarBuilder();
  builder.AppendRuleReference("file://c:/temp/cities.grxml");

  Grammar citiesGrammar = new Grammar(builder);
  citiesGrammar.Name = "Cities Grammar 1";
  return citiesGrammar;
}
XML Copy imageCopy Code
<?xml version="1.0" encoding="UTF-16" ?>
<grammar version="1.0" xml:lang="en-US"
         xmlns="http://www.w3.org/2001/06/grammar"
         tag-format="semantics/1.0" root="Main">
  
  <!-- cities.grxml: 
    Defines an SRGS grammar for requesting a flight. This grammar includes
    a Cities rule that lists the cities that can be used for departures
    and destinations. -->
  
  <rule id="Main">
    <item>
      I would like to fly from <ruleref uri="#Cities"/>
      to <ruleref uri="#Cities"/>
    </item>
  </rule>

  <rule id="Cities" scope="public">
    <one-of>
      <item> Seattle </item>
      <item> Los Angeles </item>
      <item> New York </item>
      <item> Miami </item>
    </one-of>
  </rule>
</grammar>

See Also