Export (0) Print
Expand All

SpeechSynthesizer.GetInstalledVoices Method (CultureInfo)

Returns all of the installed speech synthesis (text-to-speech) voices that support a specific locale.

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

public ReadOnlyCollection<InstalledVoice> GetInstalledVoices(
	CultureInfo culture
)

Parameters

culture
Type: System.Globalization.CultureInfo

The locale that the voice must support.

Return Value

Type: System.Collections.ObjectModel.ReadOnlyCollection<InstalledVoice>
Returns a read-only collection of the voices currently installed on the system that support the specified locale.

If none of the installed voices support the specified locale, this method returns an empty collection.

Microsoft Windows and the System.Speech API accept all valid language-country codes. 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. The speech synthesis engines that shipped with Microsoft Windows 7 work with the following language-country codes:

  • en-US. English (United States)

  • zh-CN. Chinese (China)

  • zh-TW. Chinese (Taiwan)

Two-letter language codes such as "en" are also permitted.

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

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft