微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

同一输出文件中的AWS 2声音新闻标题和新闻内容

如何解决同一输出文件中的AWS 2声音新闻标题和新闻内容

我有一条新闻帖子:

新闻帖子的标题(使用语音Joey):

F1 cancels Hanoi 2020 schedule

新闻内容(使用语音:琼)

Turkey,Bahrain (hosting two races),and Abu Dhabi will be part of the revised season,bringing the total number of races to 17,Formula One stated Tuesday. A number of races in the revised 2020 season will be open to a limited number of fans,including hospitality,it said. While three races will be hosted in Asia this year,the Vietnamese Grand Prix in Hanoi did not make the list,along with the Chinese Grand Prix in Shanghai,due to the ongoing Covid-19 pandemic. The Turkish Grand Prix will occur on November 15,before the back-to-back races in Bahrain on November 29 and December 6.

(摘自来源:https://e.vnexpress.net/news/sports/f1-cancels-hanoi-2020-schedule-4152653.html

我尝试过使用NAudio,但是合并后出现音频错误。我正在寻找使用AWS Polly API的本机方式,而不是通过NAudio文件流进行组合。

[HttpGet]
[Route("generate/audio/compound/{id}")]       
public static void GenerateSoundOfNewsCompound(int id)
{
    if (System.IO.File.Exists(@"c:\audio\compound\" + id + ".mp3"))
    {
        // Console.WriteLine("The file exists.");
    }
    else
    {
        // title.
        AmazonPollyClient amazonPollyClient = new AmazonPollyClient("AKIA4NK3K6JXXZ724452","D4rqgC7Ap2H9msff5mO3lxiS1SvXJf6dcpogHnjN",Amazon.RegionEndpoint.EUWest1);
        SynthesizeSpeechRequest synthesizeSpeechRequest = new SynthesizeSpeechRequest();
        synthesizeSpeechRequest.Text = GetNewsTitleById(id);
        // Giọng nam,Anh Mỹ.
        synthesizeSpeechRequest.VoiceId = VoiceId.Joey;
        synthesizeSpeechRequest.OutputFormat = OutputFormat.Mp3;
        synthesizeSpeechRequest.SampleRate = "8000";
        synthesizeSpeechRequest.TextType = "text";
        var response = amazonPollyClient.SynthesizeSpeechAsync(synthesizeSpeechRequest).GetAwaiter().GetResult();
        using (FileStream output = System.IO.File.OpenWrite(@"c:\audio\title\" + id + ".mp3"))
        {
            response.AudioStream.copyTo(output);
        }
        // content.
        SynthesizeSpeechRequest synthesizeSpeechRequest2 = new SynthesizeSpeechRequest();
        synthesizeSpeechRequest2.Text = GetSummary4SentencesById(id);
        // Giọng nữ,Mỹ.
        synthesizeSpeechRequest2.VoiceId = VoiceId.Joanna;
        synthesizeSpeechRequest2.OutputFormat = OutputFormat.Mp3;
        synthesizeSpeechRequest2.SampleRate = "8000";
        synthesizeSpeechRequest2.TextType = "text";                
        var response2 = amazonPollyClient.SynthesizeSpeechAsync(synthesizeSpeechRequest2).GetAwaiter().GetResult();
        using FileStream output2 = System.IO.File.OpenWrite(@"c:\audio\content\" + id + ".mp3");
        response.AudioStream.copyTo(output2);

        // Ghép 2 file.
        string[] foo = { @"c:\audio\title\" + id + ".mp3",@"c:\audio\content\" + id + ".mp3" };
        Stream output3 = System.IO.File.OpenWrite(@"c:\audio\compound\" + id + ".mp3"); ;
        Combine(foo,output3);
    }            
}

// Sinh file (đã bao gồm kiểm tra tồn tại),trả về file.
[HttpGet]
[Route("audio/compound/{id}")]
public IActionResult GetSoundOfNewsPost22(int id)
{
    GenerateSoundOfNewsCompound(id);
    return new PhysicalFileResult(@"c:\audio\compound\" + id + ".mp3","audio/mpeg");
}

如何生成乔伊(Joey)读过的标题和琼(Joan)读过的内容相结合的mp3音频文件

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。