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

@@ -12,6 +12,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN git clone https://github.com/myshell-ai/MeloTTS.git /opt/MeloTTS RUN git clone https://github.com/myshell-ai/MeloTTS.git /opt/MeloTTS
RUN pip install --no-cache-dir -e /opt/MeloTTS RUN pip install --no-cache-dir -e /opt/MeloTTS
RUN pip install --no-cache-dir python-mecab-ko python-mecab-ko-dic
RUN python -m unidic download RUN python -m unidic download
RUN python /opt/MeloTTS/melo/init_downloads.py RUN python /opt/MeloTTS/melo/init_downloads.py

View File

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