PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / Polly / PollyClient.php
transferito / vendor / aws / aws-sdk-php / src / Polly Last commit date
Exception 11 months ago PollyClient.php 11 months ago
PollyClient.php
74 lines
1 <?php
2 namespace Aws\Polly;
3
4 use Aws\Api\Serializer\JsonBody;
5 use Aws\AwsClient;
6 use Aws\Signature\SignatureV4;
7 use GuzzleHttp\Psr7\Request;
8 use GuzzleHttp\Psr7\Uri;
9 use GuzzleHttp\Psr7;
10
11 /**
12 * This client is used to interact with the **Amazon Polly** service.
13 * @method \Aws\Result deleteLexicon(array $args = [])
14 * @method \GuzzleHttp\Promise\Promise deleteLexiconAsync(array $args = [])
15 * @method \Aws\Result describeVoices(array $args = [])
16 * @method \GuzzleHttp\Promise\Promise describeVoicesAsync(array $args = [])
17 * @method \Aws\Result getLexicon(array $args = [])
18 * @method \GuzzleHttp\Promise\Promise getLexiconAsync(array $args = [])
19 * @method \Aws\Result getSpeechSynthesisTask(array $args = [])
20 * @method \GuzzleHttp\Promise\Promise getSpeechSynthesisTaskAsync(array $args = [])
21 * @method \Aws\Result listLexicons(array $args = [])
22 * @method \GuzzleHttp\Promise\Promise listLexiconsAsync(array $args = [])
23 * @method \Aws\Result listSpeechSynthesisTasks(array $args = [])
24 * @method \GuzzleHttp\Promise\Promise listSpeechSynthesisTasksAsync(array $args = [])
25 * @method \Aws\Result putLexicon(array $args = [])
26 * @method \GuzzleHttp\Promise\Promise putLexiconAsync(array $args = [])
27 * @method \Aws\Result startSpeechSynthesisTask(array $args = [])
28 * @method \GuzzleHttp\Promise\Promise startSpeechSynthesisTaskAsync(array $args = [])
29 * @method \Aws\Result synthesizeSpeech(array $args = [])
30 * @method \GuzzleHttp\Promise\Promise synthesizeSpeechAsync(array $args = [])
31 */
32 class PollyClient extends AwsClient
33 {
34 /** @var JsonBody */
35 private $formatter;
36
37 /**
38 * Create a pre-signed URL for Polly operation `SynthesizeSpeech`
39 *
40 * @param array $args parameters array for `SynthesizeSpeech`
41 * More information @see Aws\Polly\PollyClient::SynthesizeSpeech
42 *
43 * @return string
44 */
45 public function createSynthesizeSpeechPreSignedUrl(array $args)
46 {
47 $uri = new Uri($this->getEndpoint());
48 $uri = $uri->withPath('/v1/speech');
49
50 // Formatting parameters follows rest-json protocol
51 $this->formatter = $this->formatter ?: new JsonBody($this->getApi());
52 $queryArray = json_decode(
53 $this->formatter->build(
54 $this->getApi()->getOperation('SynthesizeSpeech')->getInput(),
55 $args
56 ),
57 true
58 );
59
60 // Mocking a 'GET' request in pre-signing the Url
61 $query = Psr7\Query::build($queryArray);
62 $uri = $uri->withQuery($query);
63
64 $request = new Request('GET', $uri);
65 $request = $request->withBody(Psr7\Utils::streamFor(''));
66 $signer = new SignatureV4('polly', $this->getRegion());
67 return (string) $signer->presign(
68 $request,
69 $this->getCredentials()->wait(),
70 '+15 minutes'
71 )->getUri();
72 }
73 }
74