Fix TTS playback and preinstall mecab
This commit is contained in:
@@ -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 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 /opt/MeloTTS/melo/init_downloads.py
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user