feat(audio): add pluggable audio preprocessing and denoising layer before STT
- Add audio_enhancer module with 60s timeout, zero-transcoding default, and fail-soft fallback - Persist enhanced audio in daily folders with _enhanced suffix and emit audio.enhance.result event - Connect audio enhancer to transcribe_multi and transcribe in stt.py - Forward message_id and trace_id from handlers - Ensure consensus_text fallback persistence and remove scenario leakage in nlu.py - Add test_enhancer.py unit suite and update smoke_test.py
This commit is contained in:
+14
-3
@@ -255,6 +255,17 @@ def _install_fake_stores() -> None:
|
||||
|
||||
runtime.LinkStore.get, runtime.LinkStore.upsert, runtime.LinkStore.delete = link_get, link_upsert, link_delete
|
||||
|
||||
import app.observability as obs
|
||||
async def fake_obs(*args, **kwargs):
|
||||
pass
|
||||
async def fake_obs_trace(*args, **kwargs):
|
||||
return None
|
||||
obs.event = fake_obs
|
||||
obs.trace_start = fake_obs
|
||||
obs.link_draft = fake_obs
|
||||
obs.set_trace_status = fake_obs
|
||||
obs.latest_trace_for_draft = fake_obs_trace
|
||||
|
||||
|
||||
async def fake_log(self, chat_id, direction, kind, body=None):
|
||||
pass
|
||||
@@ -263,16 +274,16 @@ async def fake_log(self, chat_id, direction, kind, body=None):
|
||||
NLU_QUEUE: list[dict] = []
|
||||
|
||||
|
||||
async def fake_understand(settings, text, draft_summary=None):
|
||||
async def fake_understand(settings, text, draft_summary=None, *args, **kwargs):
|
||||
return NLU_QUEUE.pop(0) if NLU_QUEUE else {"intent": "unknown", "patch": {}, "confidence": 0}
|
||||
|
||||
|
||||
async def fake_transcribe(settings, audio, mime_type=None, filename=None):
|
||||
async def fake_transcribe(settings, audio, mime_type=None, filename=None, *args, **kwargs):
|
||||
return ("سازان نو برای پروژه برج آسمان ۵۰۰ کیلو میلگرد A3 سایز ۱۴ هر کیلو ۴۵ هزار تومن "
|
||||
"پرداخت سه فاز")
|
||||
|
||||
|
||||
async def fake_transcribe_multi(settings, audio, mime_type=None, filename=None):
|
||||
async def fake_transcribe_multi(settings, audio, mime_type=None, filename=None, *args, **kwargs):
|
||||
return [{"name": "fake", "text": "سازان نو برای پروژه برج آسمان ۵۰۰ کیلو میلگرد A3 سایز ۱۴ هر کیلو ۴۵ هزار تومن پرداخت سه فاز"}]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user