SpeechSynthesizer.Voice Eigenschap

Definitie

Hiermee wordt informatie opgehaald over de huidige stem van het SpeechSynthesizer object.

public:
 property System::Speech::Synthesis::VoiceInfo ^ Voice { System::Speech::Synthesis::VoiceInfo ^ get(); };
public System.Speech.Synthesis.VoiceInfo Voice { get; }
member this.Voice : System.Speech.Synthesis.VoiceInfo
Public ReadOnly Property Voice As VoiceInfo

Waarde van eigenschap

Retourneert informatie over de huidige stem van het SpeechSynthesizer object.

Voorbeelden

In het volgende voorbeeld wordt een instantie geïnitialiseerd van SpeechSynthesizer en wordt informatie over de huidige stem opgehaald.

using System;
using System.IO;
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())
      {

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

Opmerkingen

Wanneer u een nieuwe SpeechSynthesizerinitialiseert, wordt de standaardsysteemstem gebruikt. Als u het SpeechSynthesizer object wilt configureren voor het gebruik van een van de geïnstalleerde spraaksynthesestemmen, gebruikt u de SelectVoice of SelectVoiceByHints methode. Als u informatie wilt over welke stemmen zijn geïnstalleerd, gebruikt u de GetInstalledVoices methode en de VoiceInfo klasse.

Van toepassing op

Zie ook