Created
April 2, 2021 11:04
-
-
Save coder618/968cbde3e0bfd954dcab8c69eb5ed24c to your computer and use it in GitHub Desktop.
Amazon polly API with Dutch Language (PHP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// require_once 'app/aws/aws-autoloader.php'; | |
require 'vendor/autoload.php'; | |
$awsAccessKeyId = '-----'; | |
$awsSecretKey = '-----'; | |
$credentials = new \Aws\Credentials\Credentials($awsAccessKeyId, $awsSecretKey); | |
$client = new \Aws\Polly\PollyClient([ | |
'version' => '2016-06-10', | |
'credentials' => $credentials, | |
'region' => 'us-east-1', | |
]); | |
$result = $client->synthesizeSpeech([ | |
'OutputFormat' => 'mp3', | |
'Text' => "A. D", | |
'TextType' => 'text', | |
'VoiceId' => 'Lotte', | |
'LanguageCode' => 'nl-NL' | |
]); | |
$resultData = $result->get('AudioStream')->getContents(); | |
header('Content-Transfer-Encoding: binary'); | |
header('Content-Type: audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3'); | |
header('Content-length: ' . strlen($resultData)); | |
header('Content-Disposition: attachment; filename="pollyTTS.mp3"'); | |
header('X-Pad: avoid browser bug'); | |
header('Cache-Control: no-cache'); | |
echo $resultData; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment