feat: Hearo 1차 구현 — 프로그램 소리 실시간 번역 자막

프로그램별 오디오를 캡처해 로컬 GPU에서 음성인식→번역하고 화면 위
자막으로 보여주는 데스크톱 앱. 한/영/일/중 4개 언어.

구성
- audio: WASAPI 프로그램별 캡처(C++ 보조 프로그램) + 장치 루프백 폴백,
  적응형 VAD 발화 분할
- models: 속도~품질 5단계 티어, faster-whisper + CTranslate2/LLM 2백엔드,
  용어집(플레이스홀더 보호 + 프롬프트 주입)
- core: Qt 비의존 파이프라인 엔진 (캡처/분할/추론 3스레드, 큐 연결)
- ui: 사이드바 5화면 + 무테두리 항상위 자막 오버레이, 자체 다크 테마

모델 선정 근거는 docs/MODELS.md, 추가학습 가능 여부와 방법은
docs/FINETUNING.md 참고.

검증: pytest 39개 통과 (GPU·오디오 장치 없이 실행), ruff clean

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-09-21 10:47:11 +09:00
parent c24e5f938d
commit 1a87ec6677
49 changed files with 4975 additions and 1 deletions

75
tests/test_glossary.py Normal file
View File

@@ -0,0 +1,75 @@
from hearo.models.glossary import Glossary, GlossaryEntry
def make() -> Glossary:
return Glossary(
[
GlossaryEntry("headshot", {"ko": "헤드샷"}),
GlossaryEntry("head", {"ko": "머리"}),
GlossaryEntry("Nexus", {"ko": "넥서스", "ja": "ネクサス"}),
]
)
def test_protect_and_restore_roundtrip():
g = make()
protected, repl = g.protect("Nice headshot on the Nexus", "ko")
assert "headshot" not in protected
assert "Nexus" not in protected
assert repl == ["헤드샷", "넥서스"]
# 번역 모델이 플레이스홀더를 그대로 통과시켰다고 가정
assert Glossary.restore(protected, repl) == "Nice 헤드샷 on the 넥서스"
def test_longest_match_wins():
"""'headshot'이 'head'에 먼저 잡아먹히면 안 된다."""
g = make()
_, repl = g.protect("headshot", "ko")
assert repl == ["헤드샷"]
def test_word_boundary_for_latin_terms():
g = make()
_, repl = g.protect("overheated", "ko")
assert repl == []
def test_missing_target_language_is_left_alone():
g = make()
protected, repl = g.protect("headshot", "ja")
assert protected == "headshot"
assert repl == []
def test_prompt_hint_only_includes_present_terms():
g = make()
hint = g.prompt_hint("push to the Nexus", "ko")
assert "Nexus -> 넥서스" in hint
assert "headshot" not in hint
assert g.prompt_hint("nothing here", "ko") == ""
def test_case_insensitive_by_default():
g = make()
_, repl = g.protect("NEXUS down", "ko")
assert repl == ["넥서스"]
def test_save_and_load(tmp_path):
path = tmp_path / "glossary.json"
make().save(path)
loaded = Glossary.load(path)
assert len(loaded) == 3
assert loaded.entries[2].target_for("ja") == "ネクサス"
def test_add_replaces_existing_entry():
g = make()
g.add(GlossaryEntry("Nexus", {"ko": "본진"}))
assert len(g) == 3
_, repl = g.protect("Nexus", "ko")
assert repl == ["본진"]
def test_restore_ignores_out_of_range_placeholder():
assert Glossary.restore("a ⟦5⟧ b", ["x"]) == "a b"