I am a PHP programmer, and I can't get the AWS Transcribe Service to work.
I need someone to send me a snippet of code that works.
Requirements:
1. Use the AWS SDK for PHP v3
2. Create a new client for the Transcribe service
3. Make a request to the transcribe service
4. Receive a success response as documented on the PHP SDK page for the Transcribe service
Here is the PHP code I have been using, but it fails. It seems to be failing when I create the client using the factory() method. I have tried creating the client in other ways, but it keeps failing.
// AWS SDK (this path is for the ZIP file method of installing the SDK)
require 'vendor/aws/[login to view URL]';
// Transcribe
use Aws\TranscribeService\TranscribeServiceClient;
$transcribeClient = TranscribeClient::factory(
array(
'region' => 'ap-southeast-2',
'version' => '2017-10-26',
'credentials' => array(
'key' => 'yourAccessKeyHere',
'secret' => 'yourSecretKeyHere'
)
)
);
$result = $transcribeClient->startTranscriptionJob([
'LanguageCode' => 'en-AU', //'en-US|es-US|en-AU|fr-CA|en-GB|de-DE|pt-BR|fr-FR|it-IT', // REQUIRED
'Media' => [ // REQUIRED
'MediaFileUri' => 'https://url-to-file-in-S3-bucket',
],
'MediaFormat' => 'mp3', //'mp3|mp4|wav|flac', // REQUIRED
//'MediaSampleRateHertz' => <integer>,
//'OutputBucketName' => '<string>',
//'Settings' => [
// 'ChannelIdentification' => true || false,
// 'MaxSpeakerLabels' => <integer>,
// 'ShowSpeakerLabels' => true || false,
// 'VocabularyName' => '<string>',
//],
'TranscriptionJobName' => 'job-name-here, // REQUIRED
]);
// not sure if we need this here, you *do* need to do this for S3 response, so maybe we need it for Transcribe response.
$result = $result->toArray();
print_r($result);
/*
Response:
$result = [
'TranscriptionJob' => [
'CompletionTime' => <DateTime>,
'CreationTime' => <DateTime>,
'FailureReason' => '<string>',
'LanguageCode' => 'en-US|es-US|en-AU|fr-CA|en-GB|de-DE|pt-BR|fr-FR|it-IT',
'Media' => [
'MediaFileUri' => '<string>',
],
'MediaFormat' => 'mp3|mp4|wav|flac',
'MediaSampleRateHertz' => <integer>,
'Settings' => [
'ChannelIdentification' => true || false,
'MaxSpeakerLabels' => <integer>,
'ShowSpeakerLabels' => true || false,
'VocabularyName' => '<string>',
],
'Transcript' => [
'TranscriptFileUri' => '<string>',
],
'TranscriptionJobName' => '<string>',
'TranscriptionJobStatus' => 'IN_PROGRESS|FAILED|COMPLETED',
],
]
*/