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