const BaseEngine=require('../BaseEngine'); const fetch = require('node-fetch'); const querystring = require('querystring'); module.exports= class extends BaseEngine { constructor() { super("IBM Watson TTS","ogg"); this.voices={ 'Michael': 'en-US_MichaelV3Voice', 'Allison': 'en-US_AllisonV3Voice', 'Kevin': 'en-US_KevinV3Voice', }; } getDefaultVoice() { return 'Michael'; } async getSpeech(text, voice=this.getSpeechVoice(), params={}) { const url = process.env.watsonURL+"/v1/synthesize?voice="+this.getInternalVoiceName(voice); let buff=new Buffer('apikey:'+process.env.watsonAPIKey); let b64auth=buff.toString('base64'); const authorization='Basic '+b64auth; const opts={ method: "post", headers: { 'Content-Type': 'application/json', 'Authorization': authorization }, body: JSON.stringify({ text: text }) }; return fetch(url,opts); } };