InstalledVoice InstalledVoice InstalledVoice InstalledVoice Class

定義

包含安裝在 Windows 中語音合成聲音的相關資訊。Contains information about a speech synthesis voice installed in Windows.

public ref class InstalledVoice
public class InstalledVoice
type InstalledVoice = class
Public Class InstalledVoice
繼承
InstalledVoiceInstalledVoiceInstalledVoiceInstalledVoice

範例

下列範例是主控台應用程式的一部分, 它會初始化SpeechSynthesizer物件, 並將已安裝的語音 (適用于語音合成的引擎) 清單輸出到主控台, 並示範每個語音可用的資訊。The following example is part of a console application that initializes a SpeechSynthesizer object and outputs to the console a list of the installed voices (engines for speech synthesis) and demonstrates the information that is available for each voice.

using System;  
using System.Speech.Synthesis;  
using System.Speech.AudioFormat;  
  
namespace SampleSynthesis  
{  
  class Program  
  {  
    static void Main(string[] args)  
    {  
  
      // Initialize a new instance of the SpeechSynthesizer.  
      using (SpeechSynthesizer synth = new SpeechSynthesizer())  
      {  
  
        // Output information about all of the installed voices.   
        Console.WriteLine("Installed voices -");  
        foreach (InstalledVoice voice in synth.GetInstalledVoices())  
        {  
          VoiceInfo info = voice.VoiceInfo;  
          string AudioFormats = "";  
          foreach (SpeechAudioFormatInfo fmt in info.SupportedAudioFormats)  
          {  
            AudioFormats += String.Format("{0}\n",  
            fmt.EncodingFormat.ToString());  
          }  
  
          Console.WriteLine(" Name:          " + info.Name);  
          Console.WriteLine(" Culture:       " + info.Culture);  
          Console.WriteLine(" Age:           " + info.Age);  
          Console.WriteLine(" Gender:        " + info.Gender);  
          Console.WriteLine(" Description:   " + info.Description);  
          Console.WriteLine(" ID:            " + info.Id);  
          Console.WriteLine(" Enabled:       " + voice.Enabled);  
          if (info.SupportedAudioFormats.Count != 0)  
          {  
            Console.WriteLine( " Audio formats: " + AudioFormats);  
          }  
          else  
          {  
            Console.WriteLine(" No supported audio formats found");  
          }  
  
          string AdditionalInfo = "";  
          foreach (string key in info.AdditionalInfo.Keys)  
          {  
            AdditionalInfo += String.Format("  {0}: {1}\n", key, info.AdditionalInfo[key]);  
          }  
  
          Console.WriteLine(" Additional Info - " + AdditionalInfo);  
          Console.WriteLine();  
        }  
      }  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  
  

備註

使用此類別來取得已安裝之語音的相關資訊, 包括其文化特性、名稱、性別、年齡, 以及是否已啟用。Use this class to get information about an installed voice, including its culture, name, gender, age, and whether it is enabled.

若要使用Culture屬性中指定的語言來執行文字轉換語音, 必須安裝支援該語言國家/地區代碼的語音合成引擎。To perform text-to-speech using the language specified in the Culture property, 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-CN。zh-CN. 中文 (中國)Chinese (China)

  • zh-幼圓。zh-TW. 中文 (臺灣)Chinese (Taiwan)

也允許使用兩個字母的語言代碼, 例如 "en"。Two-letter language codes such as "en" are also permitted.

屬性

Enabled Enabled Enabled Enabled

取得或設定語音是否可用來產生語音。Gets or sets whether a voice can be used to generate speech.

VoiceInfo VoiceInfo VoiceInfo VoiceInfo

取得有關語音的資訊,例如文化特性、名稱、性別和年齡。Gets information about a voice, such as culture, name, gender, and age.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否為 InstalledVoice 執行個體並等於目前 InstalledVoice 執行個體。Determines if a given object is an instance of InstalledVoice and equal to the current instance of InstalledVoice.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

提供 InstalledVoice 物件的雜湊碼。Provides a hash code for an InstalledVoice object.

GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於