SpeechSynthesizer.SetOutputToWaveFile Méthode
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.
Configure l’objet pour ajouter la SpeechSynthesizer sortie à un fichier de format audio Waveform.
Surcharges
| Nom | Description |
|---|---|
| SetOutputToWaveFile(String, SpeechAudioFormatInfo) |
Configure l’objet pour ajouter la SpeechSynthesizer sortie à un fichier de format audio Waveform dans un format spécifié. |
| SetOutputToWaveFile(String) |
Configure l’objet pour ajouter la SpeechSynthesizer sortie à un fichier qui contient le format audio du format Waveform. |
Remarques
Pour libérer la SpeechSynthesizerréférence du fichier, reconfigurez la SpeechSynthesizersortie du fichier, par exemple en appelant SetOutputToNull.
Pour obtenir d’autres options de configuration de sortie, consultez les méthodes et les SetOutputToAudioStreamméthodesSetOutputToDefaultAudioDeviceSetOutputToNullSetOutputToWaveStream.
SetOutputToWaveFile(String, SpeechAudioFormatInfo)
- Source:
- SpeechSynthesizer.cs
- Source:
- SpeechSynthesizer.cs
- Source:
- SpeechSynthesizer.cs
- Source:
- SpeechSynthesizer.cs
Configure l’objet pour ajouter la SpeechSynthesizer sortie à un fichier de format audio Waveform dans un format spécifié.
public:
void SetOutputToWaveFile(System::String ^ path, System::Speech::AudioFormat::SpeechAudioFormatInfo ^ formatInfo);
public void SetOutputToWaveFile(string path, System.Speech.AudioFormat.SpeechAudioFormatInfo formatInfo);
member this.SetOutputToWaveFile : string * System.Speech.AudioFormat.SpeechAudioFormatInfo -> unit
Public Sub SetOutputToWaveFile (path As String, formatInfo As SpeechAudioFormatInfo)
Paramètres
- path
- String
Chemin d’accès au fichier.
- formatInfo
- SpeechAudioFormatInfo
Informations de format audio.
Exemples
L’exemple suivant spécifie le format de la sortie de synthèse vocale et l’envoie à un fichier WAV.
using System;
using System.IO;
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())
{
// Configure the audio output.
synth.SetOutputToWaveFile(@"C:\temp\test.wav",
new SpeechAudioFormatInfo(32000, AudioBitsPerSample.Sixteen, AudioChannel.Mono));
// Create a SoundPlayer instance to play output audio file.
System.Media.SoundPlayer m_SoundPlayer =
new System.Media.SoundPlayer(@"C:\temp\test.wav");
// Build a prompt.
PromptBuilder builder = new PromptBuilder();
builder.AppendText("This is sample output to a WAVE file.");
// Speak the prompt.
synth.Speak(builder);
m_SoundPlayer.Play();
}
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
Voir aussi
- SetOutputToAudioStream(Stream, SpeechAudioFormatInfo)
- SetOutputToDefaultAudioDevice()
- SetOutputToNull()
- SetOutputToWaveStream(Stream)
S’applique à
SetOutputToWaveFile(String)
- Source:
- SpeechSynthesizer.cs
- Source:
- SpeechSynthesizer.cs
- Source:
- SpeechSynthesizer.cs
- Source:
- SpeechSynthesizer.cs
Configure l’objet pour ajouter la SpeechSynthesizer sortie à un fichier qui contient le format audio du format Waveform.
public:
void SetOutputToWaveFile(System::String ^ path);
public void SetOutputToWaveFile(string path);
member this.SetOutputToWaveFile : string -> unit
Public Sub SetOutputToWaveFile (path As String)
Paramètres
- path
- String
Chemin d’accès au fichier.
Exemples
L’exemple suivant utilise une instance de SoundPlayer lecture d’une invite qui a été sortie dans un fichier .wav. Étant donné que l’appel SpeakAsync est asynchrone, l’instance SoundPlayer est créée (et la Play méthode appelée) dans le gestionnaire de l’événement SpeakCompleted .
using System;
using System.Speech.Synthesis;
namespace SampleSynthesis
{
class Program
{
static void Main(string[] args)
{
// Initialize a new instance of the SpeechSynthesizer.
SpeechSynthesizer synth = new SpeechSynthesizer();
// Configure the audio output.
synth.SetOutputToWaveFile(@"C:\Test\Sample.wav");
// Register for the SpeakCompleted event.
synth.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(synth_SpeakCompleted);
// Build a prompt.
PromptBuilder builder = new PromptBuilder();
builder.AppendText("This sample asynchronously speaks a prompt to a WAVE file.");
// Speak the string asynchronously.
synth.SpeakAsync(builder);
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
// Handle the SpeakCompleted event.
static void synth_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
{
// Create a SoundPlayer instance to play the output audio file.
System.Media.SoundPlayer m_SoundPlayer =
new System.Media.SoundPlayer(@"C:\Test\Sample.wav");
// Play the output file.
m_SoundPlayer.Play();
}
}
}
Remarques
Pour configurer la sortie et spécifier le format audio, utilisez la SetOutputToWaveFile méthode.
Voir aussi
- SetOutputToAudioStream(Stream, SpeechAudioFormatInfo)
- SetOutputToDefaultAudioDevice()
- SetOutputToNull()
- SetOutputToWaveStream(Stream)