Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Save text to speech to MP3 file

I am wondering if there is a way to save text to speech data to an mp3 or Wav file format to be played back at a later time?

SpeechSynthesizer reader = new SpeechSynthesizer();
reader.Rate = (int)-2;
reader.Speak("Hello this is an example expression from the computers TTS engine in C-Sharp);

I am trying to get that saved externally so I can play it back later. What is the best way to do this?

like image 632
CodeMonkeyAlx Avatar asked Apr 15 '13 17:04

CodeMonkeyAlx


1 Answers

There are multiple options such as saving to an existing stream. If you want to create a new WAV file, you can use the SetOutputToWaveFile method.

reader.SetOutputToWaveFile(@"C:\MyWavFile.wav");
like image 122
keyboardP Avatar answered Sep 28 '22 04:09

keyboardP