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 !
The speech synthesizer has not made a WAV file, so there is no RIFF header. instead of
WaveFileReader
you should be usingRawSourceWaveStream
and passing in the memory stream and the correctWaveFormat
that the speech synthesizer is outputting .