Ultra Fast Text to Speech (WAV -> MP3) in ASP.NET MVC

后端 未结 2 1742
小鲜肉
小鲜肉 2021-02-06 16:16

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

相关标签:
2条回答
  • 2021-02-06 16:54

    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#

    0 讨论(0)
  • 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...

    0 讨论(0)
提交回复
热议问题