Windows RT /通用应用程序,文本到语音“另存为Mp3”

时间:2014-11-24 10:56:29

标签: c# windows windows-phone-8 text-to-speech win-universal-app

我试图发表文字通用应用程序,但却陷入了困境。我看了整个互联网,找不到合适的解决方案。所以我来到这里..基本上我希望应用程序保存文本框中的所有内容为mp3。到目前为止,这是我的代码:

 private void Speak_Click(object sender, RoutedEventArgs e)
    {
        SpeakText(Text.Text);
    }
    public async void SpeakText(string TTS)
            {
                SpeechSynthesizer ttssynthesizer = new SpeechSynthesizer();

                //Set the Voice/Speaker
                using (var Speaker = new SpeechSynthesizer())
                {
                    Speaker.Voice = (SpeechSynthesizer.AllVoices.First(x => x.Gender == VoiceGender.Female));

                    ttssynthesizer.Voice = Speaker.Voice;
                }

                SpeechSynthesisStream ttsStream = await ttssynthesizer.SynthesizeTextToStreamAsync(TTS);

                //play the speech
                MediaElement media = new MediaElement();
                media.SetSource(ttsStream, " ");
            }

1 个答案:

答案 0 :(得分:2)

我认为您可以将SpeechSynthesisStream保存为.wav文件。然后,您可以使用MediaTranscoder类将其重新编码为您喜欢的任何内容。

MSDN: Media Transcoder

Sample Project using Media Transcoder -- use it as a refeence


将流保存到wav文件的一些额外帮助:SpeakText.xaml.cpp