【问题标题】:AWS Transcribe PHP API 3.0 - Can't Initialize APIAWS Transcribe PHP API 3.0 - 无法初始化 API
【发布时间】:2018-08-13 12:54:43
【问题描述】:

我正在尝试为 AWS Transcribe 初始化 API,但文档似乎并不清晰。

我的代码是:

    <?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

我无法找到 Transcribe API 的代码 sn-p 并且无法弄清楚我缺少什么。谁有 Transcription API 的代码?

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

【问题讨论】:

    标签: php amazon-web-services aws-transcribe


    【解决方案1】:

    这个问题的答案是它缺少区域和版本的选项数组。这是从 AWS PHP 3.0 API 获取转录文本的工作代码

    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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-13
      • 1970-01-01
      • 2022-09-24
      • 1970-01-01
      相关资源
      最近更新 更多