SpeechSynthesizer.SetOutputToWaveFile 메서드

정의

Waveform 오디오 형식 파일에 출력을 추가하도록 SpeechSynthesizer 개체를 구성합니다.

오버로드

SetOutputToWaveFile(String, SpeechAudioFormatInfo)

지정된 형식의 Waveform 오디오 형식 파일에 출력을 추가하도록 SpeechSynthesizer 개체를 구성합니다.

SetOutputToWaveFile(String)

Waveform 형식 오디오를 포함하는 파일에 출력을 추가하도록 SpeechSynthesizer 개체를 구성합니다.

설명

파일에 대한 의 참조를 해제SpeechSynthesizer하려면 를 호출SetOutputToNull하여 의 출력을 다시 구성SpeechSynthesizer합니다.

다른 출력 구성 옵션은 , , SetOutputToDefaultAudioDeviceSetOutputToNullSetOutputToWaveStream 메서드를 SetOutputToAudioStream참조하세요.

SetOutputToWaveFile(String, SpeechAudioFormatInfo)

Source:
SpeechSynthesizer.cs
Source:
SpeechSynthesizer.cs
Source:
SpeechSynthesizer.cs

지정된 형식의 Waveform 오디오 형식 파일에 출력을 추가하도록 SpeechSynthesizer 개체를 구성합니다.

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)

매개 변수

path
String

파일의 경로입니다.

formatInfo
SpeechAudioFormatInfo

오디오 형식 정보입니다.

예제

다음 예제에서는 음성 합성 출력의 형식을 지정하고 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();
    }
  }
}

추가 정보

적용 대상

SetOutputToWaveFile(String)

Source:
SpeechSynthesizer.cs
Source:
SpeechSynthesizer.cs
Source:
SpeechSynthesizer.cs

Waveform 형식 오디오를 포함하는 파일에 출력을 추가하도록 SpeechSynthesizer 개체를 구성합니다.

public:
 void SetOutputToWaveFile(System::String ^ path);
public void SetOutputToWaveFile (string path);
member this.SetOutputToWaveFile : string -> unit
Public Sub SetOutputToWaveFile (path As String)

매개 변수

path
String

파일의 경로입니다.

예제

다음 예제에서는 의 instance SoundPlayer 사용하여 .wav 파일에 출력된 프롬프트를 재생합니다. 호출이 SpeakAsync 비동 SoundPlayer 기적이므로 instance 이벤트 처리기에 생성되고 Play 메서드가 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();
    }
  }
}

설명

출력을 구성하고 오디오 형식을 지정하려면 메서드를 SetOutputToWaveFile 사용합니다.

추가 정보

적용 대상