SpeechSynthesizer.SelectVoiceByHints 方法

定义

选择具有特定性格的语音。Selects a voice with specific characteristics.

重载

SelectVoiceByHints(VoiceGender)

选择具有特定性别的语音。Selects a voice with a specific gender.

SelectVoiceByHints(VoiceGender, VoiceAge)

选择具有特定性别和年龄的语音。Selects a voice with a specific gender and age.

SelectVoiceByHints(VoiceGender, VoiceAge, Int32)

根据语音的排序位置选择具有特定性别和年龄的语音。Selects a voice with a specific gender and age, based on the position in which the voices are ordered.

SelectVoiceByHints(VoiceGender, VoiceAge, Int32, CultureInfo)

根据语音的排序位置选择具有特定性别、年龄和区域设置的语音。Selects a voice with a specific gender, age, and locale, based on the position in which the voices are ordered.

注解

使用方法和VoiceInfo类获取可选择的已安装文本到语音转换 (TTS) 语音的名称。 GetInstalledVoicesUse the GetInstalledVoices method and VoiceInfo class to obtain the names of installed text-to-speech (TTS) voices that you can select. SpeechSynthesizer对象选择与指定特性匹配的第一个已安装语音。The SpeechSynthesizer object selects the first installed voice that matches the specified characteristics.

当应用程序调用GetInstalledVoices时, 该方法会验证它在注册表中找到的每个声音是否满足某些最小标准。When an application calls GetInstalledVoices, the method verifies that each of the voices it finds in the registry meets certain minimum criteria. 对于验证失败的任何语音, GetInstalledVoices将其Enabled属性设置False为。For any voice that fails verification, GetInstalledVoices sets its Enabled property to False. 应用程序无法选择其Enabled属性为False的声音。An application cannot select a voice whose Enabled property is False. 通常, 应用程序不会设置语音的Enabled属性。Typically, applications will not set a voice's Enabled property.

若要按名称选择语音, 请使用SelectVoice方法To select a voice by name, use the SelectVoice method

SelectVoiceByHints(VoiceGender)

选择具有特定性别的语音。Selects a voice with a specific gender.

public:
 void SelectVoiceByHints(System::Speech::Synthesis::VoiceGender gender);
public void SelectVoiceByHints (System.Speech.Synthesis.VoiceGender gender);
member this.SelectVoiceByHints : System.Speech.Synthesis.VoiceGender -> unit
Public Sub SelectVoiceByHints (gender As VoiceGender)

参数

gender
VoiceGender

选择语音的性别。The gender of the voice to select.

注解

使用方法和VoiceInfo类获取可选择的已安装文本到语音转换 (TTS) 语音的名称。 GetInstalledVoicesUse the GetInstalledVoices method and VoiceInfo class to obtain the names of installed text-to-speech (TTS) voices that you can select. 对象选择其Gender属性与gender参数匹配的第一个已安装语音。 SpeechSynthesizerThe SpeechSynthesizer object selects the first installed voice whose Gender property matches the gender parameter.

当应用程序调用GetInstalledVoices时, 该方法会验证它在注册表中找到的每个声音是否满足某些最小标准。When an application calls GetInstalledVoices, the method verifies that each of the voices it finds in the registry meets certain minimum criteria. 对于验证失败的任何语音, GetInstalledVoices将其Enabled属性设置False为。For any voice that fails verification, GetInstalledVoices sets its Enabled property to False. 应用程序无法选择其Enabled属性为False的声音。An application cannot select a voice whose Enabled property is False. 通常, 应用程序不会设置语音的Enabled属性。Typically, applications will not set a voice's Enabled property.

若要根据其他特征选择语音, 请参阅其他SelectVoiceByHints方法。To select a voice based on other characteristics, see the other SelectVoiceByHints methods.

若要按名称选择语音, 请使用SelectVoice方法。To select a voice by name, use the SelectVoice method.

另请参阅

SelectVoiceByHints(VoiceGender, VoiceAge)

选择具有特定性别和年龄的语音。Selects a voice with a specific gender and age.

public:
 void SelectVoiceByHints(System::Speech::Synthesis::VoiceGender gender, System::Speech::Synthesis::VoiceAge age);
public void SelectVoiceByHints (System.Speech.Synthesis.VoiceGender gender, System.Speech.Synthesis.VoiceAge age);
member this.SelectVoiceByHints : System.Speech.Synthesis.VoiceGender * System.Speech.Synthesis.VoiceAge -> unit
Public Sub SelectVoiceByHints (gender As VoiceGender, age As VoiceAge)

参数

gender
VoiceGender

选择语音的性别。The gender of the voice to select.

age
VoiceAge

要选择该的语音的年龄。The age of the voice to select.

注解

使用方法和VoiceInfo类获取可选择的已安装文本到语音转换 (TTS) 语音的名称。 GetInstalledVoicesUse the GetInstalledVoices method and VoiceInfo class to obtain the names of installed text-to-speech (TTS) voices that you can select. Age Gender age gender对象选择第一个安装的语音, 其和属性与和参数匹配。 SpeechSynthesizerThe SpeechSynthesizer object selects the first installed voice whose Gender and Age properties match the gender and age parameters.

当应用程序调用GetInstalledVoices时, 该方法会验证它在注册表中找到的每个声音是否满足某些最小标准。When an application calls GetInstalledVoices, the method verifies that each of the voices it finds in the registry meets certain minimum criteria. 对于验证失败的任何语音, GetInstalledVoices将其Enabled属性设置False为。For any voice that fails verification, GetInstalledVoices sets its Enabled property to False. 应用程序无法选择其Enabled属性为False的声音。An application cannot select a voice whose Enabled property is False. 通常, 应用程序不会设置语音的Enabled属性。Typically, applications will not set a voice's Enabled property.

若要根据其他特征选择语音, 请参阅其他SelectVoiceByHints方法。To select a voice based on other characteristics, see the other SelectVoiceByHints methods.

若要按名称选择语音, 请使用SelectVoice方法。To select a voice by name, use the SelectVoice method.

另请参阅

SelectVoiceByHints(VoiceGender, VoiceAge, Int32)

根据语音的排序位置选择具有特定性别和年龄的语音。Selects a voice with a specific gender and age, based on the position in which the voices are ordered.

public:
 void SelectVoiceByHints(System::Speech::Synthesis::VoiceGender gender, System::Speech::Synthesis::VoiceAge age, int voiceAlternate);
public void SelectVoiceByHints (System.Speech.Synthesis.VoiceGender gender, System.Speech.Synthesis.VoiceAge age, int voiceAlternate);
member this.SelectVoiceByHints : System.Speech.Synthesis.VoiceGender * System.Speech.Synthesis.VoiceAge * int -> unit
Public Sub SelectVoiceByHints (gender As VoiceGender, age As VoiceAge, voiceAlternate As Integer)

参数

gender
VoiceGender

选择语音的性别。The gender of the voice to select.

age
VoiceAge

要选择该的语音的年龄。The age of the voice to select.

voiceAlternate
Int32

要选择该语音的位置。The position of the voice to select.

注解

使用方法和VoiceInfo类获取可选择的已安装文本到语音转换 (TTS) 语音的名称。 GetInstalledVoicesUse the GetInstalledVoices method and VoiceInfo class to obtain the names of installed text-to-speech (TTS) voices that you can select. 对象SpeechSynthesizer将查找其GenderAge属性与genderage参数匹配的已安装语音。The SpeechSynthesizer object finds installed voices whose Gender and Age properties match the gender and age parameters. 计算所找到的匹配项的数目, 并在计数voiceAlternate等于参数时返回声音。 SpeechSynthesizerThe SpeechSynthesizer counts the matches it finds, and returns the voice when the count equals the voiceAlternate parameter.

当应用程序调用GetInstalledVoices时, 该方法会验证它在注册表中找到的每个声音是否满足某些最小标准。When an application calls GetInstalledVoices, the method verifies that each of the voices it finds in the registry meets certain minimum criteria. 对于验证失败的任何语音, GetInstalledVoices将其Enabled属性设置False为。For any voice that fails verification, GetInstalledVoices sets its Enabled property to False. 应用程序无法选择其Enabled属性为False的声音。An application cannot select a voice whose Enabled property is False. 通常, 应用程序不会设置语音的Enabled属性。Typically, applications will not set a voice's Enabled property.

若要根据其他特征选择语音, 请参阅其他SelectVoiceByHints重载。To select a voice based on other characteristics, see the other SelectVoiceByHints overloads.

若要按名称选择语音, 请使用SelectVoice方法。To select a voice by name, use the SelectVoice method.

另请参阅

SelectVoiceByHints(VoiceGender, VoiceAge, Int32, CultureInfo)

根据语音的排序位置选择具有特定性别、年龄和区域设置的语音。Selects a voice with a specific gender, age, and locale, based on the position in which the voices are ordered.

public:
 void SelectVoiceByHints(System::Speech::Synthesis::VoiceGender gender, System::Speech::Synthesis::VoiceAge age, int voiceAlternate, System::Globalization::CultureInfo ^ culture);
public void SelectVoiceByHints (System.Speech.Synthesis.VoiceGender gender, System.Speech.Synthesis.VoiceAge age, int voiceAlternate, System.Globalization.CultureInfo culture);
member this.SelectVoiceByHints : System.Speech.Synthesis.VoiceGender * System.Speech.Synthesis.VoiceAge * int * System.Globalization.CultureInfo -> unit
Public Sub SelectVoiceByHints (gender As VoiceGender, age As VoiceAge, voiceAlternate As Integer, culture As CultureInfo)

参数

gender
VoiceGender

选择语音的性别。The gender of the voice to select.

age
VoiceAge

要选择该的语音的年龄。The age of the voice to select.

voiceAlternate
Int32

要选择该语音的位置。The position of the voice to select.

culture
CultureInfo

要选择该的语音的区域设置。The locale of the voice to select.

注解

Gender对象查找Age其、和属性与genderculture和参数age匹配的声音。 Culture SpeechSynthesizerThe SpeechSynthesizer object finds voices whose Gender, Age, and Culture properties match the gender, age, and culture parameters. 计算所找到的匹配项的数目, 并在计数voiceAlternate等于参数时返回声音。 SpeechSynthesizerThe SpeechSynthesizer counts the matches it finds, and returns the voice when the count equals the voiceAlternate parameter.

Microsoft Windows 和 Speech API 接受所有有效的语言-国家/地区代码。Microsoft Windows and the System.Speech API accept all valid language-country codes. 若要使用culture参数中指定的语言执行文本到语音转换, 必须安装支持该语言-国家/地区代码的语音合成引擎。To perform text-to-speech using the language specified in the culture parameter, a speech synthesis engine that supports that language-country code must be installed. Microsoft Windows 7 随附的语音合成引擎使用以下语言-国家/地区代码:The speech synthesis engines that shipped with Microsoft Windows 7 work with the following language-country codes:

  • en-us。en-US. 英语 (美国)English (United States)

  • zh-chs-CN。zh-CN. 中文 (中国)Chinese (China)

  • zh-chs-幼圆。zh-TW. 中文 (中国台湾)Chinese (Taiwan)

还允许使用两个字母的语言代码, 例如 "en"。Two-letter language codes such as "en" are also permitted.

当应用程序调用GetInstalledVoices时, 该方法会验证它在注册表中找到的每个声音是否满足某些最小标准。When an application calls GetInstalledVoices, the method verifies that each of the voices it finds in the registry meets certain minimum criteria. 对于验证失败的任何语音, GetInstalledVoices将其Enabled属性设置False为。For any voice that fails verification, GetInstalledVoices sets its Enabled property to False. 应用程序无法选择其Enabled属性为False的声音。An application cannot select a voice whose Enabled property is False. 通常, 应用程序不会设置语音的Enabled属性。Typically, applications will not set a voice's Enabled property.

若要根据其他特征选择语音, 请参阅其他SelectVoiceByHints重载。To select a voice based on other characteristics, see the other SelectVoiceByHints overloads.

若要按名称选择语音, 请使用SelectVoice方法。To select a voice by name, use the SelectVoice method.

另请参阅

适用于