2021-04-06 00:16:09 +00:00
|
|
|
const BaseEngine=require('../BaseEngine');
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
const tts = require('google-tts-api');
|
|
|
|
|
|
|
|
module.exports= class extends BaseEngine {
|
|
|
|
constructor() {
|
|
|
|
super("Google Translate TTS","mp3");
|
|
|
|
}
|
2021-04-06 23:33:47 +00:00
|
|
|
getDefaultVoice() {
|
|
|
|
return 'en-us';
|
|
|
|
}
|
|
|
|
async getSpeech(text, voice=this.getDefaultVoice(), params={}) {
|
2021-04-06 00:16:09 +00:00
|
|
|
const url = tts.getAudioUrl(text, {lang: voice});
|
|
|
|
return fetch(url);
|
|
|
|
}
|
|
|
|
};
|