【问题标题】:windows RT / Universal app, Text to speech "Save as Mp3"Windows RT / 通用应用程序,文本到语音“另存为 Mp3”
【发布时间】:2014-11-24 10:56:28
【问题描述】:

我正在尝试向文本通用应用程序发表演讲,但遇到了一件事情。我浏览了整个互联网,找不到合适的解决方案。所以我来到这里。基本上我希望应用程序将文本框中的内容保存为 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, " ");
            }

【问题讨论】:

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


    【解决方案1】:

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

    MSDN: Media Transcoder

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


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

    【讨论】:

    • 如何将 SpeechSynthesStrem 保存为 .wav 文件?抱歉,我对这些东西不熟悉
    • @ProgrammingPotato 查看链接的cpp文件,它位于事件处理程序BtnSaveToFile_Click
    • 谢谢,但我在寻找 c# 代码,而不是 c++。在我了解更多关于编程的知识之前,我会留下它。
    • @ProgrammingPotato 它使用相同的功能。几乎可以1:1转换。忽略^,你就会发现Windows::Storage::Streams::BufferWindows.Storage.Streams.Buffer是一样的废话
    • @ProgrammingPotato 或者您可以搜索 SO,了解如何将缓冲区写入文件。可以肯定有很多答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-07
    • 1970-01-01
    • 2013-04-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多