Search code examples
aws-php-sdkamazon-transcribe

How to transcribe a call with AWS transcribe API?


I got this error when I'm trying to transcribe a call:

Account isn't authorized to call this operation. Check your account perm

I think the bad property is DataAccessRoleArn, I tried to create new role on IAM console, but it does not work.

Here's the full PHP code:

<?php
require 'vendor/autoload.php';

use Aws\TranscribeService\TranscribeServiceClient;

$awsKey = "{awsKey}";
$awsSecretKey = "{awsSecretKey}";

$clientAWS = new TranscribeServiceClient([
    'region' => 'eu-west-3',
    'version' => 'latest',
    'credentials' => [
        'key' => $awsKey,
        'secret' => $awsSecretKey
    ],
]);

$result = $clientAWS->startCallAnalyticsJob([
    'CallAnalyticsJobName' => 'Transcript1', // REQUIRED
    'ChannelDefinitions' => [
        [
            'ChannelId' => 0,
            'ParticipantRole' => 'AGENT',
        ],
        [
            'ChannelId' => 1,
            'ParticipantRole' => 'CUSTOMER',
        ]
    ],
    'DataAccessRoleArn' => 'arn:aws:iam::{id}:role/AWSRole', // REQUIRED
    'Media' => [ // REQUIRED
        'MediaFileUri' => 's3://{bucketName}/2022/02/23/file.wav',
        'RedactedMediaFileUri' => 's3://{bucketName}/2022/02/23/',
    ],
    'Settings' => [
        'ContentRedaction' => [
            'RedactionOutput' => 'redacted', // REQUIRED
            'RedactionType' => 'PII', // REQUIRED
        ],
    ],
]);

print_r($result);

Do you know how to fix role issue?


Solution

  • For fixing this issue, you have to:

    • Select a region compatible (in my case eu-central-1)

    • Create a new role with AmazonS3FullAccess policy (just for testing, adjust for security) and this trust entity:

      { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "transcribe.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }

    • Attach AmazonTranscribeFullAccess and AmazonS3FullAccess policiy to your IAM user (just for testing, adjust for security)