Add local TTS smoke test mode
This commit is contained in:
@@ -65,6 +65,12 @@ bun run devices
|
|||||||
bun run start:local
|
bun run start:local
|
||||||
```
|
```
|
||||||
|
|
||||||
|
TTS만 단독으로 확인:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bun run tts:test -- "안녕하세요. 출력 장치 테스트입니다."
|
||||||
|
```
|
||||||
|
|
||||||
Discord 모드:
|
Discord 모드:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
"start": "bun src/index.ts discord",
|
"start": "bun src/index.ts discord",
|
||||||
"start:discord": "bun src/index.ts discord",
|
"start:discord": "bun src/index.ts discord",
|
||||||
"start:local": "bun src/index.ts local",
|
"start:local": "bun src/index.ts local",
|
||||||
|
"tts:test": "bun src/index.ts local-say",
|
||||||
"setup:local-ai": "bun src/setup-local-ai.ts",
|
"setup:local-ai": "bun src/setup-local-ai.ts",
|
||||||
"devices": "bun src/index.ts local-devices",
|
"devices": "bun src/index.ts local-devices",
|
||||||
"audio:devices": "bun src/index.ts local-devices",
|
"audio:devices": "bun src/index.ts local-devices",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import process from "node:process";
|
|||||||
import { loadConfig, requireAssistantRuntimeConfig, requireDiscordRuntimeConfig } from "./config.js";
|
import { loadConfig, requireAssistantRuntimeConfig, requireDiscordRuntimeConfig } from "./config.js";
|
||||||
import { runDiscordBot } from "./discord-main.js";
|
import { runDiscordBot } from "./discord-main.js";
|
||||||
import { Logger } from "./logger.js";
|
import { Logger } from "./logger.js";
|
||||||
import { printLocalAudioDevices, runLocalAssistant } from "./local-main.js";
|
import { printLocalAudioDevices, runLocalAssistant, runLocalTtsSmokeTest } from "./local-main.js";
|
||||||
|
|
||||||
const mode = process.argv[2] ?? "discord";
|
const mode = process.argv[2] ?? "discord";
|
||||||
const config = loadConfig();
|
const config = loadConfig();
|
||||||
@@ -20,8 +20,13 @@ async function main(): Promise<void> {
|
|||||||
case "local-devices":
|
case "local-devices":
|
||||||
await printLocalAudioDevices();
|
await printLocalAudioDevices();
|
||||||
return;
|
return;
|
||||||
|
case "local-say": {
|
||||||
|
const text = process.argv.slice(3).join(" ").trim() || "안녕하세요. TTS 단독 재생 테스트입니다.";
|
||||||
|
await runLocalTtsSmokeTest(requireAssistantRuntimeConfig(config), logger, text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw new Error(`알 수 없는 실행 모드입니다: ${mode}. 사용 가능: discord, local, local-devices`);
|
throw new Error(`알 수 없는 실행 모드입니다: ${mode}. 사용 가능: discord, local, local-devices, local-say`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import type { AssistantRuntimeConfig } from "./config.js";
|
|||||||
import { Logger } from "./logger.js";
|
import { Logger } from "./logger.js";
|
||||||
import { LocalVoiceSession } from "./audio/local-voice-session.js";
|
import { LocalVoiceSession } from "./audio/local-voice-session.js";
|
||||||
import { requireFfmpegPath } from "./audio/ffmpeg-path.js";
|
import { requireFfmpegPath } from "./audio/ffmpeg-path.js";
|
||||||
|
import type { LlmService } from "./services/llm.js";
|
||||||
import { LocalFasterWhisperSttService } from "./services/local-stt.js";
|
import { LocalFasterWhisperSttService } from "./services/local-stt.js";
|
||||||
import { LocalKokoroTtsService } from "./services/local-tts.js";
|
import { LocalKokoroTtsService } from "./services/local-tts.js";
|
||||||
import { OllamaLlmService } from "./services/ollama-llm.js";
|
import { OllamaLlmService } from "./services/ollama-llm.js";
|
||||||
|
import type { SttService } from "./services/stt.js";
|
||||||
import { WindowsSystemTtsService } from "./services/windows-system-tts.js";
|
import { WindowsSystemTtsService } from "./services/windows-system-tts.js";
|
||||||
|
|
||||||
export async function printLocalAudioDevices(): Promise<void> {
|
export async function printLocalAudioDevices(): Promise<void> {
|
||||||
@@ -120,3 +122,47 @@ export async function runLocalAssistant(config: AssistantRuntimeConfig, logger:
|
|||||||
|
|
||||||
await session.start();
|
await session.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function runLocalTtsSmokeTest(
|
||||||
|
config: AssistantRuntimeConfig,
|
||||||
|
logger: Logger,
|
||||||
|
text: string,
|
||||||
|
): Promise<void> {
|
||||||
|
const tts =
|
||||||
|
process.platform === "win32"
|
||||||
|
? new WindowsSystemTtsService(config.LOCAL_TTS_SPEED)
|
||||||
|
: new LocalKokoroTtsService(config, logger);
|
||||||
|
|
||||||
|
const noOpStt: SttService = {
|
||||||
|
async transcribePcm16() {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const noOpLlm: LlmService = {
|
||||||
|
async generateReply() {
|
||||||
|
return "";
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
await tts.warmup();
|
||||||
|
|
||||||
|
const session = new LocalVoiceSession({
|
||||||
|
config,
|
||||||
|
logger,
|
||||||
|
stt: noOpStt,
|
||||||
|
tts,
|
||||||
|
llm: noOpLlm,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("TTS 단독 재생 테스트를 시작합니다.");
|
||||||
|
console.log(`재생 문장: ${text}`);
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
console.log("Windows에서는 시스템 기본 출력 장치로 재생됩니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await session.speakText(text);
|
||||||
|
} finally {
|
||||||
|
await Promise.allSettled([session.destroy(), tts.destroy?.()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user