SpeechSynthesizer.SetOutputToWaveStream(Stream) SpeechSynthesizer.SetOutputToWaveStream(Stream) SpeechSynthesizer.SetOutputToWaveStream(Stream) SpeechSynthesizer.SetOutputToWaveStream(Stream) Method

定義

SpeechSynthesizer オブジェクトを、WAVE 形式のオーディオを含むストリームに出力を追加するように構成します。Configures the SpeechSynthesizer object to append output to a stream that contains Waveform format audio.

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 Stream Stream Stream

合成出力を追加するストリーム。The stream to which to append synthesis output.

次の例では、WAV ストリームに語句を出力します。The following example outputs a phrase to a WAV stream.

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などして、シンセサイザーの出力を再構成します。To release the SpeechSynthesizer's reference to the stream, reconfigure the synthesizer's output, for example, by calling SetOutputToNull.

その他の出力構成オプションについSetOutputToAudioStreamては、「 SetOutputToWaveFile 」、「」、「」、および「」を参照してくださいSetOutputToDefaultAudioDeviceSetOutputToNullFor other output configuration options, see the SetOutputToAudioStream, SetOutputToDefaultAudioDevice, SetOutputToNull, and SetOutputToWaveFile methods.

適用対象