共用方式為


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

SpeechSynthesizer.Voice Property

Gets information about the current voice of the SpeechSynthesizer object.

Namespace:  Microsoft.Speech.Synthesis
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

'Declaration
Public Property Voice As VoiceInfo
    Get
    Friend Set
'Usage
Dim instance As SpeechSynthesizer
Dim value As VoiceInfo

value = instance.Voice
public VoiceInfo Voice { get; internal set; }

Property Value

Type: Microsoft.Speech.Synthesis.VoiceInfo
Returns information about the current voice of the SpeechSynthesizer object.

Remarks

A voice is an installed Runtime Language for speech synthesis (TTS, or text-to-speech). The Microsoft Speech Platform Runtime 11 and Microsoft Speech Platform SDK 11 do not include any Runtime Languages for speech synthesis. You must download and install a Runtime Language for each language in which you want to generate synthesized speech. A Runtime Language includes the language model, acoustic model, and other data necessary to provision a speech engine to perform speech synthesis in a particular language. A voice also defines other characteristics, such as age and gender. See InstalledVoice for more information.

When you initialize a new SpeechSynthesizer, it uses the default system voice. To configure the SpeechSynthesizer object to use one of the installed speech synthesis voices, use the SelectVoice or SelectVoiceByHints method. To get information about which voices are installed, use the GetInstalledVoices method and the VoiceInfo class.

Examples

The following example initializes an instance of SpeechSynthesizer and gets information about the current voice.

using System;
using System.IO;
using Microsoft.Speech.Synthesis;
using Microsoft.Speech.AudioFormat;

namespace SampleSynthesis
{
  class Program
  {
    static void Main(string[] args)
    {

      // Initialize a new instance of the SpeechSynthesizer.
      using (SpeechSynthesizer synth = new SpeechSynthesizer())
      {

        // Get information about supported audio formats.
        string AudioFormats = "";
        foreach (SpeechAudioFormatInfo fmt in synth.Voice.SupportedAudioFormats)
        {
          AudioFormats += String.Format("{0}\n",
          fmt.EncodingFormat.ToString());
        }

        // Write information about the voice to the console.
        Console.WriteLine(" Name:          " + synth.Voice.Name);
        Console.WriteLine(" Culture:       " + synth.Voice.Culture);
        Console.WriteLine(" Age:           " + synth.Voice.Age);
        Console.WriteLine(" Gender:        " + synth.Voice.Gender);
        Console.WriteLine(" Description:   " + synth.Voice.Description);
        Console.WriteLine(" ID:            " + synth.Voice.Id);
        if (synth.Voice.SupportedAudioFormats.Count != 0)
        {
          Console.WriteLine(" Audio formats: " + AudioFormats);
        }
        else
        {
          Console.WriteLine(" No supported audio formats found");
        }

        // Get additional information about the voice.
        string AdditionalInfo = "";
        foreach (string key in synth.Voice.AdditionalInfo.Keys)
        {
          AdditionalInfo += String.Format("  {0}: {1}\n",
            key, synth.Voice.AdditionalInfo[key]);
        }

        Console.WriteLine(" Additional Info - " + AdditionalInfo);
        Console.WriteLine();
      }

      Console.WriteLine();
      Console.WriteLine("Press any key to exit...");
      Console.ReadKey();
    }
  }
}

See Also

Reference

SpeechSynthesizer Class

SpeechSynthesizer Members

Microsoft.Speech.Synthesis Namespace