InstalledVoice Klass
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Innehåller information om en talsyntesröst installerad i Windows.
public ref class InstalledVoice
public class InstalledVoice
type InstalledVoice = class
Public Class InstalledVoice
- Arv
-
InstalledVoice
Exempel
Följande exempel är en del av ett konsolprogram som initierar ett SpeechSynthesizer objekt och matar ut en lista över installerade röster (motorer för talsyntes) till konsolen och visar den information som är tillgänglig för varje röst.
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();
}
}
}
Kommentarer
Använd den här klassen för att få information om en installerad röst, inklusive dess kultur, namn, kön, ålder och om den är aktiverad.
Om du vill utföra text-till-tal med det språk som anges i Culture egenskapen måste en talsyntesmotor som stöder språklandskoden installeras. Talsyntesmotorerna som levererades med Microsoft Windows 7 arbeta med följande språk-landskoder:
en-US. Engelska (USA)
zh-CN. Kinesiska (Kina)
zh-TW. Kinesiska (Taiwan)
Språkkoder med två bokstäver, till exempel "en" är också tillåtna.
Egenskaper
| Name | Description |
|---|---|
| Enabled |
Hämtar eller anger om en röst kan användas för att generera tal. |
| VoiceInfo |
Hämtar information om en röst, till exempel kultur, namn, kön och ålder. |
Metoder
| Name | Description |
|---|---|
| Equals(Object) |
Avgör om ett angivet objekt är en instans av InstalledVoice och lika med den aktuella instansen av InstalledVoice. |
| GetHashCode() |
Tillhandahåller en hash-kod för ett |
| GetType() |
Hämtar den aktuella instansen Type . (Ärvd från Object) |
| MemberwiseClone() |
Skapar en ytlig kopia av den aktuella Object. (Ärvd från Object) |
| ToString() |
Returnerar en sträng som representerar det aktuella objektet. (Ärvd från Object) |