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.put_lexicon.complete]
// snippet-start:[polly.php.put_lexicon.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.put_lexicon.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.put_lexicon.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
$name = 'lexiconName' ;
$PLS = '
2018-12-17 08:55:01 -08:00
<lexicon version="1.0"
xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon
http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd"
alphabet="ipa"
xml:lang="en-US">
<lexeme>
<grapheme>W3C</grapheme>
<alias>World Wide Web Consortium</alias>
</lexeme>
</lexicon>' ;
2024-02-05 10:49:20 -07:00
2018-12-17 00:52:09 -08:00
try {
$result = $client -> putLexicon ([
'Name' => $name ,
'Content' => $PLS ,
]);
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.put_lexicon.main]
// snippet-end:[polly.php.put_lexicon.complete]