2018-12-17 00:52:09 -08:00
< ? php
2019-01-02 21:21:22 -08:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2018-12-17 00:52:09 -08:00
// SPDX-License-Identifier: Apache-2.0
2024-02-05 10:49:20 -07:00
2019-01-04 14:55:07 -08:00
// snippet-start:[polly.php.get_speech_task.complete]
// snippet-start:[polly.php.get_speech_task.import]
2024-02-05 10:49:20 -07:00
2018-12-17 00:52:09 -08:00
require 'vendor/autoload.php' ;
2024-02-05 10:49:20 -07:00
2018-12-17 00:52:09 -08:00
use Aws\Exception\AwsException ;
2024-02-05 10:49:20 -07:00
2019-01-04 14:55:07 -08:00
// snippet-end:[polly.php.get_speech_task.import]
2024-02-05 10:49:20 -07:00
2018-12-17 00:52:09 -08:00
/**
* This code expects that you have AWS credentials set up per:
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html
*/
2019-01-17 14:27:30 -08:00
// snippet-start:[polly.php.get_speech_task.main]
2019-01-04 14:55:07 -08:00
// Create a PollyClient
2018-12-17 00:52:09 -08:00
$client = new Aws\Polly\PollyClient ([
2018-12-17 08:55:01 -08:00
'profile' => 'default' ,
2018-12-17 00:52:09 -08:00
'version' => '2016-06-10' ,
2018-12-17 08:55:01 -08:00
'region' => 'us-east-2'
2018-12-17 00:52:09 -08:00
]);
2024-02-05 10:49:20 -07:00
2018-12-17 00:52:09 -08:00
$taskId = 'ab01cd23-ef45-67gh-ij89-ab01cd23ef45' ;
2024-02-05 10:49:20 -07:00
2018-12-17 00:52:09 -08:00
try {
$result = $client -> getSpeechSynthesisTask ([
'TaskId' => $taskId ,
]);
var_dump ( $result );
2018-12-17 08:55:01 -08:00
} catch ( AwsException $e ) {
2018-12-17 00:52:09 -08:00
// output error message if fails
echo $e -> getMessage ();
echo " \n " ;
2019-01-04 14:55:07 -08:00
}
2024-02-05 10:49:20 -07:00
2019-01-04 14:55:07 -08:00
// snippet-end:[polly.php.get_speech_task.main]
// snippet-end:[polly.php.get_speech_task.complete]