Created
December 13, 2016 13:54
-
-
Save anaptfox/6ea8fcf6ae9f3a9617ebc9b3eccbd894 to your computer and use it in GitHub Desktop.
Node.js Amazon Polly to file example.
This file contains hidden or 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
// Load the SDK | |
const AWS = require('aws-sdk') | |
const Fs = require('fs') | |
// Create an Polly client | |
const Polly = new AWS.Polly({ | |
signatureVersion: 'v4', | |
region: 'us-east-1' | |
}) | |
let params = { | |
'Text': 'Hi, my name is @anaptfox.', | |
'OutputFormat': 'mp3', | |
'VoiceId': 'Kimberly' | |
} | |
Polly.synthesizeSpeech(params, (err, data) => { | |
if (err) { | |
console.log(err.code) | |
} else if (data) { | |
if (data.AudioStream instanceof Buffer) { | |
Fs.writeFile("./speech.mp3", data.AudioStream, function(err) { | |
if (err) { | |
return console.log(err) | |
} | |
console.log("The file was saved!") | |
}) | |
} | |
} | |
}) |
@jersonjunior: ssml tags will be accepted if setting 'TextType': 'ssml',
in params. :)
how to get file in wav
format?
I use this:
var output = child_process.execSync('lame --decode ' + argv.mp3 + ' ' + '-b 8000' + ' ' + argv.wav + '.wav');
To convert in wav 8000hz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The sound is very low, I tried to use <prosody volume = + 20dB> Hi, my name is @anaptfox., but it is not accepting the prosody
'Text': 'Hi, my name is @anaptfox.'