AWS Polly Integration

Can anybody help me with the AWS Polly TTS integration with asterisk, I am using festival however voice quality is not good.

Asterisk integration with an external TTS provider is one of the easiest thing on the world , as far as you can handle the TTS API, the goal is convert the text in a sound file with a format who asterisk , related to the Polly I suggest you use their documentation, polly API it is outside the scope of support on this forum

Thanks a lot…can you please suggest me any third party API

I have successfully implemented with Asterisk the following TTS

http://tts.readspeaker.com/

voicerss.org

http://tts.readspeaker.com/

how was voice quality??

They have online demo, you can evaluate it your self

Can you share me the syntex of dialplan as well where you have used VoiceRSS api

exten=>_091,1,Answer()
same=>n,Set(voicercode=en-us)
same=>n,Set(__translated="Hello world")
same=>n,system(php /var/www/html/tts/voicerss1.php "${translated}" ${UNIQUEID} "${voicercode}")
same=>n,Playback(/var/www/html/tts/${UNIQUEID})

php voicerss1.php code

<?php
//en-us fr-fr es-es es-mx
$message=rawurlencode($argv[1]); //convert spaces if not   wont work
$api="000000001110119";
$lang="en-us";
$type="WAV";
$format="8khz_16bit_mono";
$name=$argv[2];
$url=shell_exec(" curl -o /var/www/html/tts/$name.wav -G -d\"key=$api&hl=$lang&c=$type&f=$format&src=$message\" http://api.voicerss.org");
echo $url;



?>

I gave you a working example you re free to modify it based on your needs, what you are doing wont work , you need to Write output to instead of stdout, if you re new with Asterisk I suggest start learning how Asterisk curl command work and then you can move foward

Easy with Polly:

Sample project to demonstrate usage of the AWS SDK for Node.js:

cd /opt/
git clone https://github.com/awslabs/aws-nodejs-sample
cd aws-nodejs-sample
npm install
npm install optimist
npm install child_process
vim script.js

// Load the SDK
var argv = require(‘optimist’).argv;
const AWS = require(‘aws-sdk’)
const Fs = require(‘fs’)
var child_process = require(‘child_process’);
// Create an Polly client
const Polly = new AWS.Polly({
accessKeyId: “accessKeyId here”,
secretAccessKey: “secretAccesKey here”,
signatureVersion: ‘v4’,
region: ‘us-east-1’

})

let params = {
‘Text’: argv.text,
// ‘Text’: ‘Tatiana’,
‘OutputFormat’: ‘mp3’,
‘SampleRate’: ‘8000’,
‘VoiceId’: ‘Vitoria’
}

Polly.synthesizeSpeech(params, (err, data) => {
if (err) {
console.log(err.code)
} else if (data) {
if (data.AudioStream instanceof Buffer) {
Fs.writeFile(argv.mp3, data.AudioStream, function(err) {
if (err) {
return console.log(err)
}
console.log(“The file was saved!”)
var output = child_process.execSync('lame --decode ’ + argv.mp3 + ’ ’ + ‘-b 8000’ + ’ ’ + argv.wav + ‘.wav’);

    })
}

}
})

Hi…
i’m not quite comfortable with node.js…but i’m trying…even for ARI implementation…
Can you give further details about TTS Polly implementation…how do i call inside Asterisk?
And so on…
Thanks