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() {
|
2021-04-06 23:36:35 +00:00
|
|
|
super('ESpeak', 'wav')
|
2021-04-06 00:16:09 +00:00
|
|
|
}
|
2021-04-06 23:33:47 +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']);
|
2021-04-06 10:46:11 +00:00
|
|
|
proc.stdin.end(text);
|
2021-04-06 00:16:09 +00:00
|
|
|
}
|
|
|
|
}
|