diff --git a/src/gateway/guards/prompt-gates.ts b/src/gateway/guards/prompt-gates.ts index 2fde59e..c442c49 100644 --- a/src/gateway/guards/prompt-gates.ts +++ b/src/gateway/guards/prompt-gates.ts @@ -552,6 +552,9 @@ export function isActionPromiseNoTool(text: string): boolean { const s = String(text || '').trim(); if (!s || s.length > 800) return false; const tail = s.slice(-220); + // 되묻기("…알려주시면 바로 확인해 드리겠습니다", "…말씀하신 건가요?")는 약속이 아니라 사용자 답을 기다리는 질문이다. + // 2026-10-19 음성: "국제 육관"을 되물은 답이 약속으로 오판돼 넛지 → "죄송합니다, 약속하고 실행 안 했습니다"로 엉뚱한 사과가 나갔다. + if (/[??]\s*$|(?:알려|말씀해|가르쳐)\s*주(?:시면|세요|실래요)|확인\s*부탁|(?:인가요|일까요|건가요|드릴까요|할까요|싶으신가요)[??\s]*$/.test(tail.trim()) || /(?:알려|말씀해)\s*주시면/.test(tail)) return false; return ( /(검색|찾|조사|다운로드|받아|불러|만들|생성|저장|정리|수집|모으|확인|시작|진행|시도|실행|수정|추가|변경|고치|작성|적용|바꾸|렌더|출력)[가-힣\s]{0,5}겠(습니다|다)|시작합니다|(?:let\s+me|i'?ll|i\s+will)\s+(?:search|find|check|look|download|fetch|grab|read|create|make|try)\b/i.test(tail) ); diff --git a/src/tools/stt-correct.ts b/src/tools/stt-correct.ts index 9204241..769c650 100644 --- a/src/tools/stt-correct.ts +++ b/src/tools/stt-correct.ts @@ -34,6 +34,8 @@ export const DEFAULT_RULES: Array<{ pattern: string; to: string }> = [ { pattern: '트루\\s*(?:나스|내스)', to: '트루나스' }, { pattern: '라즈베리\\s*(?:파이|화이|피이)', to: '라즈베리 파이' }, // "서울"이 "세월"로 들린 실사고(2026-10-18 "오늘 세월에 비가 많이 왔나"). 날씨 단어가 가까이 있을 때만 — 세월호·세월이 흘러 같은 진짜 "세월"은 건드리지 않는다. + // "국제 유가"가 "국제 육관"으로 들린 실사고(2026-10-19) + { pattern: '국제\\s*(?:육관|육가|유관|유카|육화)', to: '국제 유가' }, { pattern: '세월(?!호|이\\s|은\\s|을\\s|도\\s)(?=[^.?!\\n]{0,10}(?:비|날씨|강수|기온|미세먼지|바람|습도|온도|예보|우산|눈이))', to: '서울' }, ]; @@ -137,7 +139,9 @@ export function correctTranscript(text: string, cfg: SttCorrectionConfig = getSt /** 자주 쓰는 지명 — Whisper hotwords에 같이 넣는다(현풍→선풍, 서울→세월 같은 오인식 방지). */ -export const HOTWORD_PLACES = ['서울', '부산', '대구', '구미', '인동', '현풍', '화원', '다사', '창원', '제주', '세종']; +export const HOTWORD_PLACES = ['서울', '부산', '대구', '구미', '인동', '현풍', '화원', '다사', '창원', '제주', '세종', + // 경제 시세 질문 단어 — "국제 유가"가 "국제 육관"·"6화"로 들린 실사고(2026-10-19) + '유가', '금리', '환율']; const MAX_HOTWORDS = 40; /** diff --git a/src/tools/voice_engine.py b/src/tools/voice_engine.py index 201bced..b56819f 100644 --- a/src/tools/voice_engine.py +++ b/src/tools/voice_engine.py @@ -62,6 +62,7 @@ MIN_PARTIAL_BYTES = int(16000 * 2 * 0.6) # ~0.6s of 16kHz mono PCM16 before we NO_SPEECH_PROB_CUTOFF = 0.6 # 고유어·지명 사전(faster-whisper hotwords). 2026-10-18 측정: CER 7.4% → 3.7%. VAD가 켜져 있어 무음/잡음에서는 환각이 없다. STT_HOTWORDS = None +STT_DROP_MEAN_PROB = 0.12 # 최종 인식의 평균 단어 확률이 이보다 낮으면 환각으로 보고 버린다(실측: 환각 0.008, 정상 발화 ≥0.3) def is_unrecoverable_cuda_error(e: Exception) -> bool: @@ -325,6 +326,11 @@ class Engine: if log_conf: sim = self.spk.observe(audio, ctx) if (text and ctx is not None) else None log_stt_confidence('stream', segs, text, t0, sim, ctx.user if ctx is not None else None) + # 거의 무음·잡음에서 hotwords를 그대로 뱉는 환각("네스트 젬마 제미나이", 단어 확률 ~0.01)은 버린다. + probs = [w.probability for sg in segs if sg.no_speech_prob < NO_SPEECH_PROB_CUTOFF for w in (sg.words or [])] + if text and probs and sum(probs) / len(probs) < STT_DROP_MEAN_PROB: + log.info('STT dropped (mean_prob %.3f): %r', sum(probs) / len(probs), text) + text = '' return text, (info.language if info else language) # ── "Streaming" TTS ───────────────────────────────────────────────── diff --git a/tests/prompt-gates.test.ts b/tests/prompt-gates.test.ts index 4cb97f7..077faea 100644 --- a/tests/prompt-gates.test.ts +++ b/tests/prompt-gates.test.ts @@ -537,3 +537,13 @@ describe('isActionPromiseNoTool — 행동 예고 후 도구 0개 턴', () => { assert.equal(isActionPromiseNoTool(long), false); }); }); + +describe('isActionPromiseNoTool — 되묻기는 약속이 아니다', () => { + test('정보를 알려 주면 확인하겠다는 되묻기는 통과', () => { + assert.equal(isActionPromiseNoTool('어떤 용어를 말씀하신 것인가요?\n\n어떤 정보를 찾으시는지 알려주시면 바로 확인해 드리겠습니다.'), false); + assert.equal(isActionPromiseNoTool('국제 유가를 말씀하신 건가요?'), false); + }); + test('진짜 실행 예고는 그대로 잡는다', () => { + assert.equal(isActionPromiseNoTool('먼저 GitHub에서 관련 리포지토리를 검색하겠습니다.'), true); + }); +});