feat(api): use Tencent ASR flash with 16k_zh_large and dev transcript logs
Replace CreateRecTask polling with recording-file flash API, add TENCENT_APP_ID, remove server-side pydub slicing, and log ASR recognition text at INFO in development. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
58
api/tests/test_asr_transcript_logging.py
Normal file
58
api/tests/test_asr_transcript_logging.py
Normal file
@@ -0,0 +1,58 @@
|
||||
"""ASR transcript logging helpers."""
|
||||
|
||||
from app.core.agent_logging import asr_transcript_log_enabled, log_asr_transcript_result
|
||||
|
||||
|
||||
def test_asr_transcript_log_enabled_in_development(
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
from app.core.config import settings
|
||||
|
||||
monkeypatch.setattr(settings, "app_environment", "development", raising=False)
|
||||
monkeypatch.setattr(settings, "log_level", "INFO", raising=False)
|
||||
assert asr_transcript_log_enabled() is True
|
||||
|
||||
|
||||
def test_asr_transcript_log_disabled_in_production_info(
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
from app.core.config import settings
|
||||
|
||||
monkeypatch.setattr(settings, "app_environment", "production", raising=False)
|
||||
monkeypatch.setattr(settings, "log_level", "INFO", raising=False)
|
||||
assert asr_transcript_log_enabled() is False
|
||||
|
||||
|
||||
def test_log_asr_transcript_result_emits_info(
|
||||
monkeypatch,
|
||||
caplog,
|
||||
) -> None:
|
||||
import logging
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
caplog.set_level(logging.INFO)
|
||||
monkeypatch.setattr(settings, "app_environment", "development", raising=False)
|
||||
|
||||
class _Logger:
|
||||
def info(self, msg, *args):
|
||||
caplog.records.append(
|
||||
logging.LogRecord(
|
||||
name="test",
|
||||
level=logging.INFO,
|
||||
pathname="",
|
||||
lineno=0,
|
||||
msg=msg.format(*args) if args else msg,
|
||||
args=(),
|
||||
exc_info=None,
|
||||
)
|
||||
)
|
||||
|
||||
log_asr_transcript_result(
|
||||
_Logger(),
|
||||
text="你好世界",
|
||||
conversation_id="c1",
|
||||
segment_index=0,
|
||||
)
|
||||
messages = [r.getMessage() for r in caplog.records]
|
||||
assert any("ASR 识别结果" in m and "你好世界" in m for m in messages)
|
||||
Reference in New Issue
Block a user