Reputation: 6103
This is how I speak "Hello" using SpeechSynthesizer
, convert with NAudio WaveFormatConversionStream
and read it again .
And I got the error
Not a WAVE file - no RIFF header
int count = sourceFiles.Count;
WaveFileReader[] reader = new WaveFileReader[count];
var _wavStream = new MemoryStream();
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
synth.SetOutputToWaveStream(_wavStream);
synth.Speak("Hello");
_wavStream.Position = 0;
int outRate = 44100;
var outFormat = new WaveFormat(outRate, 16, 1);
using (var resampler = new WaveFormatConversionStream(outFormat, new WaveFileReader(_wavStream)))
{
reader[i] = new WaveFileReader(resampler); <====GotTheErrorHere
How can I fix it ?
Thanks !
Upvotes: 0
Views: 3383
Reputation: 49502
The speech synthesizer has not made a WAV file, so there is no RIFF header. instead of WaveFileReader
you should be using RawSourceWaveStream
and passing in the memory stream and the correct WaveFormat
that the speech synthesizer is outputting .
Upvotes: 1