From 751169748d3c31638367c113bef024b3ce1b55cb Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sat, 3 Apr 2021 11:16:56 -0400 Subject: [PATCH] Fix --- commands/voice/dec-talk.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/commands/voice/dec-talk.js b/commands/voice/dec-talk.js index 11abaf35..4bf3ee73 100644 --- a/commands/voice/dec-talk.js +++ b/commands/voice/dec-talk.js @@ -69,16 +69,18 @@ module.exports = class DECTalkCommand extends Command { } async tts(id, input) { - await writeFile(path.join(__dirname, '..', '..', 'tmp', `${id}.txt`), input); - await execAsync(`xvfb-run wine say.exe -w ${id}.wav < ${path.join(__dirname, '..', '..', 'tmp', `${id}.txt`)}`, { + const inputFile = path.join(__dirname, '..', '..', 'tmp', `${id}.txt`); + await writeFile(inputFile, input); + const outputFile = path.join(__dirname, '..', '..', 'tmp', `${id}.wav`); + await execAsync(`xvfb-run wine say.exe -w ${outputFile} < ${inputFile}`, { cwd: path.join(__dirname, '..', '..', 'dectalk'), timeout: 30000 }); let result; try { - result = await readFile(path.join(__dirname, '..', '..', 'tmp', `${id}.wav`)); - await unlink(path.join(__dirname, '..', '..', 'tmp', `${id}.txt`)); - await unlink(path.join(__dirname, '..', '..', 'tmp', `${id}.wav`)); + result = await readFile(outputFile); + await unlink(inputFile); + await unlink(outputFile); } catch { if (!result) result = null; }