- 따라갈 사람: 봇이 서버를 지켜보기 전 멤버 요청을 사이트 서버가 forbidden 으로 거절하고 앱이 오류를 숨겨 빈 목록이 됐다 → 가입한 서버면 지켜보기 전에도 응답(source.members 가 멤버 확인), 앱은 오류 · 다시 불러오기 표시 → 내 계정 → 관리자(GET /app/admins) → 이름순, 녹음할 서버를 바꾸면 봇을 다시 붙여 새 서버를 지켜봄 - 롤 채팅 OCR 제거: 앱 설정 · 마법사 · 진단 · lol.ts · 워커 ocr.py/ocr_* op · pywinrt/mss/Pillow · win-ci ocr_lang 롤은 게임 중 전체/팀 채팅 API 가 없어 LCU(챔피언 선택 · 게임 후) + r3dlog(남아 있을 때, LCU 채팅을 지우지 않고 추가) - 표시 이름: 서버 store.displayNames (세션 · 앱 유저 · 접속 기록 이름까지 바꿈), GET /app/names, PUT /app/admin/names, cli name. 앱은 받아서 users · 지난 범인 분석 이름을 바꾸고 이후 디스코드 이름 대신 저장. 관리자 탭에 편집 UI - 저장소 시연 · 테스트 데이터 · 화면 캡처 · 계획서 PDF 의 실제 이름을 가짜 이름으로 교체 - 테스트: 앱 41 · 서버 16 · 워커 39 통과 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
4.5 KiB
TypeScript
85 lines
4.5 KiB
TypeScript
// 실제 STT 워커(CPU, tiny)와 코어를 붙여 "발화 저장 → 대기열 → STT → DB → 실시간 이벤트 → API" 를 확인한다.
|
|
// 워커 venv(worker/.venv)와 HF 캐시의 tiny 모델이 있어야 한다. 없으면 건너뛴다.
|
|
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
|
|
const root = path.resolve(import.meta.dirname, '..', '..');
|
|
const py = path.join(root, 'worker', '.venv', 'bin', 'python');
|
|
const hfTiny = path.join(os.homedir(), '.cache/huggingface/hub/models--Systran--faster-whisper-tiny/snapshots');
|
|
const skip = !fs.existsSync(py) || !fs.existsSync(hfTiny);
|
|
|
|
test('E2E: 발화 → STT 워커 → DB → 실시간 이벤트 → 기록 API', { skip, timeout: 180000 }, async () => {
|
|
const { startCore } = await import('../src/core/index.ts');
|
|
const dataDir = fs.mkdtempSync(path.join(process.env.TMPDIR || os.tmpdir(), 'gvr-e2e-'));
|
|
const models = path.join(dataDir, 'models');
|
|
fs.mkdirSync(models, { recursive: true });
|
|
fs.symlinkSync(path.join(hfTiny, fs.readdirSync(hfTiny)[0]), path.join(models, 'tiny'));
|
|
fs.writeFileSync(
|
|
path.join(dataDir, 'settings.json'),
|
|
JSON.stringify({ stt: { realtimeModel: 'tiny', preciseModel: 'tiny', device: 'cpu', computeType: 'int8' }, games: { valorant: false, lol: false } }),
|
|
);
|
|
const core = await startCore({
|
|
dataDir,
|
|
resourcesDir: path.join(root, 'app', 'resources'),
|
|
worker: { cmd: py, args: ['-m', 'gvr_worker'], cwd: path.join(root, 'worker') },
|
|
version: 'test',
|
|
});
|
|
const live: any[] = [];
|
|
core.bus.on('live', (e) => live.push(e));
|
|
try {
|
|
const wait = async (fn: () => boolean, ms: number, label: string) => {
|
|
const t = Date.now();
|
|
while (!fn()) {
|
|
if (Date.now() - t > ms) throw new Error(`timeout ${label}: ${JSON.stringify(core.stt.status)}`);
|
|
await new Promise((r) => setTimeout(r, 100));
|
|
}
|
|
};
|
|
await wait(() => core.stt.status.slots.realtime.state === 'loaded', 60000, 'model load');
|
|
core.store.upsertUser({ id: 'u1', name: '하늘', avatar: null });
|
|
const fx = path.join(root, 'worker', 'tests', 'fixtures');
|
|
const items: [string, string][] = [
|
|
['speech', 'speech_ko.ogg'],
|
|
['quiet', 'speech_ko_quiet.ogg'],
|
|
['keys', 'keyboard_clicks.ogg'],
|
|
];
|
|
const t0 = Date.now();
|
|
for (const [id, f] of items) {
|
|
const dst = path.join(core.paths().audio, 'test', `${id}.ogg`);
|
|
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
fs.copyFileSync(path.join(fx, f), dst);
|
|
core.store.insertUtterance({ id, session_id: null, user_id: 'u1', started_at: t0, ended_at: t0 + 3000, audio_path: dst, match_id: null });
|
|
core.stt.enqueue(id, 'realtime');
|
|
}
|
|
await wait(() => items.every(([id]) => core.store.getUtterance(id)!.status !== 'pending'), 120000, 'transcribe');
|
|
const sp = core.store.getUtterance('speech')!;
|
|
console.log('speech →', sp.text, '| raw:', sp.raw_text, '| gain', sp.gain_db);
|
|
assert.ok(['realtime', 'precise'].includes(sp.status), sp.status);
|
|
assert.ok(sp.text && sp.text.includes('레이즈'), sp.text ?? '');
|
|
assert.ok(JSON.parse(sp.words).length >= 3);
|
|
const q = core.store.getUtterance('quiet')!;
|
|
assert.ok(q.gain_db > 15, `quiet gain ${q.gain_db}`);
|
|
const k = core.store.getUtterance('keys')!;
|
|
assert.equal(k.noise, 1);
|
|
assert.ok(live.filter((e) => e.type === 'utterance.updated').length >= 3);
|
|
// 기록 API (사이트가 중계로 부르는 것과 같은 경로)
|
|
const res = await core.api.inject({ method: 'GET', url: '/api/timeline?limit=10' });
|
|
const page = res.json();
|
|
assert.equal(page.items.length, 3);
|
|
const audio = await core.api.inject({ method: 'GET', url: '/api/audio/speech', headers: { range: 'bytes=0-99' } });
|
|
assert.equal(audio.statusCode, 206);
|
|
assert.equal(audio.rawPayload.length, 100);
|
|
// 사이트 교정 → 사전·학습 데이터
|
|
const patched = await core.api.inject({ method: 'PATCH', url: '/api/utterances/speech', payload: { text: '레이즈 궁 빠졌어 B 사이트 로테 하자' } });
|
|
assert.equal(patched.json().corrected, true);
|
|
assert.equal(core.store.trainingSamples().length, 1);
|
|
assert.ok(fs.existsSync(core.store.trainingSamples()[0].audio_path));
|
|
const search = (await core.api.inject({ method: 'GET', url: '/api/timeline?q=' + encodeURIComponent('궁 빠졌어') })).json();
|
|
assert.deepEqual(search.items.map((i: any) => i.id), ['speech']);
|
|
} finally {
|
|
await core.stop();
|
|
}
|
|
});
|