将AWS Polly mp3文件保存到S3 [英] Save AWS Polly mp3 file to S3

查看:98
本文介绍了将AWS Polly mp3文件保存到S3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些文本发送到AWS Polly以转换为语音,然后将该mp3文件保存到S3.该部分现在似乎可以正常工作了.

I am trying to send some text to AWS Polly to convert to speech and then save that mp3 file to S3. That part seems to work now.

// Send text to AWS Polly
$client_polly = new Aws\Polly\PollyClient([
    'region' => 'us-west-2',
    'version' => 'latest',
    'credentials' => [
        'key' => $aws_useKey,
        'secret' => $aws_secret,
    ]
]);

$text = 'Test. Test. This is a sample text to be synthesized.';
$voice = 'Matthew';

 $result_polly = $client_polly->startSpeechSynthesisTask([
    'Text' => $text,
    'TextType' => 'text',
    'OutputFormat' => 'mp3',
    'OutputS3BucketName' => $aws_bucket,
    'OutputS3KeyPrefix' => 'files/audio/,
    'VoiceId' => $voice,
    'ACL' => 'public-read'
]);


echo $result_polly['ObjectURL'];

我也在尝试完成其他几件事:

I'm also trying to accomplish couple other things:

  1. 使mp3文件可公开访问.目前,我必须转到AWS控制台 点击公开"按钮.看来'ACL'=>'公开阅读'对我不起作用

  1. Make mp3 file publicly accessible. Currently I have to go to AWS console to click "Make Public" button. It seems that 'ACL' => 'public-read' doesn't work for me

我需要返回mp3文件的完整URL.由于某种原因$ result_polly ['ObjectURL'];没有任何价值.

I need to return full URL of the mp3 file. For some reason $result_polly['ObjectURL']; doesn't get any value.

我想念什么?

推荐答案

ACL字段/api/api-polly-2016-06-10.html#startspeechsynthesistask"rel =" nofollow noreferrer> StartSpeechSynthesisTask调用:

There is no ACL field in the StartSpeechSynthesisTask call:

$result = $client->startSpeechSynthesisTask([
    'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR',
    'LexiconNames' => ['<string>', ...],
    'OutputFormat' => 'json|mp3|ogg_vorbis|pcm', // REQUIRED
    'OutputS3BucketName' => '<string>', // REQUIRED
    'OutputS3KeyPrefix' => '<string>',
    'SampleRate' => '<string>',
    'SnsTopicArn' => '<string>',
    'SpeechMarkTypes' => ['<string>', ...],
    'Text' => '<string>', // REQUIRED
    'TextType' => 'ssml|text',
    'VoiceId' => 'Aditi|Amy|Astrid|Bianca|Brian|Carla|Carmen|Celine|Chantal|Conchita|Cristiano|Dora|Emma|Enrique|Ewa|Filiz|Geraint|Giorgio|Gwyneth|Hans|Ines|Ivy|Jacek|Jan|Joanna|Joey|Justin|Karl|Kendra|Kimberly|Lea|Liv|Lotte|Lucia|Mads|Maja|Marlene|Mathieu|Matthew|Maxim|Mia|Miguel|Mizuki|Naja|Nicole|Penelope|Raveena|Ricardo|Ruben|Russell|Salli|Seoyeon|Takumi|Tatyana|Vicki|Vitoria|Zeina|Zhiyu', // REQUIRED
]);

因此,您将需要再次调用Amazon S3来更改对象的ACL,或使用Amazon S3 Bucket Policy 来创建存储桶(或存储桶中的路径)公开的.

Therefore, you will either need to make another call to Amazon S3 to change the ACL of the object, or use an Amazon S3 Bucket Policy to make the bucket (or a path within the bucket) public.

输出位置在OutputUri字段中给出( NOT OutputUrl-URI vs URL).

The output location is given in the OutputUri field (NOT OutputUrl -- URI vs URL).

这篇关于将AWS Polly mp3文件保存到S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆