refine: dashboard review fixes - echo removal, model escape, RMS gate, fd leak, mic cleanup

Reviewer feedback: remove AudioContext destination echo, escape model names, add RMS gate to skip silence, close mkstemp fd, clean up mic on WS close. Tests updated for the RMS gate.
This commit is contained in:
2026-08-12 21:44:26 +09:00
parent 3dfa660503
commit 7616b87f4c
6 changed files with 61 additions and 6 deletions
+3 -1
View File
@@ -147,7 +147,9 @@ class TestJobs:
# 조회
r = client.get(f"/v1/jobs/{job_id}", headers=headers)
assert r.status_code == 200
assert r.json()["status"] == "queued"
body = r.json()
assert body["status"] == "queued"
assert body["source_name"] == "meeting.mp3" # 대시보드 파일 컬럼용
# 결과는 아직 없음
r = client.get(f"/v1/jobs/{job_id}/result", headers=headers)
+13 -1
View File
@@ -87,12 +87,24 @@ def test_pcm16_to_wav_header():
assert struct.unpack("<I", wav[40:44])[0] == 16000 # data 크기
def test_emit_hypothesis_skips_silence():
"""무음 청크는 decode 없이 빈 가설 반환 (할루시네이션 방지)."""
engine = _SegFakeEngine()
owner = _bare_owner(engine)
out = owner.emit_hypothesis(b"\x00\x00" * 16000) # 완전 무음
assert out["segments"] == []
assert engine.path is None # decode 미실행 → 임시 파일도 안 만듦
def test_emit_hypothesis_decodes_chunk_and_cleans_temp():
import os
import random
import struct
engine = _SegFakeEngine()
owner = _bare_owner(engine)
chunk = b"\x00\x00" * 16000 # 1초 PCM16
# 1초 PCM16 — RMS 게이트를 통과하는 유성 신호 (무음이면 decode가 생략됨)
chunk = b"".join(struct.pack("<h", random.randint(-6000, 6000)) for _ in range(16000))
out = owner.emit_hypothesis(chunk)
assert out["audio_sec"] == 1.0
assert len(out["segments"]) == 1