小编Jay*_*ali的帖子

使用PHP SDK的Amazon Polly实施

我正在尝试使用Amazon的PHP SDK将Amazon Polly Web服务集成到我的一个项目中。但是,当我使用PollyClient SDK时,客户端中仅实现一种方法createSynthesizeSpeechPreSignedUrl(),它返回url,而不返回音频剪辑。当我尝试将URL粘贴到浏览器窗口中时,出现以下错误:"message": "The security token included in the request is invalid."

请查看我的代码段:

error_reporting(E_ALL);
ini_set('display_errors', 1);
header('Content-Type: text/plain; charset=utf-8');
require_once 'app/aws/aws-autoloader.php';
use Aws\Polly\PollyClient;

class TestPolly extends Base {
    public function newPolly () {
        $connection = [
            'region'      => 'us-west-2',
            'version'     => 'latest',
            'debug'       => true,
            'scheme'      => 'http',
            'credentials' => [
                'key'    => 'XXXXX',
                'secret' => 'XXXXXX',
            ],
        ];
        $client     = new PollyClient($connection);
        $polly_args = [
            'OutputFormat' => 'mp3',
            'Text'         => 'My Input text',
            'TextType' …
Run Code Online (Sandbox Code Playgroud)

php sdk amazon-web-services amazon-polly

3
推荐指数
1
解决办法
3620
查看次数

标签 统计

amazon-polly ×1

amazon-web-services ×1

php ×1

sdk ×1