screenshot345
screenshot345

Reputation: 608

How to use Microsoft Speech Object Library to create a wav file

I am looking to use Skype in my C# program. I wish to initiate a phone call and inject an audio file for the receiver to listen to.

Is it possible to use Microsoft Speech Object Library in C# to save the converted audio file (wav), instead of just playing it directly through the speakers?

Upvotes: 1

Views: 2018

Answers (1)

Shay Erlichmen
Shay Erlichmen

Reputation: 31928

You will need .NET 3.0 for this:

public void TextToSpeech(string text, string fileName)
{
   using (var stream = File.Create(fileName))
   {
      SpeechSynthesizer speechEngine = new SpeechSynthesizer();
      speechEngine.SetOutputToWaveStream(stream);
      speechEngine.Speak(text);
      stream.Flush();
   }
}

Upvotes: 3

Related Questions