This question is essentially about the suitability of Microsoft\'s Speech API (SAPI) for server workloads and whether it can be used reliably inside of w3wp for
I/O is very expensive on a server. how many multiple streams of wav writting do you think you can get on a server hard drive? Why not do it all in memory and only write the mp3 when it's fully processed? mp3's are much smaller and the I/O will be engaged for a small amount of time. You can even change the code to return the stream directly to the user instead of saving to an mp3 if you want.
How do can I use LAME to encode an wav to an mp3 c#
This question is a bit old now, but this is what I'm doing and it's been working great so far:
public Task<FileStreamResult> Speak(string text)
{
return Task.Factory.StartNew(() =>
{
using (var synthesizer = new SpeechSynthesizer())
{
var ms = new MemoryStream();
synthesizer.SetOutputToWaveStream(ms);
synthesizer.Speak(text);
ms.Position = 0;
return new FileStreamResult(ms, "audio/wav");
}
});
}
might help someone...