This commit is contained in:
@@ -209,9 +209,26 @@ class TranscriptionTaskViewSet(viewsets.ModelViewSet):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error downloading transcription: {e}")
|
logger.error(f"Error downloading transcription: {e}")
|
||||||
transcription_data = {}
|
transcription_data = {}
|
||||||
|
elif isinstance(transcription_data, dict) and 'TranscriptionUrl' in transcription_data:
|
||||||
|
# 有些情况 Transcription 还是对象,但内容在 Url 字段
|
||||||
|
try:
|
||||||
|
import requests
|
||||||
|
url = transcription_data['TranscriptionUrl']
|
||||||
|
logger.info(f"Downloading transcription from {url}")
|
||||||
|
t_resp = requests.get(url)
|
||||||
|
if t_resp.status_code == 200:
|
||||||
|
transcription_data = t_resp.json()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error downloading transcription nested url: {e}")
|
||||||
|
|
||||||
if isinstance(transcription_data, dict):
|
if isinstance(transcription_data, dict):
|
||||||
|
# 尝试多种可能的路径提取句子
|
||||||
|
# 1. 直接在根目录: {"Sentences": [...]}
|
||||||
|
# 2. 在 Transcription 字段下: {"Transcription": {"Sentences": [...]}}
|
||||||
sentences = transcription_data.get('Sentences', [])
|
sentences = transcription_data.get('Sentences', [])
|
||||||
|
if not sentences and 'Transcription' in transcription_data:
|
||||||
|
sentences = transcription_data['Transcription'].get('Sentences', [])
|
||||||
|
|
||||||
full_text = " ".join([s.get('Text', '') for s in sentences])
|
full_text = " ".join([s.get('Text', '') for s in sentences])
|
||||||
task.transcription = full_text
|
task.transcription = full_text
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user