Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const saveSpeechLocally = text => getSpeech(text).then(saveSpeech)
- const getSpeech = text => {
- const Text = cleanText(text)
- const OutputFormat = 'mp3'
- const VoiceId = 'Kimberly'
- const params = { Text, OutputFormat, VoiceId }
- return polly.synthesizeSpeechAsync(params)
- }
- const saveSpeech = ({ AudioStream }) => {
- const fileName = './audios/' + new Date().getTime() + '.mp3'
- return fs.writeFileAsync(fileName, AudioStream)
- .then(() => fileName)
- }
Add Comment
Please, Sign In to add comment