v1.4.3: 상대 닉네임을 말로 적던 문제 ("QQQWWWQ")
- 선수 이름은 한글이 들어간 것만 핫워드로 넣는다 - 결과가 선수 이름(조각)뿐이면 워커가 이름을 빼고 다시 변환 (is_name_echo, player_names) - 예전에 이렇게 적힌 발화는 한 번만 정밀 모델로 다시 변환 (파일 없으면 숨김, 고친 발화 제외) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
- 설계·계획: [`docs/gemnoki-project-plan.pdf`](docs/gemnoki-project-plan.pdf), 개발 구조·인터페이스: [`docs/dev/ARCHITECTURE.md`](docs/dev/ARCHITECTURE.md)
|
||||
- 범인찾기 · 리플레이 동기화 계획서 v1.2 (결정 반영): [`docs/culprit-finder-plan.pdf`](docs/culprit-finder-plan.pdf) · 원본 · 비용 계산 · 프롬프트 초안: `docs/report/culprit/` (실제로 쓰는 프롬프트는 `site/server/prompt/`)
|
||||
- **제작 완료 보고서 (M0~M8)**: [`docs/gemnoki-final-report.pdf`](docs/gemnoki-final-report.pdf) · 단계별 테스트 기록: [`docs/dev/test-results.md`](docs/dev/test-results.md)
|
||||
- Windows 실행 파일: Gitea 릴리스 [v1.4.2](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.4.2) (`GameVoiceRecorder-1.4.2-win-x64.zip` 권장, 단일 파일 `GameVoiceRecorder-1.4.2-portable.exe`) · 바뀐 점 보고서 [`docs/gemnoki-v1.3.7-report.pdf`](docs/gemnoki-v1.3.7-report.pdf) · 처음 버전 [v1.0.0](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.0.0)
|
||||
- Windows 실행 파일: Gitea 릴리스 [v1.4.2](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.4.3) (`GameVoiceRecorder-1.4.3-win-x64.zip` 권장, 단일 파일 `GameVoiceRecorder-1.4.3-portable.exe`) · 바뀐 점 보고서 [`docs/gemnoki-v1.3.7-report.pdf`](docs/gemnoki-v1.3.7-report.pdf) · 처음 버전 [v1.0.0](https://git.tkrmagid.kr/tkrmagid/game_voice_recorder/releases/tag/v1.0.0)
|
||||
|
||||
## 로그인 · 관리자 (v1.2.0~)
|
||||
|
||||
@@ -19,6 +19,13 @@
|
||||
- 앱은 시작할 때와 10분마다 등록 여부를 다시 확인한다. 등록이 해제되면 바로 잠그고 봇 · 녹음 · 사이트 연결을 멈춘다. 사이트 서버에 못 붙으면 마지막 확인 뒤 3일까지는 그대로 쓴다.
|
||||
- 서버 쪽: `site/server/src/app-auth.ts` (`/auth/app/*`, `/app/me`, `/app/admin/users`), 앱 쪽: `app/src/core/auth.ts`, 권한 목록: `app/src/core/roles.ts`. 로그인 E2E: `app/scripts/login-e2e.mts`.
|
||||
|
||||
## v1.4.3 바뀐 점
|
||||
|
||||
- 상대 닉네임을 말로 적던 문제 (예: 말소리가 "QQQWWWQ"로 나옴): 그 경기 선수 이름을 모두 핫워드로 넣어서, 말을 못 알아들으면 Whisper 가 닉네임을 그대로 적었다. 이제
|
||||
- 선수 이름은 한글이 들어간 것만 핫워드로 넣는다 (영문 · 숫자 닉네임은 한국어 말로 나올 일이 거의 없음)
|
||||
- 결과가 선수 이름(또는 그 조각)뿐이면 워커가 선수 이름을 빼고 한 번 더 변환한다 (`worker/gvr_worker/stt.py` `is_name_echo`, 앱이 `player_names` 로 넘김)
|
||||
- 한 번만: 예전에 이렇게 적힌 발화를 정밀 모델로 다시 변환한다 (음성 파일이 지워졌으면 숨김, 사람이 고친 발화는 그대로). `app/src/core/stt/pipeline.ts` `recheckNameEchoes`
|
||||
|
||||
## v1.4.2 바뀐 점
|
||||
|
||||
- 녹음 중에 음성채널에 들어온 사람이 사이트에서 "알 수 없음"으로 뜨던 문제: 앱이 그 사람을 유저로 저장만 하고 `users.updated` 를 보내지 않았다. 이제 들어올 때 보낸다 (`app/src/core/discord/bot.ts` onVoiceState)
|
||||
|
||||
4
app/package-lock.json
generated
4
app/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "gvr-app",
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gvr-app",
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.3",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.19.2",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "gvr-app",
|
||||
"productName": "겜녹이",
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.3",
|
||||
"description": "겜녹이 (Game Voice Recorder) - 게임 연동 디스코드 음성 기록",
|
||||
"private": true,
|
||||
"main": "dist/main.cjs",
|
||||
|
||||
@@ -10,12 +10,44 @@ import { WorkerClient, WorkerError, type TranscribeResult } from './worker.js';
|
||||
|
||||
const log = logger('stt');
|
||||
|
||||
const HANGUL = /[가-힣]/;
|
||||
|
||||
/** 이 경기 상세에 나온 선수 이름 (양 팀 모두) */
|
||||
export function matchPlayerNames(store: Store, matchId: string | null): string[] {
|
||||
if (!matchId) return [];
|
||||
const m = store.getMatch(matchId);
|
||||
if (!m?.detail) return [];
|
||||
try {
|
||||
const det = JSON.parse(m.detail);
|
||||
return (det.players || []).map((p: any) => (typeof p.name === 'string' ? p.name.trim() : '')).filter((n: string) => n && n !== '?');
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
const normName = (s: string) => [...s.toLowerCase()].filter((ch) => /[\p{L}\p{N}]/u.test(ch)).join('');
|
||||
|
||||
/**
|
||||
* 인식 결과가 선수 이름(또는 그 조각)뿐인가. 워커의 is_name_echo 와 같은 기준.
|
||||
* 예: 이름 "QQQWWWQQQ" → "QQQWWWQ" 는 되풀이, "QQQ 잡았다" 는 아님.
|
||||
*/
|
||||
export function isNameEcho(text: string | null, names: string[]): boolean {
|
||||
if (!text) return false;
|
||||
const keys = names.map(normName).filter((k) => k.length >= 2);
|
||||
const toks = text.split(/\s+/).map(normName).filter(Boolean);
|
||||
if (!keys.length || !toks.length) return false;
|
||||
const whole = toks.join('');
|
||||
if (whole.length >= 2 && keys.some((k) => k.includes(whole))) return true;
|
||||
return toks.every((t) => t.length >= 2 && keys.some((k) => k.includes(t)));
|
||||
}
|
||||
|
||||
const NOISE_REASON: Record<string, string> = {
|
||||
vad: '목소리 없음',
|
||||
no_speech: '말소리 아님',
|
||||
hallucination: '잡음에서 지어낸 문장',
|
||||
repetition: '같은 말만 반복',
|
||||
learned: '잡음으로 배운 문장',
|
||||
name_echo: '선수 이름을 잘못 적음',
|
||||
};
|
||||
|
||||
type Slot = 'realtime' | 'precise';
|
||||
@@ -26,6 +58,8 @@ interface Job {
|
||||
prio: number;
|
||||
/** 예전 녹음 고친 뒤 다시 변환: 잡음으로 나오면 이전 결과를 지키고, 정밀 결과로만 덮는다 */
|
||||
repair?: boolean;
|
||||
/** 이미 정밀 모델로 변환한 발화도 다시 변환한다 (잡음으로 나오면 잡음으로 숨김) */
|
||||
redo?: boolean;
|
||||
}
|
||||
|
||||
export interface SttStatus {
|
||||
@@ -161,16 +195,17 @@ export class SttPipeline {
|
||||
resumePending(): void {
|
||||
this.purgeOldNoise();
|
||||
this.repairOldAudio();
|
||||
this.recheckNameEchoes();
|
||||
const rows = this.store.pendingUtterances();
|
||||
if (rows.length) log.info(`미처리 발화 ${rows.length}개 다시 대기열에 넣음`);
|
||||
for (const r of rows) this.enqueue(r.id, 'realtime', 5);
|
||||
}
|
||||
|
||||
enqueue(id: string, slot: Slot, prio = slot === 'realtime' ? 1 : 10, repair = false): void {
|
||||
enqueue(id: string, slot: Slot, prio = slot === 'realtime' ? 1 : 10, repair = false, redo = false): void {
|
||||
const key = `${slot}:${id}`;
|
||||
if (this.queued.has(key)) return;
|
||||
this.queued.add(key);
|
||||
this.queue.push({ id, slot, prio, ...(repair ? { repair } : {}) });
|
||||
this.queue.push({ id, slot, prio, ...(repair ? { repair } : {}), ...(redo ? { redo } : {}) });
|
||||
this.queue.sort((a, b) => a.prio - b.prio);
|
||||
this.status.queue = this.queue.length;
|
||||
this.pump();
|
||||
@@ -228,22 +263,23 @@ export class SttPipeline {
|
||||
});
|
||||
}
|
||||
|
||||
/** 이 경기에 나온 요원·챔피언·선수 이름 → 핫워드 맨 앞 */
|
||||
private matchWords(u: UtteranceRow): string[] {
|
||||
if (!u.match_id) return [];
|
||||
const m = this.store.getMatch(u.match_id);
|
||||
if (!m?.detail) return [];
|
||||
try {
|
||||
const det = JSON.parse(m.detail);
|
||||
const out: string[] = [];
|
||||
for (const p of det.players || []) {
|
||||
if (p.character?.name && p.character.name !== '?') out.push(p.character.name);
|
||||
/**
|
||||
* 이 경기에 나온 요원·챔피언·선수 이름 → 핫워드 맨 앞.
|
||||
* 선수 이름은 한글이 들어간 것만 넣는다: "QQQWWWQQQ" 같은 영문 · 숫자 닉네임은 한국어 말로 나올 일이 거의 없고,
|
||||
* 말을 못 알아들을 때 Whisper 가 그 이름을 그대로 적어 버린다 (v1.4.3).
|
||||
*/
|
||||
private matchWords(u: UtteranceRow): { words: string[]; players: string[] } {
|
||||
const players = matchPlayerNames(this.store, u.match_id).filter((n) => HANGUL.test(n));
|
||||
const words: string[] = [];
|
||||
if (u.match_id) {
|
||||
try {
|
||||
const det = JSON.parse(this.store.getMatch(u.match_id)?.detail || '{}');
|
||||
for (const p of det.players || []) if (p.character?.name && p.character.name !== '?') words.push(p.character.name);
|
||||
} catch {
|
||||
/* 경기 상세가 깨졌으면 요원 이름 없이 */
|
||||
}
|
||||
for (const p of det.players || []) if (p.name && p.name !== '?') out.push(p.name);
|
||||
return out;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
return { words: [...words, ...players], players };
|
||||
}
|
||||
|
||||
private dictContext(u: UtteranceRow): DictContext {
|
||||
@@ -258,10 +294,11 @@ export class SttPipeline {
|
||||
this.store.markUtteranceFailed(u.id);
|
||||
return;
|
||||
}
|
||||
if (job.slot === 'precise' && (u.corrected || (u.status === 'precise' && !job.repair))) return;
|
||||
if (job.slot === 'precise' && (u.corrected || (u.status === 'precise' && !job.repair && !job.redo))) return;
|
||||
const s = this.settings();
|
||||
const ctx = this.dictContext(u);
|
||||
const user = this.store.getUser(u.user_id);
|
||||
const mw = this.matchWords(u);
|
||||
let r: TranscribeResult;
|
||||
try {
|
||||
r = await this.worker.request<TranscribeResult>(
|
||||
@@ -269,7 +306,9 @@ export class SttPipeline {
|
||||
{
|
||||
slot,
|
||||
path: u.audio_path,
|
||||
hotwords: this.dict.hotwords(ctx, this.matchWords(u)),
|
||||
hotwords: this.dict.hotwords(ctx, mw.words),
|
||||
// 결과가 이 이름(조각)뿐이면 워커가 이름을 빼고 다시 변환한다
|
||||
player_names: mw.players,
|
||||
initial_prompt: null,
|
||||
corrections: this.dict.corrections(),
|
||||
dictionary: this.dict.candidates(ctx),
|
||||
@@ -392,6 +431,49 @@ export class SttPipeline {
|
||||
step();
|
||||
}
|
||||
|
||||
/**
|
||||
* 한 번만 (v1.4.3): 예전 버전이 선수 이름 핫워드를 그대로 적은 발화(예: 상대 닉네임 "QQQWWWQ")를 다시 본다.
|
||||
* 음성 파일이 있으면 새 기준(한글 이름만 핫워드 · 이름 되풀이면 이름 없이 다시)으로 정밀 모델이 다시 변환하고,
|
||||
* 파일이 지워졌으면 다시 들을 수 없으니 잡음으로 숨긴다. 사람이 고친 발화는 건드리지 않는다.
|
||||
*/
|
||||
private recheckNameEchoes(): void {
|
||||
const KEY = 'name_echo_recheck_v143';
|
||||
if (this.store.meta(KEY)) return;
|
||||
const rows = this.store.db
|
||||
.prepare(`SELECT rowid,* FROM utterances WHERE noise=0 AND corrected=0 AND match_id IS NOT NULL AND text IS NOT NULL ORDER BY started_at`)
|
||||
.all() as UtteranceRow[];
|
||||
const names = new Map<string, string[]>();
|
||||
let redo = 0;
|
||||
let hidden = 0;
|
||||
for (const u of rows) {
|
||||
if (!names.has(u.match_id!)) names.set(u.match_id!, matchPlayerNames(this.store, u.match_id));
|
||||
if (!isNameEcho(u.text, names.get(u.match_id!)!)) continue;
|
||||
if (u.audio_path && !u.audio_deleted && fs.existsSync(u.audio_path)) {
|
||||
log.info(`선수 이름을 잘못 적은 발화 ${u.id} ("${u.text}") → 정밀 모델로 다시 변환`);
|
||||
this.enqueue(u.id, 'precise', 20, false, true);
|
||||
redo++;
|
||||
} else {
|
||||
log.info(`선수 이름을 잘못 적은 발화 ${u.id} ("${u.text}") → 음성 파일이 없어 숨김`);
|
||||
this.store.updateUtteranceResult(u.id, {
|
||||
text: null,
|
||||
raw_text: u.raw_text,
|
||||
words: [],
|
||||
noise: true,
|
||||
noise_reason: 'name_echo',
|
||||
confidence: u.confidence,
|
||||
lufs: u.lufs,
|
||||
gain_db: u.gain_db,
|
||||
model: u.model ?? '',
|
||||
status: u.status === 'precise' ? 'precise' : 'realtime',
|
||||
});
|
||||
this.emit(u.id);
|
||||
hidden++;
|
||||
}
|
||||
}
|
||||
this.store.setMeta(KEY, String(Date.now()));
|
||||
if (redo || hidden) log.info(`선수 이름을 잘못 적은 예전 발화: ${redo}개 다시 변환, ${hidden}개(음성 파일 없음) 숨김`);
|
||||
}
|
||||
|
||||
/** v1.3.5 이하에서 잡음으로 판정된 발화의 남은 파일 정리 */
|
||||
private purgeOldNoise(): void {
|
||||
const rows = this.store.noiseWithAudio();
|
||||
|
||||
113
app/test/name-echo.test.ts
Normal file
113
app/test/name-echo.test.ts
Normal file
@@ -0,0 +1,113 @@
|
||||
// v1.4.3: 상대 닉네임("QQQWWWQQQ")을 핫워드로 넣었더니 말소리를 "QQQWWWQ" 로 적던 문제
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { Store } from '../src/core/db/db.ts';
|
||||
import { Timeline } from '../src/core/timeline.ts';
|
||||
import { Bus } from '../src/core/util/events.ts';
|
||||
import { SttPipeline, isNameEcho } from '../src/core/stt/pipeline.ts';
|
||||
|
||||
const NAMES = ['QQQWWWQQQ', '노곤노곤탐방가', '하늘 별'];
|
||||
|
||||
test('선수 이름 되풀이 판정: 이름(조각)만 있으면 되풀이, 실제 말이 붙으면 아님 (워커 is_name_echo 와 같은 기준)', () => {
|
||||
for (const t of ['QQQWWWQ', ' QQQWWWQ.', 'qqqwwwqqq', 'QQQWWWQ QQQWWWQ', '노곤노곤탐방가', '하늘 별']) assert.ok(isNameEcho(t, NAMES), t);
|
||||
for (const t of ['QQQ 잡았다', '노곤노곤탐방가 죽였어', '아이고, 점프티... 아, 갔다.', 'Q', '', null]) assert.ok(!isNameEcho(t, NAMES), String(t));
|
||||
assert.ok(!isNameEcho('QQQWWWQ', []));
|
||||
});
|
||||
|
||||
function setup() {
|
||||
const dir = fs.mkdtempSync(path.join(process.env.TMPDIR || os.tmpdir(), 'gvr-echo-'));
|
||||
const store = new Store(path.join(dir, 'db.sqlite'));
|
||||
store.upsertUser({ id: 'u1', name: '안정우', avatar: null });
|
||||
const players = [
|
||||
{ name: 'QQQWWWQQQ', character: { name: '제트' } },
|
||||
{ name: '노곤노곤탐방가', character: { name: '레이즈' } },
|
||||
{ name: 'Sky', character: { name: '세이지' } },
|
||||
];
|
||||
store.upsertMatch({ id: 'm1', game: 'valorant', started_at: Date.now() - 60000, status: 'ended', detail: JSON.stringify({ players }) });
|
||||
const mk = (id: string, text: string | null) => {
|
||||
const f = path.join(dir, 'audio', `${id}.ogg`);
|
||||
fs.mkdirSync(path.dirname(f), { recursive: true });
|
||||
fs.writeFileSync(f, Buffer.concat([Buffer.from('OggS'), Buffer.alloc(50)]));
|
||||
store.insertUtterance({ id, session_id: null, user_id: 'u1', started_at: Date.now(), ended_at: Date.now() + 1000, audio_path: f, match_id: 'm1' });
|
||||
if (text !== null)
|
||||
store.updateUtteranceResult(id, { text, raw_text: text, words: [], noise: false, noise_reason: null, confidence: 0.4, lufs: -30, gain_db: 0, model: 'm', status: 'precise' });
|
||||
return f;
|
||||
};
|
||||
const reqs: any[] = [];
|
||||
const results: Record<string, any> = {};
|
||||
const worker: any = Object.assign(new EventEmitter(), {
|
||||
ready: true,
|
||||
request: async (op: string, req: any) => {
|
||||
if (op === 'gpu_info') return { gpus: [] };
|
||||
if (op === 'models') return { models: [{ name: 'm', installed: true }] };
|
||||
if (op === 'load') return {};
|
||||
reqs.push(req);
|
||||
const id = path.basename(req.path, '.ogg');
|
||||
return { text: '말', raw_text: '말', words: [], noise: false, noise_reason: null, confidence: 0.5, lufs: -30, gain_db: 0, speech_ratio: 1, duration_s: 1, model: 'm', elapsed_ms: 1, ...results[id] };
|
||||
},
|
||||
});
|
||||
const settings: any = () => ({ stt: { realtimeModel: 'm', preciseModel: 'm', device: 'cpu', computeType: 'int8', gameVramReserveMb: 0, reprocessAfterMatch: false }, audio: { targetLufs: -18, noiseSensitivity: 0.5, denoise: false } });
|
||||
const dict: any = { hotwords: (_ctx: string, extra: string[] = []) => [...extra, '로테'].join(' '), corrections: () => [], candidates: () => [] };
|
||||
const stt = new SttPipeline(worker, store, dict, new Timeline(store), new Bus(), settings);
|
||||
const wait = async (fn: () => boolean) => {
|
||||
const t = Date.now();
|
||||
while (!fn()) {
|
||||
if (Date.now() - t > 5000) throw new Error('timeout');
|
||||
await new Promise((r) => setTimeout(r, 10));
|
||||
}
|
||||
};
|
||||
return { store, stt, mk, reqs, results, wait };
|
||||
}
|
||||
|
||||
test('핫워드: 선수 이름은 한글이 들어간 것만 넣고, 그 이름을 워커에 되풀이 확인용으로 넘긴다', async () => {
|
||||
const s = setup();
|
||||
await s.stt.load('realtime', 'm');
|
||||
s.mk('a1', null);
|
||||
s.stt.enqueue('a1', 'realtime');
|
||||
await s.wait(() => s.store.getUtterance('a1')!.status !== 'pending');
|
||||
const hw: string[] = s.reqs[0].hotwords.split(' ');
|
||||
assert.ok(hw.includes('제트') && hw.includes('레이즈') && hw.includes('세이지'), '요원 이름은 그대로');
|
||||
assert.ok(hw.includes('노곤노곤탐방가'));
|
||||
assert.ok(!hw.includes('QQQWWWQQQ') && !hw.includes('Sky'), '한글 없는 닉네임은 핫워드에 넣지 않는다');
|
||||
assert.deepEqual(s.reqs[0].player_names, ['노곤노곤탐방가']);
|
||||
});
|
||||
|
||||
test('예전 발화 다시 보기 (한 번만): 이름을 잘못 적은 발화는 정밀 모델로 다시 변환, 음성 파일이 없으면 숨김, 고친 발화 · 실제 말은 그대로', async () => {
|
||||
const s = setup();
|
||||
const fRedo = s.mk('e1', 'QQQWWWQ');
|
||||
s.mk('e2', 'QQQWWWQ');
|
||||
s.store.markAudioDeleted('e2');
|
||||
s.mk('e3', '아이고, 점프티... 아, 갔다.');
|
||||
s.mk('e4', 'QQQWWWQ');
|
||||
s.store.db.prepare('UPDATE utterances SET corrected=1 WHERE id=?').run('e4');
|
||||
const fFixed = s.mk('e5', 'QQQWWWQ');
|
||||
// e1: 다시 들어 보니 말소리가 아니었다 → 잡음으로 숨기고 파일 삭제. e5: 다시 들어 보니 실제 말
|
||||
s.results.e1 = { text: null, raw_text: null, noise: true, noise_reason: 'vad' };
|
||||
s.results.e5 = { text: '아 갔다', raw_text: '아 갔다' };
|
||||
await s.stt.load('precise', 'm');
|
||||
s.stt.resumePending();
|
||||
await s.wait(() => s.reqs.length >= 2 && !s.stt.status.processing && s.stt.status.queue === 0);
|
||||
assert.deepEqual(s.reqs.map((r) => path.basename(r.path, '.ogg')).sort(), ['e1', 'e5'], '정밀 모델로 이미 변환한 발화도 다시 변환');
|
||||
assert.equal(s.reqs[0].slot, 'precise');
|
||||
const e1 = s.store.getUtterance('e1')!;
|
||||
assert.equal(e1.noise, 1);
|
||||
assert.equal(e1.text, null);
|
||||
assert.ok(!fs.existsSync(fRedo));
|
||||
const e2 = s.store.getUtterance('e2')!;
|
||||
assert.equal(e2.noise, 1);
|
||||
assert.equal(e2.noise_reason, 'name_echo');
|
||||
assert.equal(e2.text, null);
|
||||
assert.equal(s.store.getUtterance('e3')!.text, '아이고, 점프티... 아, 갔다.');
|
||||
assert.equal(s.store.getUtterance('e4')!.text, 'QQQWWWQ', '사람이 고친 발화는 그대로');
|
||||
assert.equal(s.store.getUtterance('e5')!.text, '아 갔다');
|
||||
assert.ok(fs.existsSync(fFixed));
|
||||
// 두 번째 시작에서는 다시 보지 않는다
|
||||
s.mk('e6', 'QQQWWWQ');
|
||||
s.stt.resumePending();
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
assert.equal(s.reqs.length, 2);
|
||||
});
|
||||
@@ -263,3 +263,11 @@ VOICE E2E PASS
|
||||
- 배포: 사이트 서버 다시 배포 (배포된 화면 번들 `index-Cbz_E9Kc.js` 에 모르는 아이디 다시 받기 확인), Windows CI (79d6bb2, full) 7개 모두 PASS · 앱 버전 1.4.2 → Gitea 릴리스 v1.4.2 (v1.4.1 에 새 버전 안내)
|
||||
- 보완 (사이트만): 모르는 아이디를 받기 전에 영구히 기억해서 `/api/users` 가 한 번 실패하면 그 사람은 계속 "알 수 없음"이었다. `site/web/src/lib/unknown-users.ts` 로 빼서, 받는 중에는 또 부르지 않고 실패하면 다음 이벤트에서 다시 받는다 (성공한 아이디만 기억). 테스트 `site/server/test/unknown-users.test.ts` 2개. 목 서버 `/mock/users-fail?n=1` + `/mock/latejoin?again=1`: 고치기 전 화면은 요청 1번에 이름 없음, 고친 화면은 다음 발화에서 다시 받아 이름 표시
|
||||
- 테스트: 앱 63 · 사이트 서버 18 통과, 앱 · 화면 · 서버 타입 검사 · 화면 빌드 통과. 앱 코드는 그대로라 v1.4.2 릴리스는 그대로
|
||||
|
||||
## v1.4.3 — 상대 닉네임을 말로 적던 문제 (2026-10-17)
|
||||
|
||||
- 증상: 사이트 대화에 "QQQWWWQ" 라는 말이 여러 사람 발화로 뜸. 같은 경기 상대 선수 이름이 "QQQWWWQQQ"
|
||||
- 원인: `pipeline.ts` `matchWords` 가 그 경기 10명의 선수 이름을 핫워드 맨 앞에 넣었다. 말을 못 알아들으면 Whisper 가 핫워드를 그대로 적는데, 기존 되풀이 확인(`is_hotword_echo`)은 3단어 이상만 봐서 이름 하나(조각)는 지나갔다
|
||||
- 고침: 선수 이름은 한글이 들어간 것만 핫워드로. 결과가 선수 이름(조각)뿐이면 워커가 이름을 빼고 다시 변환. 예전 발화는 한 번만 다시 변환(파일 없으면 숨김, 고친 발화 제외)
|
||||
- 테스트: 워커 `test_hotword_echo.py` 이름 되풀이 3개, 앱 `name-echo.test.ts` 3개(판정 · 핫워드에 영문 닉네임 빠짐 · 예전 발화 다시 보기 한 번만)
|
||||
- 실제 모델(faster-whisper small, CPU): 실제 말소리 · 키보드 · 잡음 파일에 영문 닉네임 핫워드를 넣어도 정상, 결과 전체를 선수 이름으로 준 경우 되풀이로 잡고 이름 없이 다시 변환해 실제 말을 돌려줌
|
||||
|
||||
@@ -176,10 +176,17 @@ class SttEngine:
|
||||
segs = run(hotwords)
|
||||
# 핫워드 되풀이 방지: Whisper 가 말을 못 알아들으면 프롬프트(핫워드 목록)를 그대로 읽어 버리는 경우가 있다.
|
||||
# 결과가 핫워드로만 채워져 있으면 핫워드 없이 한 번 더 돌려 그 결과를 쓴다.
|
||||
names = [n for n in (req.get("player_names") or []) if isinstance(n, str) and n.strip()]
|
||||
if hotwords and is_hotword_echo("".join(x.text for x in segs), hotwords):
|
||||
log.info("핫워드 되풀이 감지 → 핫워드 없이 다시 변환")
|
||||
segs = run(None)
|
||||
result["hotword_retry"] = True
|
||||
elif names and is_name_echo("".join(x.text for x in segs), names):
|
||||
# 말을 못 알아들으면 핫워드에 넣은 선수 이름(상대 닉네임 등)을 그대로 적는 경우가 있다 (예: "QQQWWWQ").
|
||||
# 결과가 선수 이름(또는 그 조각)뿐이면 선수 이름을 빼고 다시 변환한다. 정말 이름을 말했으면 다시 해도 그 이름이 나온다.
|
||||
log.info("선수 이름 되풀이 감지 → 선수 이름 없이 다시 변환")
|
||||
segs = run(_without_names(hotwords, names))
|
||||
result["name_retry"] = True
|
||||
|
||||
words: list[dict[str, Any]] = []
|
||||
for seg in segs:
|
||||
@@ -214,6 +221,36 @@ class SttEngine:
|
||||
return done()
|
||||
|
||||
|
||||
def _norm_name(s: str) -> str:
|
||||
"""대소문자 · 띄어쓰기 · 문장부호를 무시한 비교용 글자."""
|
||||
return "".join(ch for ch in s.lower() if ch.isalnum())
|
||||
|
||||
|
||||
def is_name_echo(text: str, names: list[str]) -> bool:
|
||||
"""결과 문장이 선수 이름(또는 이름 조각)만으로 되어 있는지.
|
||||
|
||||
문장 전체(띄어쓰기 무시) 또는 모든 단어가 2글자 이상이면서 어떤 선수 이름 안에 그대로 들어 있어야 한다.
|
||||
예: 이름 "QQQWWWQQQ" → "QQQWWWQ", "QQQWWWQ QQQWWWQ" 는 되풀이, "QQQ 잡았다" 는 아님.
|
||||
"""
|
||||
keys = [k for k in (_norm_name(n) for n in names) if len(k) >= 2]
|
||||
toks = [_norm_name(t) for t in text.split()]
|
||||
toks = [t for t in toks if t]
|
||||
if not keys or not toks:
|
||||
return False
|
||||
whole = "".join(toks)
|
||||
if len(whole) >= 2 and any(whole in k for k in keys):
|
||||
return True
|
||||
return all(len(t) >= 2 and any(t in k for k in keys) for t in toks)
|
||||
|
||||
|
||||
def _without_names(hotwords: str | None, names: list[str]) -> str | None:
|
||||
if not hotwords:
|
||||
return None
|
||||
drop = {w for n in names for w in n.split()}
|
||||
rest = " ".join(h for h in hotwords.split() if h not in drop)
|
||||
return rest or None
|
||||
|
||||
|
||||
def is_hotword_echo(text: str, hotwords: str) -> bool:
|
||||
"""결과 문장이 핫워드 목록을 되풀이한 것인지.
|
||||
|
||||
|
||||
@@ -15,3 +15,33 @@ def test_normal_sentence_with_some_hotwords_is_kept():
|
||||
assert not is_hotword_echo("드래곤 가자 바텀으로 모여", HW)
|
||||
assert not is_hotword_echo("바론 치자 시야 잡아줘", HW)
|
||||
assert not is_hotword_echo("포탑 밀자", HW)
|
||||
|
||||
|
||||
# 선수 이름 되풀이 (v1.4.3): 상대 닉네임 "QQQWWWQQQ" 를 핫워드로 넣었더니 말소리를 "QQQWWWQ" 로 적었다
|
||||
from gvr_worker.stt import _without_names, is_name_echo # noqa: E402
|
||||
|
||||
NAMES = ["QQQWWWQQQ", "노곤노곤탐방가", "하늘 별"]
|
||||
|
||||
|
||||
def test_name_echo_detected_for_name_or_fragment():
|
||||
assert is_name_echo("QQQWWWQ", NAMES)
|
||||
assert is_name_echo(" QQQWWWQ.", NAMES)
|
||||
assert is_name_echo("qqqwwwqqq", NAMES)
|
||||
assert is_name_echo("QQQWWWQ QQQWWWQ", NAMES)
|
||||
assert is_name_echo("노곤노곤탐방가", NAMES)
|
||||
assert is_name_echo("하늘 별", NAMES)
|
||||
|
||||
|
||||
def test_name_echo_not_for_real_speech():
|
||||
assert not is_name_echo("QQQ 잡았다", NAMES)
|
||||
assert not is_name_echo("노곤노곤탐방가 죽였어", NAMES)
|
||||
assert not is_name_echo("아이고, 점프티... 아, 갔다.", NAMES)
|
||||
assert not is_name_echo("Q", NAMES)
|
||||
assert not is_name_echo("", NAMES)
|
||||
assert not is_name_echo("QQQWWWQ", [])
|
||||
|
||||
|
||||
def test_without_names_keeps_other_hotwords():
|
||||
assert _without_names("제트 레이즈 QQQWWWQQQ 하늘 별 로테", NAMES) == "제트 레이즈 로테"
|
||||
assert _without_names("QQQWWWQQQ", NAMES) is None
|
||||
assert _without_names(None, NAMES) is None
|
||||
|
||||
Reference in New Issue
Block a user