fix: video 模块与 continuation 状态更新

Co-Authored-By: Simon <simon@doorcome.cn>
This commit is contained in:
2026-06-17 20:48:42 +08:00
co-authored by Simon
parent 2f1d8b4d03
commit bb1a9c4470
3 changed files with 43 additions and 16 deletions
+6 -3
View File
@@ -162,7 +162,7 @@ def transcribe_audio(audio_path):
# 确保音频文件存在
if not os.path.exists(audio_path):
logger.error(f"音频文件不存在: {audio_path}")
return ""
return ['', '']
dashscope.api_key = os.getenv('DASHSCOPE_API_KEY', '')
# 创建识别对象
recognition = Recognition(
@@ -187,10 +187,10 @@ def transcribe_audio(audio_path):
return text
else:
logger.error(f"❌ 任务失败: {result.message}")
return ""
return ['', '']
except Exception as e:
logger.error(f"识别过程中发生异常: {e}")
return ""
return ['', '']
def merge_transcripts(transcripts):
"""
@@ -287,6 +287,9 @@ def analyze_and_correct_text(text):
# 首先修正文本错误
corrected_text = text_correction(text)
if corrected_text is None:
logger.warning("文本修正返回 None,使用原始文本")
corrected_text = text
logger.info(f"原始文本长度: {len(text)}")
logger.info(f"修正后文本长度: {len(corrected_text)}")
+18 -1
View File
@@ -86,7 +86,24 @@ def news_to_db(target_date):
prompt= "###请根据下面新闻内容的文本逻辑 \n - 帮我分割成各个独立的新闻内容(注意:不要修改新闻本身,仅分割文本),并给每个新闻总结一个标题; \n - 如果遇到'国内快讯''国际快讯''联播快讯',也请根据每个条快讯分割为一个新闻以及新闻标题; \n - 返回json格式。json格式包含:news_idnews_titlenews_content; news_id从1开始递增。"
try:
response = deepseek_text(result, prompt)
news_list = json.loads(response)
data = json.loads(response)
# DeepSeek json_object 模式返回的是 dict(如 {"news": [...]}),
# 普通模式返回的是纯数组 [...],这里做自适应提取
if isinstance(data, dict):
# 从 dict 中提取列表:找第一个 list 类型的 value
news_list = None
for v in data.values():
if isinstance(v, list):
news_list = v
break
if news_list is None:
# 所有 value 都不是 list,可能是 {"1": {...}, "2": {...}} 格式
news_list = list(data.values())
elif isinstance(data, list):
news_list = data
else:
raise ValueError(f"不支持 DeepSeek 响应格式: {type(data)}")
db = MySQLDB()
for news in news_list:
db.insert_data(