tardis-bot/tts/espeak/index.js

15 lines
415 B
JavaScript
Raw Normal View History

2021-04-06 23:36:35 +00:00
const BaseEngine = require('../BaseEngine')
const { spawn } = require('child_process')
2021-04-06 00:16:09 +00:00
2021-04-06 23:36:35 +00:00
module.exports = class extends BaseEngine {
2021-04-06 00:16:09 +00:00
constructor() {
super('espeak','ESpeak', 'wav')
2021-04-06 00:16:09 +00:00
}
getDefaultVoice() {
return 'en';
}
2021-04-06 23:36:35 +00:00
async getSpeechFile(text, filepath, voice = this.getDefaultVoice(), params = {}) {
let proc = await spawn('espeak', ['-v', voice, '-w', filepath, '--stdin']);
proc.stdin.end(text);
2021-04-06 00:16:09 +00:00
}
}