Skip to content

Commit

Permalink
Merge pull request #39 from Chipsnet/Chipsnet/issue37
Browse files Browse the repository at this point in the history
  • Loading branch information
Chipsnet authored Feb 16, 2022
2 parents 6b9f9bb + 84e52d6 commit 422805b
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions softalk.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const { execFileSync } = require('child_process');
const { execFile } = require('child_process');
const chokidar = require('chokidar');
const Encoding = require('encoding-japanese');

Expand All @@ -19,27 +19,23 @@ module.exports = class {

toString(bytes) {
return Encoding.convert(bytes, {
from: 'SJIS',
to: 'UNICODE',
type: 'string',
from: 'SJIS',
to: 'UNICODE',
type: 'string',
});
}

async createVoice(message) {
this.log.debug("🎤 Softalkで音声を生成します:", message);

execFileSync("./softalk/SofTalk.exe", ["/NM:女性01", `/R:${__dirname}\\voice.wav`, "/T:0", "/X:1", "/V:100", `/W:${message}`], { encoding: "Shift_JIS" }, (error, stdout, stderr) => {
log.debug("execfile 終了")
execFile(`${__dirname}/softalk/SofTalk.exe`, ["/NM:女性01", `/R:${__dirname}\\voice.wav`, "/T:0", "/X:1", "/V:100", `/W:${message}`], { shell: true }, (error, stdout, stderr) => {
if (error) {
log.error("An error occurred while running Softalk.\n" + toString(stderr));
if (readMessages.length) {
canReadMessage = true;
} else {
softalk();
}
this.log.error(error);
return;
}
})
});

this.log.debug("📌 音声生成コマンドを実行しました")

let waitVoiceCreate = new Promise((resolve, reject) => {
let watcher = chokidar.watch('./voice.wav');
Expand Down

0 comments on commit 422805b

Please sign in to comment.