Partilhar via


lang Attribute

  Microsoft Speech Technologies Homepage

Specifies the language and/or dialect that the speech engine should use.

<listen lang = "langTag" >

Remarks

The value of this attribute follows the definition found in the Internet Engineering Task Force (IETF) RFC1766. The RFC1766 specification allows for a rich suite of languages, although not all are supported by Microsoft Windows. The tags are case insensitive. The language tag is a string composed of at least one part, but optionally more parts. The first, is a two-character designation of the basic language. For example, "en" is for English; "no," Norwegian; "fr," French; "de," German, and so on. The second part is separated by a hyphen and designates the variation or dialect of the language. "en-US" is for American English, "en-cockney" is for Cockney English.

The lang attribute is scoped and, if unspecified, a higher level element in the page may propagate the lang value down to the listen element. If the lang attribute is specified in multiple places, the language ID follows an order of precedence from the lowest scope to the highest scope. For example, the language ID specified within a grammar file is the lowest scope, followed by the lang attribute in a grammar element, followed by an lang attribute in a listen element. For external grammars, it may even be overridden by lang attribute specified within the target grammar. If lang is completely unspecified, a platform-specific value is used.

This attribute is used only when a value is not specified in the lang attribute of the grammar element.

Example

The following code demonstrates the use of the lang attribute.

<salt:listen id="listen1" lang="en-US" EndSilence="10000" onreco="Handleonreco()
onnoreco="Handleonnoreco()" onsilence="Handleonsilence()" onerror="Handleonerror()">
  <salt:grammar name="numbers"> 
    <grammar version="1.0" tag-format="semantics-ms/1.0" lang="en-US" 
    xmlns="http://www.w3.org/2001/06/grammar" root="root">
      <rule id="root">
        <item repeat="0-1">from </item>
        <ruleref uri="#numbers" />
      </rule>
      <rule id="numbers">
        <one-of>
          <item>one</item> 
          <item>two</item> 
          <item>three</item> 
          <item>four</item> 
          <item>five</item>               
        </one-of>
      </rule>
    </grammar>
  </salt:grammar>
</salt:listen>

See Also

listen Element |  grammar Element | lang Attribute (grammar)