-
Notifications
You must be signed in to change notification settings - Fork 6
/
openjtalk.js
32 lines (26 loc) · 1.11 KB
/
openjtalk.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const { execFileSync } = require('child_process');
const iconv = require('iconv-lite');
const fs = require('fs');
module.exports = class {
constructor(log) {
this.log = log.child({ module: 'openjtalk' });
//this.htsvoice = "./openjtalk/voice/hts_voice_nitech_jp_atr503_m001-1.05/nitech_jp_atr503_m001.htsvoice";
this.htsvoice = "./openjtalk/voice/mei/mei_normal.htsvoice";
if (process.platform === 'win32') {
this.dic = "./openjtalk/dic/open_jtalk_dic_shift_jis-1.11"
} else {
this.dic = "./openjtalk/dic/open_jtalk_dic_utf_8-1.11"
}
}
async createVoice(message) {
this.log.debug("📝 input.txtを生成します:", message)
if (process.platform === 'win32') {
fs.writeFileSync('./input.txt', iconv.encode(message, 'shift_jis'));
} else {
fs.writeFileSync('./input.txt', message);
}
execFileSync("open_jtalk", ["-m", this.htsvoice, "-x", this.dic, , "-g", "9", "-ow", "voice.wav", "./input.txt"]);
this.log.debug("🎤 voice.wavを生成しました")
return;
}
}