v3.1 + 批次0: 智能回复重构基线 - ApprovalMatcher + 关键词降级 + 文档速修 + v4.0任务书面化
This commit is contained in:
@@ -48,6 +48,17 @@ async def get_baidu_token() -> str:
|
||||
Raises:
|
||||
HTTPException: 获取 token 失败时抛出 500 错误
|
||||
"""
|
||||
# 防御性检查:确保百度 ASR 凭证已配置
|
||||
if not settings.baidu_asr_api_key or not settings.baidu_asr_secret_key:
|
||||
logger.error(
|
||||
"[BaiduASR] 配置缺失:BAIDU_ASR_API_KEY 或 SECRET_KEY 未设置,"
|
||||
"无法获取 access_token"
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail="百度ASR配置缺失:BAIDU_ASR_API_KEY或SECRET_KEY未设置",
|
||||
)
|
||||
|
||||
redis = settings.create_redis_client()
|
||||
try:
|
||||
# 1. 尝试从 Redis 缓存读取 token
|
||||
@@ -120,6 +131,24 @@ async def transcribe_audio(
|
||||
f"filename={audio.filename}"
|
||||
)
|
||||
|
||||
# 防御性检查:确保百度 ASR AppID 已配置
|
||||
# cuid 为空时百度会返回 "url param cuid error"
|
||||
if not settings.baidu_asr_app_id:
|
||||
logger.error(
|
||||
"[BaiduASR] 配置缺失:BAIDU_ASR_APP_ID 未设置,"
|
||||
"cuid 将为空,百度会返回 url param cuid error"
|
||||
)
|
||||
return error_response(
|
||||
code=3001,
|
||||
message="百度ASR配置缺失:BAIDU_ASR_APP_ID未设置",
|
||||
)
|
||||
|
||||
logger.debug(
|
||||
f"[BaiduASR] 配置检查通过: app_id={settings.baidu_asr_app_id}, "
|
||||
f"api_key={'已设置' if settings.baidu_asr_api_key else '未设置'}, "
|
||||
f"secret_key={'已设置' if settings.baidu_asr_secret_key else '未设置'}"
|
||||
)
|
||||
|
||||
# 2. 获取百度 access_token
|
||||
try:
|
||||
token = await get_baidu_token()
|
||||
|
||||
Reference in New Issue
Block a user