Skip to content

Instantly share code, notes, and snippets.

@vashisth00
Forked from NamasteProgrammingYouTube/speech-synth.js
Last active July 27, 2020 09:52
Show Gist options
  • Save vashisth00/c5f02b71afb539e490509d83b30410de to your computer and use it in GitHub Desktop.
Save vashisth00/c5f02b71afb539e490509d83b30410de to your computer and use it in GitHub Desktop.
const AWS = require('aws-sdk')
const fs = require('fs')
const Polly = new AWS.Polly({
region: 'ap-south-1'
})
const input = {
Text: "Hola, Buenas dias.",
OutputFormat: "ogg",
VoiceId: "Alex",
LanguageCode: "es-ES"
}
Polly.synthesizeSpeech(input, (err, data) => {
if (err) {
console.log(err)
return
}
if (data.AudioStream instanceof Buffer) {
fs.writeFile('hello.ogg', data.AudioStream, (fsErr) => {
if (fsErr) {
console.error(fsErr)
return
}
console.log('Success')
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment