Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Created Unassigned: Playing Microsoft TTS with WASAPI [16449]

$
0
0
Hallo,

I have a problem playing Microsoft Text to Speech with WASAPI. I basically get an error (Not a WAVE file - no RIFF header) when the WaveFileReader tries to read the audioStream. As you can see in the code below I tried to convert the audioStream coming from Microsoft Text to Speech but it doesn't work.

```
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();

SpeechAudioFormatInfo speechFormat = new SpeechAudioFormatInfo(EncodingFormat.Pcm, 32000, 8, 2, 8000, 2, null);

//synth.SelectVoice(AppSettings.VoiceName);

// Configure the synthesizer to output to an audio stream.
synth.SetOutputToAudioStream(streamAudio,speechFormat);

// Speak a phrase.
synth.Speak("Hallo Jonas wie gehts es dir?");
streamAudio.Position = 0;
synth.SetOutputToNull();

_wasapiOut = new WasapiOut(device, AudioClientShareMode.Shared, false, 2000);

RawSourceWaveStream s = new RawSourceWaveStream(streamAudio, new WaveFormat(32000, 8, 2));
WaveStream ws = WaveFormatConversionStream.CreatePcmStream(s);

_reader = new WaveFileReader(streamAudio);
_wasapiOut.Init(_reader);
_wasapiOut.Play();
}
```

I hope somebody can help me :)

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>