English 中文(简体)
Text to MP3 using System.Speech.Synthesis.SpeechSynthesizer
原标题:

I am trying to get a text-to-speech to save to an MP3. Currently I have the System.Speech.Synthesis speaking to a WAV file nicely.

    With New System.Speech.Synthesis.SpeechSynthesizer
         .SetOutputToWaveFile(pOutputPath)    This works fine 
        .SetOutputToWaveStream(<<Problem bit>>)
        .Speak(pTextToSpeak)
        .SetOutputToNull()
        .Dispose()
    End With

Now the first line commented out produces a WAV file which is nice. Currently I am trying to replace that with an MP3 output stream and not having much success.

I have tried the Yeti.MMedia converter but either it isn t going to work or I haven t got it to work successfully. I have to admit here I don t know much about encodings, speeds etc.

So the question I have is, does anyone know of a nice way I can say something like the following:

.SetOutputToWaveStream(New MP3WriteStream(pOutputPath))

and have the SpeechSynthesizer write to the WAV which then gets converted to the MP3 and ends up on the HDD.

问题回答

First, get the Yeti classes to provide a writable stream, with the appropriate compression factor. Then, use SpeechSynthesizer.SetOutputToAudioStream - to tell the TTS engine about the speech quality.

I don t think there is any other way than to write it using Wav and then convert it using LAME MP3 Encoder (etc.).

Just fiddle around with Yeti, it does work, I used it on a pretty big web app and it s been running without issue for about 2 years.





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签