Guest User

Untitled

a guest
Mar 18th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. const saveSpeechLocally = text => getSpeech(text).then(saveSpeech)
  2.  
  3. const getSpeech = text => {
  4. const Text = cleanText(text)
  5. const OutputFormat = 'mp3'
  6. const VoiceId = 'Kimberly'
  7. const params = { Text, OutputFormat, VoiceId }
  8. return polly.synthesizeSpeechAsync(params)
  9. }
  10.  
  11. const saveSpeech = ({ AudioStream }) => {
  12. const fileName = './audios/' + new Date().getTime() + '.mp3'
  13. return fs.writeFileAsync(fileName, AudioStream)
  14. .then(() => fileName)
  15. }
Add Comment
Please, Sign In to add comment