Share via


Phone Number Rules for English (United States)

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The grammar library provides four rules for recognizing U.S. phone numbers.

The PhoneNumber_US rule recognizes a local telephone number that is optionally preceded by the toll call prefix 1, an area code, or both 1 and an area code. The PhoneNumber_US rule is composed of the PhoneNumber_US_AreaCode followed by the PhoneNumber_US_LocalNumber rule.

The PhoneNumber_US_AreaCode rule recognizes a three-digit number. The PhoneNumber_US_LocalNumber rule recognizes a seven-digit number.

The PhoneNumber_US_with_Extension rule recognizes the same expressions that the PhoneNumber_US rule recognizes, followed optionally by the word extension, plus a one-digit to four-digit sequence. When the user expresses a phrase containing an extension, the SML value returned by the engine consists of the digits for the phone number, followed by an x, followed by the digits for the extension.

All rules support common digit groupings. For example, the PhoneNumber_US_LocalNumber rule can recognize the expression of the seven-digit phone number 123 1234 as the following series of three single digits followed by two two-digit groupings: one two three twelve thirteen.

All English (United States) phone number rules return a value of type string.

Rules

PhoneNumber_US_AreaCode

PhoneNumber_US_LocalNumber

PhoneNumber_US

PhoneNumber_US_with_Extension

Usage

<ruleref uri="Library.grxml#PhoneNumber_US_AreaCode" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#PhoneNumber_US_LocalNumber" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#PhoneNumber_US" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#PhoneNumber_US_with_Extension" type="application/srgs+xml"/>

The grammar can be used as follows (using the PhoneNumber_US rule as an example).

<grammar xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"
         xml:lang="en-US" tag-format="semantics-ms/1.0" version="1.0" mode="voice"
         root="Rule1" xmlns="http://www.w3.org/2001/06/grammar">
    <rule id="Rule1" scope="public">
        <ruleref uri="Library.grxml#PhoneNumber_US" type="application/srgs+xml"/>
    <tag>$ = $$</tag>
    </rule>
</grammar>

JScript Objects

$PhoneNumber_US_AreaCode._value: string [3 characters]
$PhoneNumber_US_LocalNumber._value: string [7 characters]
$PhoneNumber_US._value: string [7, 10, or 11 characters]
$PhoneNumber_US.AreaCode._value: string [3 characters]
$PhoneNumber_US.LocalNumber._value: string [7 characters]
$PhoneNumber_US_with_Extension._value: string [7, 10, or 11 characters, plus "x" followed by 1...4 characters]
$PhoneNumber_US_with_Extension.AreaCode._value: string [3 characters]
$PhoneNumber_US_with_Extension.LocalNumber._value.: string [7 characters]
$PhoneNumber_US_with_Extension.Extension._value: string [1...4 characters]

Example: PhoneNumber_US_AreaCode

Example 1

User says: "four two five."

SML returned by the recognition engine.

<SML text="four two five" utteranceConfidence="1.000" confidence="1.000">425</SML>

Example: PhoneNumber_US_LocalNumber

Example 1

User says: "five five five two three four five."

SML returned by the recognition engine.

<SML text="five five five two three four five" utteranceConfidence="1.000" confidence="1.000">5552345</SML>

Example 2

User says: "two three four fifteen sixteen."

SML returned by the recognition engine.

<SML text="two three four fifteen sixteen" utteranceConfidence="1.000" confidence="1.000">2341516</SML>

Example: PhoneNumber_US

Example 1

User says: "one five five five four three two one."

SML returned by the recognition engine.

<SML text="one five five five four three two one" utteranceConfidence="1.000" confidence="1.000">

15554321

<LocalNumber confidence="1.000">5554321</LocalNumber>

</SML>

Example 2

User says: "one four two five five five five ten ten."

SML returned by the recognition engine.

<SML text="one four two five five five five ten ten" utteranceConfidence="1.000" confidence="1.000">

14255551010

<AreaCode confidence="1.000">425 </AreaCode>

<LocalNumber confidence="1.000">5551010</LocalNumber>

</SML>

Example: PhoneNumber_US_with_Extension

Example 1

User says: "one four two five five fifty five twelve thirty four extension ten ten."

SML returned by the recognition engine.

<SML text="one four two five five fifty five twelve thirty four extension ten ten" utteranceConfidence="1.000" confidence="1.000">

14255551234x1010

<AreaCode confidence="1.000">425</AreaCode>

<LocalNumber confidence="1.000">5551234</LocalNumber>

<Extension confidence="1.000">1010</Extension>

</SML>