Compartir a través de


voice Element

With the parameters of the voice element, you can change the voice used in speech synthesis and also specify the attributes of the voice such as the language, the gender, and the age of the voice.

Syntax

<voice name"string" gender="string" age="integer" xml:lang="string" variant="integer"> </voice>

Attributes

Attribute

Description

name

Optional. Specifies the name of the installed voice that will speak the contained text.

gender

Optional. Specifies the preferred gender of the voice that will speak the contained text. The allowed values are: male, female, and neutral.

age

Optional. Specifies the preferred age in years of the voice that will speak the contained text. The allowed values are: 10 (child), 15 (teen), 30 (adult), and 65 (senior).

xml:lang

Optional. Specifies the language that the voice must support. The value may contain either a lower-case, two-letter language code, (such as en for English), or may optionally include an upper-case, country/region or other variation in addition to the language code, (such as zh-CN).

variant

Optional. An integer that specifies a preferred voice when more than one voice matches the values specified in any of the xml:lang, gender, or age parameters.

Remarks

Although each of its attributes is individually optional, a voice element must have at least one attribute specified.

For a given language code specified in the xml:lang attribute, a speech synthesis engine that supports that language code must be installed to correctly pronounce words in the specified language.

If the xml:lang attribute specifies only a language code, and not a country/region code, (such as xml:lang="en"), then any installed synthesis engine that expresses support for that generic, region-independent language may produce acceptable pronunciations for words in the specified language.

The voice element may declare a language in its xml:lang attribute other than the language declared in the speak element. The System.Speech.Synthesis namespace supports multiple languages in SSML documents.

Microsoft Windows and the System.Speech API accept all valid language-country codes, but only a limited number of text-to-speech (TTS) engines are provided with Windows 7. The TTS engines that are shipped with Windows 7 work with the following language codes.

  • en-US. English (United States)

  • zh-CN. Chinese (China)

  • zh-TW. Chinese (Taiwan)

Two-letter language codes such as "en" are also permitted.

Example

<?xml version="1.0" encoding="ISO-8859-1"?>
<speak version="1.0"
 xmlns="http://www.w3.org/2001/10/synthesis"
 xml:lang="en-US">

  <voice name="MicrosoftAnna" gender="female" age="30" xml:lang="en-US">
  This is the text that the application will speak.
  </voice>

</speak>