AWS Polly Integration


#1

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


#2

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


#3

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


#4

I have successfully implemented with Asterisk the following TTS

http://tts.readspeaker.com/

voicerss.org

http://tts.readspeaker.com/


#5

how was voice quality??


#6

They have online demo, you can evaluate it your self


#7

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


#8
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;



?>

#9

Thanks a ton…actually I am very new in asterisk

exten => 6656,1,NoOp()
same => n,Answer()
same => n,playback(greet)
same => n,Set(foo=${CURL(http://api.voicerss.org/?key=1d7239b16807498889cb40989d871498&hl=en-us&src=Hello, world!)})
same => n,Hangup()

will it work…it gave me return ID3


#10

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


#11

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’);

    })
}

}
})


#12

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