Add full STT LLM TTS test mode

This commit is contained in:
2026-05-03 21:54:51 +09:00
parent a5f47393ee
commit 99857cdaa8
8 changed files with 419 additions and 67 deletions

View File

@@ -11,12 +11,12 @@ import { OllamaLlmService } from "./services/ollama-llm.js";
const mode = process.argv[2] ?? "test-stt";
async function runSttTest(enableLlm: boolean): Promise<void> {
async function runSttTest(options: { enableLlm: boolean; enableTts: boolean }): Promise<void> {
const config = loadConfig();
const logger = new Logger(config.DEBUG ? config.LOG_LEVEL : "error");
const stt = new FasterWhisperSttService(config, logger);
const llm = enableLlm ? new OllamaLlmService(config, logger) : null;
let tts = enableLlm && config.TTS_ENABLED ? new MeloTtsService(config, logger) : null;
const llm = options.enableLlm ? new OllamaLlmService(config, logger) : null;
let tts = options.enableTts && config.TTS_ENABLED ? new MeloTtsService(config, logger) : null;
let capture = null as ReturnType<typeof spawnLoopbackCapture> | null;
let shuttingDown: Promise<void> | null = null;
let suppressCapture = false;
@@ -47,6 +47,11 @@ async function runSttTest(enableLlm: boolean): Promise<void> {
await stt.destroy().catch((destroyError) => {
logger.warn("STT destroy failed", destroyError);
});
if (tts) {
await tts.destroy().catch((destroyError) => {
logger.warn("TTS destroy failed", destroyError);
});
}
})();
await shuttingDown;
@@ -70,6 +75,9 @@ async function runSttTest(enableLlm: boolean): Promise<void> {
capture.kill("SIGKILL");
}
void stt.destroy();
if (tts) {
void tts.destroy();
}
});
console.log("STT 준비중...");
@@ -282,14 +290,23 @@ async function runSttTest(enableLlm: boolean): Promise<void> {
});
if (config.DEBUG) {
console.log(enableLlm ? "실시간 출력장치 STT+LLM 테스트를 시작합니다. Ctrl+C 로 종료합니다." : "실시간 출력장치 STT 테스트를 시작합니다. Ctrl+C 로 종료합니다.");
if (options.enableLlm && options.enableTts) {
console.log("실시간 출력장치 STT+LLM+TTS 테스트를 시작합니다. Ctrl+C 로 종료합니다.");
} else if (options.enableLlm) {
console.log("실시간 출력장치 STT+LLM 테스트를 시작합니다. Ctrl+C 로 종료합니다.");
} else {
console.log("실시간 출력장치 STT 테스트를 시작합니다. Ctrl+C 로 종료합니다.");
}
console.log(`source: ${config.AUDIO_SOURCE ?? "unset"}`);
console.log(`model: ${config.WHISPER_MODEL}`);
console.log(`language: ${config.WHISPER_LANGUAGE}`);
console.log(`beam: ${config.WHISPER_BEAM_SIZE}`);
if (enableLlm) {
if (options.enableLlm) {
console.log(`llm: ${config.OLLAMA_MODEL}`);
}
if (options.enableTts) {
console.log(`tts: ${config.TTS_IMAGE}`);
}
}
setInterval(() => {
@@ -385,10 +402,13 @@ async function main(): Promise<void> {
await printAudioDevices();
return;
case "test-stt":
await runSttTest(false);
await runSttTest({ enableLlm: false, enableTts: false });
return;
case "test-sttllm":
await runSttTest(true);
await runSttTest({ enableLlm: true, enableTts: false });
return;
case "test-all":
await runSttTest({ enableLlm: true, enableTts: true });
return;
case "test-llm":
await runLlmCli();
@@ -397,7 +417,7 @@ async function main(): Promise<void> {
await runTtsTest();
return;
default:
throw new Error(`알 수 없는 실행 모드입니다: ${mode}. 사용 가능: test-stt, test-sttllm, test-llm, test-tts, devices`);
throw new Error(`알 수 없는 실행 모드입니다: ${mode}. 사용 가능: test-stt, test-sttllm, test-all, test-llm, test-tts, devices`);
}
}