SpeechSynthesizer.GetInstalledVoices Metod
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.
Returnerar samlingen av talsyntesröster (text till tal) som för närvarande är installerade i systemet.
Överlagringar
| Name | Description |
|---|---|
| GetInstalledVoices() |
Returnerar alla installerade talsyntesröster (text till tal). |
| GetInstalledVoices(CultureInfo) |
Returnerar alla installerade talsyntesröster (text till tal) som stöder ett visst språk. |
Kommentarer
När ett program anropar GetInstalledVoicesverifierar metoden att var och en av rösterna (motorer för text till tal) som hittas i registret uppfyller vissa minimikriterier. För alla röster som inte kan verifieras GetInstalledVoices anger dess Enabled egenskap till False. Ett program kan inte välja en röst vars Enabled egenskap är False. Normalt ställer inte program in en rösts Enabled egenskap.
GetInstalledVoices()
- Källa:
- SpeechSynthesizer.cs
- Källa:
- SpeechSynthesizer.cs
- Källa:
- SpeechSynthesizer.cs
- Källa:
- SpeechSynthesizer.cs
Returnerar alla installerade talsyntesröster (text till tal).
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)
Returer
Returnerar en skrivskyddad samling röster som för närvarande är installerade i systemet.
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
En röst är en motor för talsyntes (text till tal eller TTS) som är installerad på systemet.
Se även
Gäller för
GetInstalledVoices(CultureInfo)
- Källa:
- SpeechSynthesizer.cs
- Källa:
- SpeechSynthesizer.cs
- Källa:
- SpeechSynthesizer.cs
- Källa:
- SpeechSynthesizer.cs
Returnerar alla installerade talsyntesröster (text till tal) som stöder ett visst språk.
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)
Parametrar
- culture
- CultureInfo
Det språk som rösten måste stödja.
Returer
Returnerar en skrivskyddad samling röster som för närvarande är installerade i systemet som stöder det angivna språket.
Exempel
Följande exempel är en del av ett konsolprogram som initierar ett SpeechSynthesizer objekt och utdata till konsolen en lista över installerade röster som stöder en-US nationella inställningar.
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);
}
}
}
Kommentarer
Om ingen av de installerade rösterna stöder det angivna språket returnerar den här metoden en tom samling.
Microsoft Windows och System.Speech API accepterar alla giltiga språk-landskoder. Om du vill utföra text-till-tal med det språk som anges i egenskapen Kultur 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.