SpeechSynthesizer.GetInstalledVoices SpeechSynthesizer.GetInstalledVoices SpeechSynthesizer.GetInstalledVoices SpeechSynthesizer.GetInstalledVoices Method

Definición

Devuelve la colección de voces de síntesis de voz (texto a voz) que están instaladas actualmente en el sistema.Returns the collection of speech synthesis (text-to-speech) voices that are currently installed on the system.

Sobrecargas

GetInstalledVoices() GetInstalledVoices() GetInstalledVoices() GetInstalledVoices()

Devuelve todas las voces de síntesis de voz (texto a voz) instaladas.Returns all of the installed speech synthesis (text-to-speech) voices.

GetInstalledVoices(CultureInfo) GetInstalledVoices(CultureInfo) GetInstalledVoices(CultureInfo) GetInstalledVoices(CultureInfo)

Devuelve todas las voces de síntesis de voz (texto a voz) instaladas que admiten una configuración regional específica.Returns all of the installed speech synthesis (text-to-speech) voices that support a specific locale.

Comentarios

Cuando una aplicación llama GetInstalledVoicesa, el método comprueba que cada una de las voces (motores de texto a voz) que encuentra en el registro cumple determinados criterios mínimos.When an application calls GetInstalledVoices, the method verifies that each of the voices (engines for text-to-speech) it finds in the registry meets certain minimum criteria. Para cualquier voz que produzca un error GetInstalledVoices de comprobación Enabled , establece Falsesu propiedad en.For any voice that fails verification, GetInstalledVoices sets its Enabled property to False. Una aplicación no puede seleccionar una voz Enabled cuya propiedad Falsesea.An application cannot select a voice whose Enabled property is False. Normalmente, las aplicaciones no establecerán la propiedad Enabled de una voz.Typically, applications will not set a voice's Enabled property.

GetInstalledVoices() GetInstalledVoices() GetInstalledVoices() GetInstalledVoices()

Devuelve todas las voces de síntesis de voz (texto a voz) instaladas.Returns all of the installed speech synthesis (text-to-speech) voices.

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)

Devoluciones

Devuelve una colección de solo lectura de las voces instaladas actualmente en el sistema.Returns a read-only collection of the voices currently installed on the system.

Ejemplos

El siguiente ejemplo forma parte de una aplicación de consola que inicializa un SpeechSynthesizer objeto y envía a la consola una lista de las voces instaladas (motores para la síntesis de voz) y muestra la información que está disponible para cada voz.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();  
    }  
  }  
}  

Comentarios

Una voz es un motor de síntesis de voz (texto a voz o TTS) que está instalado en el sistema.A voice is an engine for speech synthesis (text-to-speech or TTS) that is installed on the system.

Consulte también:

GetInstalledVoices(CultureInfo) GetInstalledVoices(CultureInfo) GetInstalledVoices(CultureInfo) GetInstalledVoices(CultureInfo)

Devuelve todas las voces de síntesis de voz (texto a voz) instaladas que admiten una configuración regional específica.Returns all of the installed speech synthesis (text-to-speech) voices that support a specific locale.

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)

Parámetros

culture
CultureInfo CultureInfo CultureInfo CultureInfo

Configuración regional que la voz debe admitir.The locale that the voice must support.

Devoluciones

Devuelve una colección de solo lectura de las voces instaladas actualmente en el sistema que admite la configuración regional especificada.Returns a read-only collection of the voices currently installed on the system that support the specified locale.

Ejemplos

El siguiente ejemplo forma parte de una aplicación de consola que inicializa un SpeechSynthesizer objeto y envía a la consola una lista de las voces instaladas que admiten la configuración regional en-US.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 that support the en-US locale.

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

Comentarios

Si ninguna de las voces instaladas admite la configuración regional especificada, este método devuelve una colección vacía.If none of the installed voices support the specified locale, this method returns an empty collection.

Microsoft Windows y System. Speech API aceptan todos los códigos de país de idioma válidos.Microsoft Windows and the System.Speech API accept all valid language-country codes. Para realizar una conversión de texto a voz mediante el idioma especificado en la propiedad Culture, se debe instalar un motor de síntesis de voz que admita ese código de país de idioma.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. Los motores de síntesis de voz que se incluyen con Microsoft Windows 7 funcionan con los siguientes códigos de país de idioma:The speech synthesis engines that shipped with Microsoft Windows 7 work with the following language-country codes:

  • en-US.en-US. Inglés (Estados Unidos)English (United States)

  • zh-CN.zh-CN. Chino (China)Chinese (China)

  • zh-TW.zh-TW. Chino (Taiwán)Chinese (Taiwan)

También se permiten códigos de idioma de dos letras, como "en".Two-letter language codes such as "en" are also permitted.

Consulte también:

Se aplica a