"say-as" Element

Description

The <say-as> element enables users to annotate text fragments to enforce a particular interpretation. It disables most default normalization rules and should be used sparingly — only when defaults fail or to explicitly force a specific pronunciation.

The interpret-as attribute indicates the text construct type and the level of rendering detail.

Syntax

<say-as
  interpret-as = "construct_type"
  format = "string"
  detail = "string">
  text
</say-as>

Attributes

AttributeDescription
interpret-asType of text construct. Mandatory field.
formatDescription of the text type. Optional field.
detailText detail information. Optional field.

Parent

<audio>, <emphasis>, <p>, <prosody>, <s>, <speak>, <voice>

Children

#TEXT, #CDATA-SECTION

Limitations/Restrictions

The maximum text length is 512 bytes. Text exceeding this limit is truncated.

User lexicons do not apply within <say-as> elements.


Supported interpret-as Values

date

Format options: mdy, dmy, ymd, md, dm, ym, my, d, m, y

Text: Digits and delimiters (/, ., -). English defaults to month-day-year; Spanish defaults to day-month-year when unspecified.

Examples:

<say-as interpret-as="date" format="mdy">01/02/2007</say-as>
<say-as interpret-as="date" format="dmy">01/02/2007</say-as>
<say-as interpret-as="date" format="ymd">2007/01/02</say-as>

time

Format options: hms24, hms12

Text: Digits, time delimiters (:, .), modifiers (AM, A.M., PM, P.M., etc.). With hms12, hours are restricted to 0–12; with hms24, hours are restricted to 0–23.

Examples:

<say-as interpret-as="time" format="hms12">09:21:15</say-as>
<say-as interpret-as="time">2'10"</say-as>
<say-as interpret-as="time">1234am</say-as>

telephone

Format: Country code number

Text: + symbol, digits, delimiters ((), -, ., /), symbols (*, #), letters (excluding Q and Z).

Examples:

<say-as interpret-as="telephone" format="39">+39(011)777-7777</say-as>
<say-as interpret-as="telephone">+1-800-555-234 ex. 23</say-as>
<say-as interpret-as="telephone">*53#</say-as>

characters

Format: characters

Detail: Character counts per group (space-separated); the sum must equal the total text length.

Text: English characters, numbers, and 31 symbols (!, #, $, %, &, ', (, ), *, +, comma, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, ~).

Examples:

<say-as interpret-as="characters" format="characters" detail="3 1 2">1a3BZ7</say-as>
<say-as interpret-as="characters">speed</say-as>

cardinal

Text: Symbols (+, -), numbers, format/detail symbols. Supports Roman numerals. The format and detail attributes are ignored. Numbers with 16+ digits starting with 0 are read digit-by-digit.

Examples:

<say-as interpret-as="cardinal" format=".">123.456</say-as>
<say-as interpret-as="cardinal">123</say-as>
<say-as interpret-as="cardinal">CLI</say-as>

ordinal

Text: Numbers only. Supports Roman numerals. Numbers with 16+ digits starting with 0 are read digit-by-digit.

Examples:

<say-as interpret-as="ordinal">23</say-as>
<say-as interpret-as="ordinal">VI</say-as>

fraction

Text syntax:

  • Fraction: [+|-|±] cardinal "/" cardinal
  • Mixed number (non-negative): [+|±] cardinal "+" cardinal "/" cardinal
  • Mixed number (negative): "-" cardinal "-" cardinal "/" cardinal

Examples:

<say-as interpret-as="fraction">2/9</say-as>
<say-as interpret-as="fraction">3+1/2</say-as>
<say-as interpret-as="fraction">-2-3/8</say-as>

measure / unit

Text syntax:

  • Unit: symbol [2|3|4] ["/unit"]
  • Measurement: number unit
  • Adjective: number "-" unit

Supports metric, imperial, and other standard unit symbols (N, kJ, mi, sqft, MiB, ly, tbsp, °F, psi, etc.). Generally case-sensitive; unambiguous matches are case-insensitive. SI/binary prefixes are supported. Appending 's' forces plural. Power suffixes (2, 3) indicate squared/cubed (e.g. m2 = square meters).

Examples:

<say-as interpret-as="unit">2nmi</say-as>
<say-as interpret-as="unit">1+1/2tsp</say-as>
<say-as interpret-as="unit">5m/s2</say-as>
<say-as interpret-as="unit">2,100prm</say-as>
<say-as interpret-as="unit">2.7µF</say-as>

address

Format option: us-state (forces two-letter US state abbreviation expansion outside ZIP code context).

Text: Street addresses or parts thereof. US state abbreviations expand only when followed by ZIP codes unless format="us-state" is specified.

Examples:

<say-as interpret-as="address">320 W Mt Willson Ct</say-as>
<say-as interpret-as="address">rm. 103</say-as>
<say-as interpret-as="address">Ft Worth, TX 12345</say-as>
<say-as interpret-as="address" format="us-state">CO</say-as>

spell-out / spell

Text: Reads individual characters one at a time.

Examples:

<say-as interpret-as="spell-out">Hello</say-as>
<say-as interpret-as="spell-out">speed</say-as>
<say-as interpret-as="spell-out">1234</say-as>
<say-as interpret-as="spell-out">*#!</say-as>

vxml:boolean

Text: "true" or "false" only.

Examples:

<say-as interpret-as="vxml:boolean">true</say-as>
<say-as interpret-as="vxml:boolean">false</say-as>

vxml:date

Text: yyyyMMdd pattern; '?' is allowed as an undefined placeholder.

Restriction: yyyy (four digits), MM (two-digit month), dd (two-digit day).

Examples:

<say-as interpret-as="vxml:date">20070102</say-as>
<say-as interpret-as="vxml:date">????0102</say-as>

vxml:digits

Text: Numbers only.

Example:

<say-as interpret-as="vxml:digits">123</say-as>

vxml:currency

Text: UUUmm.nn pattern (currency symbol, numbers, decimal points). Numbers with 16+ digits starting with 0 are read digit-by-digit.

Example:

<say-as interpret-as="vxml:currency">USD30.101</say-as>

vxml:number

Text: Signs (+, -), numbers, decimal points. Numbers with 16+ digits starting with 0 are read digit-by-digit.

Example:

<say-as interpret-as="vxml:number">123.45</say-as>

vxml:phone

Text: Numbers and 'x' (extension abbreviation) only.

Example:

<say-as interpret-as="vxml:phone">8005551234x789</say-as>

vxml:time

Text: HHMMX pattern. HH (two-digit hour), MM (two-digit minutes), X (a=AM, p=PM, h=24-hour, ?=ambiguous). Only 'h' allows 00–23 hours.

Examples:

<say-as interpret-as="vxml:time">0600a</say-as>
<say-as interpret-as="vxml:time">0600p</say-as>
<say-as interpret-as="vxml:time">0600?</say-as>
<say-as interpret-as="vxml:time">2310h</say-as>

Complete Example

<?xml version="1.0"?>
<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.w3.org/2001/10/synthesis
               http://www.w3.org/TR/speech-synthesis/synthesis.xsd"
     xml:lang="en-US">

  <say-as interpret-as="characters" format="characters">VoiceXML</say-as>
  You still owe me <say-as interpret-as="vxml:currency">USD30.10</say-as>
  Today's date is
  <say-as interpret-as="date" format="ymd">2006/01/01</say-as>
  Please push the <say-as interpret-as="vxml:boolean">true</say-as> button.
  I will get there at
  <say-as interpret-as="time" format="hms24">07:30:30.0PM</say-as>
</speak>

TTS Special Characters

Force letter "a" pronunciation: _a is pronounced as "ey" to distinguish from the article "a".

Force rising intonation: ?^ (question mark + caret) forces rising intonation for wh-questions. Example: "How are you?^"

Force falling intonation: ?_ (question mark + underscore) forces falling intonation for yes/no questions. Example: "Are you all right?_"


Was this article helpful?