SpeechSynthesizer.SetOutputToWaveStream(Stream) 메서드

정의

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

public:
 void SetOutputToWaveStream(System::IO::Stream ^ audioDestination);
public void SetOutputToWaveStream (System.IO.Stream audioDestination);
member this.SetOutputToWaveStream : System.IO.Stream -> unit
Public Sub SetOutputToWaveStream (audioDestination As Stream)

매개 변수

audioDestination
Stream

합성 출력을 추가할 스트림입니다.

예제

다음 예에서는 WAV 스트림에 구를 출력 합니다.

using System;  
using System.IO;  
using System.Speech.Synthesis;  

namespace SampleSynthesis  
{  
  class Program  
  {  
    static void Main(string[] args)  
    {  

      // Initialize a new instance of the speech synthesizer.  
      using (SpeechSynthesizer synth = new SpeechSynthesizer())  
      using (MemoryStream streamAudio = new MemoryStream())  
      {  

        // Create a SoundPlayer instance to play the output audio file.  
        System.Media.SoundPlayer m_SoundPlayer = new System.Media.SoundPlayer();  

        // Configure the synthesizer to output to an audio stream.  
        synth.SetOutputToWaveStream(streamAudio);  

        // Speak a phrase.  
        synth.Speak("This is sample text-to-speech output.");  
        streamAudio.Position = 0;  
        m_SoundPlayer.Stream = streamAudio;  
        m_SoundPlayer.Play();  

        // Set the synthesizer output to null to release the stream.   
        synth.SetOutputToNull();  

        // Insert code to persist or process the stream contents here.  
      }  

      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  

설명

의 스트림에 대 한 참조를 해제 하려면를 SpeechSynthesizer 호출 하 여 신시사이저의 출력을 다시 구성 합니다 SetOutputToNull .

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

적용 대상