samruddha

text2speech

Dec 14th, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. var TextToSpeechV1 = require('watson-developer-cloud/text-to-speech/v1');
  2. var fs = require('fs');
  3.  
  4. var text_to_speech = new TextToSpeechV1 ({
  5. username: '{username}',
  6. password: '{password}'
  7. });
  8.  
  9. var params = {
  10. text: 'Hello world',
  11. voice: 'en-US_AllisonVoice',
  12. accept: 'audio/wav'
  13. };
  14.  
  15. // Pipe the synthesized text to a file.
  16. text_to_speech.synthesize(params).on('error', function(error) {
  17. console.log('Error:', error);
  18. }).pipe(fs.createWriteStream('hello_world.wav'));
Add Comment
Please, Sign In to add comment