tingwu_new
All checks were successful
Deploy to Server / deploy (push) Successful in 14s

This commit is contained in:
jeremygan2021
2026-03-11 15:24:39 +08:00
parent 60423c4323
commit 886ffec374

View File

@@ -193,13 +193,47 @@ class TranscriptionTaskViewSet(viewsets.ModelViewSet):
task_result = data_obj.get('Result', {})
# 提取逐字稿
sentences = task_result.get('Transcription', {}).get('Sentences', [])
full_text = " ".join([s.get('Text', '') for s in sentences])
task.transcription = full_text
transcription_data = task_result.get('Transcription', {})
# 如果是 URL (字符串),尝试下载内容
if isinstance(transcription_data, str) and transcription_data.startswith('http'):
try:
import requests
logger.info(f"Downloading transcription from {transcription_data}")
t_resp = requests.get(transcription_data)
if t_resp.status_code == 200:
transcription_data = t_resp.json()
else:
logger.warning(f"Failed to download transcription: {t_resp.status_code}")
transcription_data = {}
except Exception as e:
logger.error(f"Error downloading transcription: {e}")
transcription_data = {}
if isinstance(transcription_data, dict):
sentences = transcription_data.get('Sentences', [])
full_text = " ".join([s.get('Text', '') for s in sentences])
task.transcription = full_text
# 提取总结
# 总结结果结构可能因配置不同而异,这里尝试获取摘要
summarization = task_result.get('Summarization', {})
# 如果是 URL (字符串),尝试下载内容
if isinstance(summarization, str) and summarization.startswith('http'):
try:
import requests
logger.info(f"Downloading summarization from {summarization}")
s_resp = requests.get(summarization)
if s_resp.status_code == 200:
summarization = s_resp.json()
else:
logger.warning(f"Failed to download summarization: {s_resp.status_code}")
summarization = {}
except Exception as e:
logger.error(f"Error downloading summarization: {e}")
summarization = {}
# 听悟的总结通常在 Summarization.Text 或类似字段
# 如果是章节摘要,可能在 Chapters 中
# 假设是全文摘要