Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

VoiceInfo Class

Represents an installed speech synthesis engine.

System.Object
  System.Speech.Synthesis.VoiceInfo

Namespace:  System.Speech.Synthesis
Assembly:  System.Speech (in System.Speech.dll)
[SerializableAttribute]
public class VoiceInfo

The VoiceInfo type exposes the following members.

  NameDescription
Public propertyAdditionalInfoGets additional information about the voice.
Public propertyAgeGets the age of the voice.
Public propertyCultureGets the culture of the voice.
Public propertyDescriptionGets the description of the voice.
Public propertyGenderGets the gender of the voice.
Public propertyIdGets the ID of the voice.
Public propertyNameGets the name of the voice.
Public propertySupportedAudioFormatsGets the collection of audio formats that the voice supports.
Top
  NameDescription
Public methodEqualsCompares the fields of the voice with the specified VoiceInfo object to determine whether they contain the same values. (Overrides Object.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeProvides a hash code for a VoiceInfo object. (Overrides Object.GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

A voice is an installed speech synthesis engine, which is also referred to as a text-to-speech engine or a TTS engine. The SpeechSynthesizer object uses a voice to generate speech from text. The properties of the VoiceInfo object identify a voice and describe its characteristics. The most defining characteristic of a voice is its Culture, which defines the single language that a voice can speak.

The Voice property returns a VoiceInfo object that contains information about the current voice in use by the SpeechSynthesizer. You can also use a VoiceInfo object to get information about any of the voices that are installed on the system, as returned by the GetInstalledVoices() method. See InstalledVoice for more information.

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

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows Phone 8.1, Windows Phone 8, 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.