404 for Polly mp3 generated into s3 bucket

0

I think this might be an issue with S3 Access rights/permissions, but I am lost as to how to proceed.

I create a mp3 file with this: $result_audio = $client->startSpeechSynthesisTask([ 'Engine' => 'standard', 'OutputFormat' => 'mp3', 'OutputS3BucketName' => 'BUCKET', 'Text' => $chunk_text, 'VoiceId' => $row_data['cv_service_id'] ]);

$s3KeyName = substr($result_audio['SynthesisTask']['OutputUri'], 43);

$s3->copyObject([ 'Bucket' => 'BUCKET', 'Key' => urlencode($new_id.'.mp3'), 'CopySource' => "BUCKET/".urlencode($s3KeyName), ]);

I replaced my bucket with BUCKET for this post.

I get a 404 not found on the copy object, even though I have double checked that the temp file is created. It is auto generated by Amazon Polly and I cannot change the way it is saved. It does not contain anything I think needs to be urlencoded, but I added that to make sure.

An example of the $s3KeyName: 3b7901d6-52af-44ce-9993-b2f805153e85.mp3

I have used the Policy simulator to check that the IAM user credentials have access: https://policysim.aws.amazon.com/home/index.jsp I checked the following permissions: S3 DeleteObject GetObject PutObject GetObjectTagging PutObjectTagging PutObject ListAllMyBuckets

s3express CreateSession

I have granted the IAM user full access to s3 and s3 express, but still nothing changes. I do have the bucket set to prevent public access with all options checked, but I don't think that should stop an authenticated IAM user?

There is no way to set the filename when creating an Amazon Polly mp3 file with startSpeechSynthesisTask, right?

Any guidance what I should do?

anet
asked 3 months ago119 views
1 Answer
1

The startSpeechSynthesisTask creates an asynchronous synthesis task. Therefore, immediately after startSpeechSynthesisTask is executed, the audio file may not be ready.

You may want to use the getSpeechSynthesisTask to wait until the TaskStatus becomes completed.

https://docs.aws.amazon.com/polly/latest/dg/API_StartSpeechSynthesisTask.html https://docs.aws.amazon.com/polly/latest/dg/API_GetSpeechSynthesisTask.html

profile picture
EXPERT
shibata
answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions