Fix TTS playback and preinstall mecab

This commit is contained in:
2026-05-03 17:56:42 +09:00
parent caae552d47
commit 46a6b926df
2 changed files with 10 additions and 4 deletions

View File

@@ -1,11 +1,12 @@
import { spawn } from "node:child_process";
import process from "node:process";
async function run(command: string, args: string[]): Promise<void> {
async function run(command: string, args: string[], env?: NodeJS.ProcessEnv): Promise<void> {
await new Promise<void>((resolve, reject) => {
const child = spawn(command, args, {
stdio: ["ignore", "inherit", "inherit"],
windowsHide: true,
env,
});
child.on("error", reject);
@@ -21,6 +22,11 @@ async function run(command: string, args: string[]): Promise<void> {
export async function playWavFile(filePath: string): Promise<void> {
if (process.platform === "win32") {
const env = {
...process.env,
TTS_WAV_PATH: filePath,
};
await run("powershell.exe", [
"-NoProfile",
"-NonInteractive",
@@ -28,13 +34,12 @@ export async function playWavFile(filePath: string): Promise<void> {
"Bypass",
"-Command",
[
"$path = $args[0]",
"$path = $env:TTS_WAV_PATH",
"$player = New-Object System.Media.SoundPlayer $path",
"$player.Load()",
"$player.PlaySync()",
].join("; "),
filePath,
]);
], env);
return;
}