SpeechSynthesizer.GetInstalledVoices Metodo

Definizione

Restituisce la raccolta di voci di sintesi attualmente installate nel sistema.

Overload

GetInstalledVoices()

Restituisce tutte le voci di sintesi vocale installate.

GetInstalledVoices(CultureInfo)

Restituisce tutte le voci di sintesi vocale installate (sintesi vocale) che supportano impostazioni locali specifiche.

Commenti

Quando un'applicazione chiama GetInstalledVoices, il metodo verifica che ognuna delle voci (motori per la sintesi vocale) venga trovata nel Registro di sistema soddisfi determinati criteri minimi. Per qualsiasi voce che non riesce la verifica, GetInstalledVoices imposta la relativa Enabled proprietà su False. Un'applicazione non può selezionare una voce la cui Enabled proprietà è False. In genere, le applicazioni non imposteranno la proprietà di Enabled una voce.

GetInstalledVoices()

Restituisce tutte le voci di sintesi vocale installate.

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)

Restituisce

Restituisce una raccolta di sola lettura delle voci attualmente installate nel sistema.

Esempio

L'esempio seguente fa parte di un'applicazione console che inizializza un SpeechSynthesizer oggetto e restituisce nella console un elenco delle voci installate (motori per la sintesi vocale) e illustra le informazioni disponibili per ogni voce.

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

Commenti

Una voce è un motore per la sintesi vocale (sintesi vocale o TTS) installato nel sistema.

Vedi anche

Si applica a

GetInstalledVoices(CultureInfo)

Restituisce tutte le voci di sintesi vocale installate (sintesi vocale) che supportano impostazioni locali specifiche.

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)

Parametri

culture
CultureInfo

Le impostazioni locali che la voce deve supportare.

Restituisce

Restituisce una raccolta di sola lettura delle voci attualmente installate nel sistema che supportano le impostazioni locali specificate.

Esempio

L'esempio seguente fa parte di un'applicazione console che inizializza un SpeechSynthesizer oggetto e restituisce nella console un elenco delle voci installate che supportano le impostazioni locali 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);
    }
  }
}

Commenti

Se nessuna delle voci installate supporta le impostazioni locali specificate, questo metodo restituisce una raccolta vuota.

Microsoft Windows e l'API System.Speech accettano tutti i codici paese di lingua validi. Per eseguire la sintesi vocale usando la lingua specificata nella proprietà Culture, è necessario installare un motore di sintesi vocale che supporta tale codice del paese di lingua. I motori di sintesi vocale forniti con Microsoft Windows 7 funzionano con i seguenti codici di lingua:The speech synthesis engines that shipped with Microsoft Windows 7 work with the following language-country codes:

  • en-US. Inglese (Stati Uniti)

  • zh-CN. Cinese (Cina)

  • zh-TW. Cinese (Taiwan)

Sono consentiti anche codici linguistici a due lettere, ad esempio "en".

Vedi anche

Si applica a