InstalledVoice Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Contient des informations sur une voix de synthèse vocale installée dans Windows.
public ref class InstalledVoice
public class InstalledVoice
type InstalledVoice = class
Public Class InstalledVoice
- Héritage
-
InstalledVoice
Exemples
L’exemple suivant fait partie d’une application console qui initialise un objet et génère dans la console une SpeechSynthesizer liste des voix installées (moteurs de synthèse vocale) et illustre les informations disponibles pour chaque voix.
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();
}
}
}
Remarques
Utilisez cette classe pour obtenir des informations sur une voix installée, y compris sa culture, son nom, son sexe, son âge et si elle est activée.
Pour effectuer une synthèse vocale à l’aide de la langue spécifiée dans la Culture propriété, un moteur de synthèse vocale qui prend en charge ce code de langue-pays doit être installé. Les moteurs de synthèse vocale fournis avec Microsoft Windows 7 fonctionnent avec les codes de pays de langue suivants :
en-US. Anglais (États-Unis)
zh-CN. Chinois (Chine)
zh-TW. Chinois (Taïwan)
Les codes de langue à deux lettres tels que « en » sont également autorisés.
Propriétés
| Nom | Description |
|---|---|
| Enabled |
Obtient ou définit si une voix peut être utilisée pour générer la voix. |
| VoiceInfo |
Obtient des informations sur une voix, comme la culture, le nom, le sexe et l’âge. |
Méthodes
| Nom | Description |
|---|---|
| Equals(Object) |
Détermine si un objet donné est une instance et InstalledVoice égale à l’instance actuelle de InstalledVoice. |
| GetHashCode() |
Fournit un code de hachage pour un |
| GetType() |
Obtient la Type de l’instance actuelle. (Hérité de Object) |
| MemberwiseClone() |
Crée une copie superficielle du Objectactuel. (Hérité de Object) |
| ToString() |
Retourne une chaîne qui représente l’objet actuel. (Hérité de Object) |