веб-сервисы Amazon — AWS Transcribe PHP API 3.0 — Не удается инициализировать API

Я пытаюсь инициализировать API для AWS Transcribe, но документация кажется неясной.

Мой код:

    <?php
require 'aws-api/aws-autoloader.php';
$client = new Aws\TranscribeService\TranscribeServiceClient;

$result = $client->commandName(listTranscriptionJobs([

]));

echo $result;

var_dump($result);

?>

но я получаю PHP Ошибка:

[Mon Aug 13 03:09:02.430628 2018] [:error] [pid 27717] [client 123.123.123.123:29660] PHP Catchable fatal error:  Argument 1 passed to Aws\\AwsClient::__construct() must be of the type array, none given, called in /var/www/example/public_html/wp-content/themes/example/aws-transcribe.php on line 16 and defined in /var/www/example/public_html/wp-content/themes/example/aws-api/Aws/AwsClient.php on line 146, referer: http://example.com/wp-content/themes/xxx/aws-transcribe.php

Я не смог найти фрагмент кода для API Transcribe и не могу понять, что мне не хватает. У кого-нибудь есть код для API транскрипции?

https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-transcribe-2017-10-26.html

0

Решение

Ответом было то, что в нем отсутствовал массив опций региона и версии. Это рабочий код для получения текста транскрипции из API AWS PHP 3.0

function get_transcription($transcription_name){
date_default_timezone_set('America/New_York');
require 'aws-api/aws-autoloader.php';

$transcribe = new Aws\TranscribeService\TranscribeServiceClient([
'region'  => 'us-east-1',
'version' => '2017-10-26'
]);

$result = $transcribe->getTranscriptionJob([
'TranscriptionJobName' => $transcription_name, // REQUIRED
]);


$transcription = $result['TranscriptionJob']['Transcript']['TranscriptFileUri'];

$transcription_download = file_get_contents($transcription);
$transcribe_final = json_decode($transcription_download, true);

$trans = $transcribe_final['results']['transcripts'][0]['transcript'];
echo $trans;
}
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector