VoiceInfo 類別

定義

表示已安裝的語音合成引擎。

public ref class VoiceInfo
[System.Serializable]
public class VoiceInfo
[<System.Serializable>]
type VoiceInfo = class
Public Class VoiceInfo
繼承
VoiceInfo
屬性

範例

下列範例是主控台應用程式的一部分,此應用程式會初始化 SpeechSynthesizer 物件並輸出至主控台,以取得語音合成的已安裝語音 (引擎清單) 並示範每個語音可用的資訊。

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();  
    }  
  }  
}  

備註

語音是一種已安裝的語音合成引擎,也稱為文字轉換語音引擎或 TTS 引擎。 SpeechSynthesizer物件使用語音從文字產生語音。 物件的屬性會 VoiceInfo 識別語音並描述其特性。 語音的最大定義特性是它 Culture ,它會定義語音可以說話的單一語言。

Voice屬性 VoiceInfo 會傳回物件,其中包含目前所使用之語音的相關資訊 SpeechSynthesizer 。 您也可以使用 VoiceInfo 物件來取得系統上所安裝之任何聲音的相關資訊,方法是由 GetInstalledVoices() 方法傳回。 如需相關資訊,請參閱 InstalledVoice

屬性

AdditionalInfo

取得語音的其他相關資訊。

Age

取得語音的年齡。

Culture

取得語音的文化特性。

Description

取得語音的描述。

Gender

取得語音的性別。

Id

取得語音的 ID。

Name

取得語音的名稱。

SupportedAudioFormats

取得語音支援的音訊格式集合。

方法

Equals(Object)

使用指定的VoiceInfo物件來比較語音的欄位,以判斷它們是否包含相同的值。

GetHashCode()

提供 VoiceInfo 物件的雜湊碼。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱