feat: 语音确认、联调与运维增强

- 语音:序数解析(第一个/第二个等)、解析失败计数与 API detail.retry_remaining;
  百度 ASR 固定 dev_pid 为普通话;SurgeryPipelineError 支持 extra 并入 HTTP detail。
- Demo:demo 路由与假 RTSP、客户端 index 与 README;BackendResolver 与配置调整。
- 可观测:消耗 TSV 日志、语音文件日志、终端 Markdown 辅助;相关测试与依赖更新。
- 注意:.env 仍被 gitignore,本地密钥不会进入本提交。

Made-with: Cursor
This commit is contained in:
Kevin
2026-04-23 14:24:20 +08:00
parent 42720f81cf
commit 0c05463617
39 changed files with 3030 additions and 143 deletions

View File

@@ -1,5 +1,6 @@
from __future__ import annotations
import asyncio
import json
import pytest
@@ -55,3 +56,50 @@ async def test_save_audit_persists_fields(db_session: AsyncSession) -> None:
assert r.resolved_label == "纱布"
assert r.options_snapshot_json == opts
assert r.error_message is None
@pytest.mark.asyncio
async def test_list_by_surgery_order_and_total(db_session: AsyncSession) -> None:
repo = VoiceAuditRepository()
async with db_session.begin():
await repo.save_audit(
db_session,
surgery_id="111111",
confirmation_id="a",
status="parse_failed",
audio_object_key=None,
audio_content_type=None,
audio_size_bytes=None,
audio_sha256=None,
asr_text="",
resolved_label=None,
options_snapshot_json="[]",
error_message="x",
)
await asyncio.sleep(0.02)
async with db_session.begin():
await repo.save_audit(
db_session,
surgery_id="111111",
confirmation_id="b",
status="recognized",
audio_object_key="k.wav",
audio_content_type="audio/wav",
audio_size_bytes=10,
audio_sha256="b" * 64,
asr_text="纱布",
resolved_label="纱布",
options_snapshot_json="[]",
error_message=None,
)
async with db_session.begin():
rows, total = await repo.list_by_surgery(db_session, "111111", limit=10, offset=0)
assert total == 2
assert [r.confirmation_id for r in rows] == ["b", "a"]
async with db_session.begin():
page2, total2 = await repo.list_by_surgery(
db_session, "111111", limit=1, offset=1
)
assert total2 == 2
assert len(page2) == 1
assert page2[0].confirmation_id == "a"