tardis-bot/tts/gtranslate/index.js

16 lines
418 B
JavaScript
Raw Normal View History

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-06 23:36:35 +00:00
super("Google Translate TTS", "mp3");
2021-04-06 00:16:09 +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);
}
};