Split STT-only and STT+LLM test modes

This commit is contained in:
2026-05-03 01:04:31 +09:00
parent c53dcc853d
commit ec02943538
4 changed files with 76 additions and 47 deletions

View File

@@ -10,11 +10,11 @@ import { OllamaLlmService } from "./services/ollama-llm.js";
const mode = process.argv[2] ?? "test-stt";
async function runSttTest(): Promise<void> {
async function runSttTest(enableLlm: boolean): Promise<void> {
const config = loadConfig();
const logger = new Logger(config.DEBUG ? config.LOG_LEVEL : "error");
const stt = new FasterWhisperSttService(config, logger);
const llm = new OllamaLlmService(config, logger);
const llm = enableLlm ? new OllamaLlmService(config, logger) : null;
let capture = null as ReturnType<typeof spawnLoopbackCapture> | null;
let shuttingDown: Promise<void> | null = null;
let receivedChunks = 0;
@@ -69,10 +69,16 @@ async function runSttTest(): Promise<void> {
void stt.destroy();
});
console.log("STT 준비중...");
await stt.warmup();
logger.info("STT warmup finished");
await llm.warmup();
logger.info("LLM warmup finished");
console.log("STT 준비 완료");
if (llm) {
console.log("LLM 준비중...");
await llm.warmup();
logger.info("LLM warmup finished");
console.log("LLM 준비 완료");
}
const transcriptionQueue: Array<{ pcm16: Buffer; queuedAt: number; index: number }> = [];
let transcribing = false;
@@ -108,45 +114,47 @@ async function runSttTest(): Promise<void> {
console.log(`사용자> ${text}`);
}
const assessmentStartedAt = Date.now();
const assessment = await llm.assessReplyNeed(text);
logger.info("Reply assessment", {
index: next.index,
should_reply: assessment.shouldReply,
likely_needs_lookup: assessment.likelyNeedsLookup,
reason: assessment.reason,
assessment_ms: Date.now() - assessmentStartedAt,
});
if (llm) {
const assessmentStartedAt = Date.now();
const assessment = await llm.assessReplyNeed(text);
logger.info("Reply assessment", {
index: next.index,
should_reply: assessment.shouldReply,
likely_needs_lookup: assessment.likelyNeedsLookup,
reason: assessment.reason,
assessment_ms: Date.now() - assessmentStartedAt,
});
if (!assessment.shouldReply) {
if (config.DEBUG) {
console.log(`[skip] ${assessment.reason}\n`);
}
return;
}
const llmStartedAt = Date.now();
const reply = await llm.generateReply(text, {
onProgress: (message) => {
if (!assessment.shouldReply) {
if (config.DEBUG) {
console.log(`[assistant] ${message}`);
return;
console.log(`[skip] ${assessment.reason}\n`);
}
console.log(`답변> ${message}`);
},
});
logger.info("LLM latency", {
index: next.index,
llm_ms: Date.now() - llmStartedAt,
});
logger.info("LLM reply", { index: next.index, text: reply });
if (config.DEBUG) {
if (config.DEBUG_TRANSCRIPTS) {
console.log(`[assistant] ${reply}\n`);
return;
}
const llmStartedAt = Date.now();
const reply = await llm.generateReply(text, {
onProgress: (message) => {
if (config.DEBUG) {
console.log(`[assistant] ${message}`);
return;
}
console.log(`답변> ${message}`);
},
});
logger.info("LLM latency", {
index: next.index,
llm_ms: Date.now() - llmStartedAt,
});
logger.info("LLM reply", { index: next.index, text: reply });
if (config.DEBUG) {
if (config.DEBUG_TRANSCRIPTS) {
console.log(`[assistant] ${reply}\n`);
}
} else {
console.log(`답변> ${reply}`);
}
} else {
console.log(`답변> ${reply}`);
}
}
} catch (error) {
@@ -238,11 +246,14 @@ async function runSttTest(): Promise<void> {
});
if (config.DEBUG) {
console.log("실시간 출력장치 STT 테스트를 시작합니다. Ctrl+C 로 종료합니다.");
console.log(enableLlm ? "실시간 출력장치 STT+LLM 테스트를 시작합니다. Ctrl+C 로 종료합니다." : "실시간 출력장치 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) {
console.log(`llm: ${config.OLLAMA_MODEL}`);
}
}
setInterval(() => {
@@ -325,13 +336,16 @@ async function main(): Promise<void> {
await printAudioDevices();
return;
case "test-stt":
await runSttTest();
await runSttTest(false);
return;
case "test-sttllm":
await runSttTest(true);
return;
case "test-llm":
await runLlmCli();
return;
default:
throw new Error(`알 수 없는 실행 모드입니다: ${mode}. 사용 가능: test-stt, test-llm, devices`);
throw new Error(`알 수 없는 실행 모드입니다: ${mode}. 사용 가능: test-stt, test-sttllm, test-llm, devices`);
}
}

View File

@@ -376,6 +376,7 @@ export class OllamaLlmService {
"bun run setup:llm",
"bun run devices",
"bun run test:stt",
"bun run test:sttllm",
"bun run test:llm",
],
};