fix(core): 脚本 agent 再兼容 lines/caption 变体,补全旁白漏空
豆包不同型号吐不同 schema:Lite 用 dialogue(字符串)+subtitle;Pro 用
lines:[{role,content}]+caption。上一版只认 dialogue/subtitle,导致 Pro 变体
画面能填、旁白仍空。normalize_draft 再扩容:
- 口播来源并入 lines(每项 content/line/text)、voiceover;subtitle/caption 兜底
- 画面来源并入 visual_description
新增 lines/caption 变体回归用例,全套 22 测试通过。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,26 @@ class NormalizeDraftTests(SimpleTestCase):
|
||||
self.assertEqual(draft["segments"][0]["narration"], "卡裆太社死!")
|
||||
self.assertEqual(draft["segments"][0]["visual"], "更衣室扯卡裆旧裤")
|
||||
|
||||
def test_lines_and_caption_variant_fills_narration(self):
|
||||
"""另一种变体(Doubao-Seed-2.0-P):shots 用 lines:[{role,content}] 放口播、caption 放字幕。
|
||||
必须把 lines 的 content 当对白/旁白,caption 兜底,而不是只填画面留旁白空。"""
|
||||
raw = json.dumps({
|
||||
"ScriptDraft": {
|
||||
"basicInfo": {"totalDuration": 30, "aspectRatio": "9:16"},
|
||||
"shots": [
|
||||
{"shotNo": 1, "scene": "化妆台两闺蜜", "lines": [{"role": "女主", "content": "防晒泛白太尴尬!"}, {"role": "闺蜜", "content": "试试这个!"}], "caption": "防晒踩雷?"},
|
||||
{"shotNo": 2, "scene": "手背挤膏体", "lines": [{"role": "闺蜜", "content": "质地清透不泛白"}], "caption": "清透质地"},
|
||||
],
|
||||
}
|
||||
}, ensure_ascii=False)
|
||||
draft = normalize_draft(raw, aspect_ratio="9:16", total_duration=30)
|
||||
self.assertEqual(len(draft["segments"]), 2)
|
||||
for seg in draft["segments"]:
|
||||
self.assertTrue(seg["narration"], "旁白不应为空")
|
||||
self.assertTrue(seg["visual"], "画面不应为空")
|
||||
self.assertIn("防晒泛白太尴尬", draft["segments"][0]["narration"])
|
||||
self.assertEqual(len(draft["segments"][0]["dialogue"]), 2) # lines→结构化对白
|
||||
|
||||
def test_string_dialogue_not_iterated_as_chars(self):
|
||||
"""dialogue 为整句字符串时,要当作旁白而不是逐字符遍历。"""
|
||||
raw = json.dumps({
|
||||
|
||||
Reference in New Issue
Block a user