SpeechSynthesizer.GetInstalledVoices Metoda

Definicja

Zwraca kolekcję głosów syntezy mowy (zamiana tekstu na mowę), które są obecnie zainstalowane w systemie.

Przeciążenia

GetInstalledVoices()

Zwraca wszystkie zainstalowane głosy syntezy mowy (zamiana tekstu na mowę).

GetInstalledVoices(CultureInfo)

Zwraca wszystkie zainstalowane głosy syntezy mowy (zamiana tekstu na mowę), które obsługują określone ustawienia regionalne.

Uwagi

Gdy aplikacja wywołuje GetInstalledVoicesmetodę , metoda sprawdza, czy każda z głosów (aparatów zamiany tekstu na mowę) znajduje się w rejestrze spełnia pewne minimalne kryteria. Dla dowolnego głosu, który kończy się niepowodzeniem weryfikacji, GetInstalledVoices ustawia jego Enabled właściwość na False. Aplikacja nie może wybrać głosu, którego Enabled właściwość to False. Zazwyczaj aplikacje nie ustawiają właściwości głosu Enabled .

GetInstalledVoices()

Źródło:
SpeechSynthesizer.cs
Źródło:
SpeechSynthesizer.cs
Źródło:
SpeechSynthesizer.cs

Zwraca wszystkie zainstalowane głosy syntezy mowy (zamiana tekstu na mowę).

public:
 System::Collections::ObjectModel::ReadOnlyCollection<System::Speech::Synthesis::InstalledVoice ^> ^ GetInstalledVoices();
public System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Synthesis.InstalledVoice> GetInstalledVoices ();
member this.GetInstalledVoices : unit -> System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Synthesis.InstalledVoice>
Public Function GetInstalledVoices () As ReadOnlyCollection(Of InstalledVoice)

Zwraca

Zwraca kolekcję głosów tylko do odczytu, która jest obecnie zainstalowana w systemie.

Przykłady

Poniższy przykład jest częścią aplikacji konsolowej, która inicjuje SpeechSynthesizer obiekt i wyprowadza do konsoli listę zainstalowanych głosów (aparatów syntezy mowy) i demonstruje informacje dostępne dla każdego głosu.

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

Uwagi

Głos to aparat syntezy mowy (zamiana tekstu na mowę lub TTS), który jest zainstalowany w systemie.

Zobacz też

Dotyczy

GetInstalledVoices(CultureInfo)

Źródło:
SpeechSynthesizer.cs
Źródło:
SpeechSynthesizer.cs
Źródło:
SpeechSynthesizer.cs

Zwraca wszystkie zainstalowane głosy syntezy mowy (zamiana tekstu na mowę), które obsługują określone ustawienia regionalne.

public:
 System::Collections::ObjectModel::ReadOnlyCollection<System::Speech::Synthesis::InstalledVoice ^> ^ GetInstalledVoices(System::Globalization::CultureInfo ^ culture);
public System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Synthesis.InstalledVoice> GetInstalledVoices (System.Globalization.CultureInfo culture);
member this.GetInstalledVoices : System.Globalization.CultureInfo -> System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Synthesis.InstalledVoice>
Public Function GetInstalledVoices (culture As CultureInfo) As ReadOnlyCollection(Of InstalledVoice)

Parametry

culture
CultureInfo

Ustawienia regionalne, które głos musi obsługiwać.

Zwraca

Zwraca kolekcję głosów tylko do odczytu zainstalowaną obecnie w systemie obsługującym określone ustawienia regionalne.

Przykłady

Poniższy przykład jest częścią aplikacji konsolowej, która inicjuje SpeechSynthesizer obiekt i dane wyjściowe w konsoli, listę zainstalowanych głosów, które obsługują ustawienia regionalne en-US.

using System;
using System.Globalization;
using System.Speech.Synthesis;

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

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

        // Output information about all of the installed voices that
        // support the en-US locale.
        Console.WriteLine("Installed voices for the en-US locale:");
        foreach (InstalledVoice voice in
          synthesizer.GetInstalledVoices(new CultureInfo("en-US")))
        {
          VoiceInfo info = voice.VoiceInfo;
          OutputVoiceInfo(info);
        }

        // Output information about the current voice.
        Console.WriteLine();
        Console.WriteLine("Current voice:");
        OutputVoiceInfo(synthesizer.Voice);
      }

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

    // Display information about a synthesizer voice.
    private static void OutputVoiceInfo(VoiceInfo info)
    {
      Console.WriteLine("  Name: {0}, culture: {1}, gender: {2}, age: {3}.",
        info.Name, info.Culture, info.Gender, info.Age);
      Console.WriteLine("    Description: {0}", info.Description);
    }
  }
}

Uwagi

Jeśli żadna z zainstalowanych głosów nie obsługuje określonych ustawień regionalnych, ta metoda zwraca pustą kolekcję.

Microsoft windows i interfejsu API System.Speech akceptują wszystkie prawidłowe kody krajów językowych. Aby wykonać zamianę tekstu na mowę przy użyciu języka określonego we właściwości Culture, należy zainstalować aparat syntezy mowy obsługujący ten kod kraju. Aparaty syntezy mowy dostarczane z systemem Microsoft Windows 7 współpracują z następującymi kodami krajów językowych:

  • en-US. Angielski (Stany Zjednoczone)

  • zh-CN. Chiński (Chiny)

  • zh-TW. Chiński (Tajwan)

Dozwolone są również dwuliterowe kody językowe, takie jak "en".

Zobacz też

Dotyczy