475 lines
20 KiB
Python
475 lines
20 KiB
Python
|
|
"""对白编辑入口、准备屏障及内容复用的回归。"""
|
|||
|
|
|
|||
|
|
from copy import deepcopy
|
|||
|
|
|
|||
|
|
import pytest
|
|||
|
|
|
|||
|
|
from sqlalchemy import select
|
|||
|
|
|
|||
|
|
from app.models import WorkflowDraft, WorkflowRun
|
|||
|
|
|
|||
|
|
|
|||
|
|
def story():
|
|||
|
|
return {
|
|||
|
|
"schema_version": 3,
|
|||
|
|
"entities": [{"id": "1" * 32, "name": "林晚", "kind": "person", "description": "年轻女性"}],
|
|||
|
|
"shots": [
|
|||
|
|
{
|
|||
|
|
"id": "2" * 32,
|
|||
|
|
"name": "站台上的告别",
|
|||
|
|
"visual_prompt": "年轻女性站在夜晚的车站,半身近景,正面清晰人脸",
|
|||
|
|
"motion_prompt": "轻轻抬头,保持自然呼吸和眼神变化",
|
|||
|
|
"cast": [{"id": "3" * 32, "entity_id": "1" * 32}],
|
|||
|
|
}
|
|||
|
|
],
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
async def enable(system):
|
|||
|
|
created = await system.client.post("/api/stories", json={"name": "对白", "spec": story()})
|
|||
|
|
assert created.status_code == 201, created.text
|
|||
|
|
draft_id = created.json()["id"]
|
|||
|
|
response = await system.client.post(
|
|||
|
|
f"/api/editors/{draft_id}/dialogue/enable",
|
|||
|
|
json={"expected_version": created.json()["version"]},
|
|||
|
|
headers={"Idempotency-Key": "enable-dialogue"},
|
|||
|
|
)
|
|||
|
|
assert response.status_code == 200, response.text
|
|||
|
|
return draft_id, response.json()
|
|||
|
|
|
|||
|
|
|
|||
|
|
async def enable_historical(system):
|
|||
|
|
"""构造上线前已保存的 V5;历史读取不得把旧图作者意图静默升级。"""
|
|||
|
|
draft_id, result = await enable(system)
|
|||
|
|
manifest = deepcopy(result["manifest"])
|
|||
|
|
manifest["spec"]["dialogue"].pop("generation", None)
|
|||
|
|
manifest["spec"]["dialogue"].pop("language", None)
|
|||
|
|
async with system.app.state.db.session() as session:
|
|||
|
|
draft = await session.get(WorkflowDraft, draft_id)
|
|||
|
|
draft.editor_manifest = deepcopy(manifest)
|
|||
|
|
draft.spec = deepcopy(manifest["spec"])
|
|||
|
|
await session.commit()
|
|||
|
|
state = (await system.client.get(f"/api/editors/{draft_id}")).json()
|
|||
|
|
assert "generation" not in state["manifest"]["spec"]["dialogue"]
|
|||
|
|
return draft_id, state
|
|||
|
|
|
|||
|
|
|
|||
|
|
async def test_enable_dialogue_is_explicit_idempotent_and_keeps_source(system):
|
|||
|
|
draft_id, result = await enable(system)
|
|||
|
|
manifest = result["manifest"]
|
|||
|
|
assert manifest["schema_version"] == 3
|
|||
|
|
assert manifest["spec"]["schema_version"] == 5
|
|||
|
|
assert manifest["editing_mode"] == "auto"
|
|||
|
|
assert manifest["spec"]["shots"][0]["id"] == "2" * 32
|
|||
|
|
assert manifest["spec"]["shots"][0]["continuity"]["transition"] == "cut"
|
|||
|
|
assert manifest["spec"]["dialogue"]["speakers"][0]["entity_id"] == "1" * 32
|
|||
|
|
replay = await system.client.post(
|
|||
|
|
f"/api/editors/{draft_id}/dialogue/enable",
|
|||
|
|
json={"expected_version": 1},
|
|||
|
|
headers={"Idempotency-Key": "enable-dialogue"},
|
|||
|
|
)
|
|||
|
|
assert replay.status_code == 200, replay.text
|
|||
|
|
assert replay.json()["version"] == result["version"]
|
|||
|
|
async with system.app.state.db.session() as session:
|
|||
|
|
assert not (await session.scalars(select(WorkflowRun))).all()
|
|||
|
|
assert (await session.get(WorkflowDraft, draft_id)).spec["schema_version"] == 5
|
|||
|
|
|
|||
|
|
|
|||
|
|
async def test_v5_editor_roundtrip_preserves_dialogue_on_save(system):
|
|||
|
|
draft_id, result = await enable(system)
|
|||
|
|
m = deepcopy(result["manifest"])
|
|||
|
|
speaker = m["spec"]["dialogue"]["speakers"][0]["id"]
|
|||
|
|
uid = "4" * 32
|
|||
|
|
m["spec"]["dialogue"]["utterances"] = [
|
|||
|
|
{"id": uid, "speaker_id": speaker, "text": "我会在这里等你。"}
|
|||
|
|
]
|
|||
|
|
sequence = m["spec"]["dialogue"]["sequences"][0]
|
|||
|
|
sequence["utterance_ids"] = [uid]
|
|||
|
|
saved = await system.client.post(
|
|||
|
|
f"/api/editors/{draft_id}/save",
|
|||
|
|
json={"expected_version": result["version"], "manifest": m},
|
|||
|
|
headers={"Idempotency-Key": "save-dialogue"},
|
|||
|
|
)
|
|||
|
|
assert saved.status_code == 200, saved.text
|
|||
|
|
reread = await system.client.get(f"/api/editors/{draft_id}")
|
|||
|
|
assert reread.status_code == 200, reread.text
|
|||
|
|
assert (
|
|||
|
|
reread.json()["manifest"]["spec"]["dialogue"]["utterances"][0]["text"] == "我会在这里等你。"
|
|||
|
|
)
|
|||
|
|
assert not reread.json()["manifest"]["audio"]["segments"]
|
|||
|
|
|
|||
|
|
|
|||
|
|
async def test_speech_preview_plan_only_prepares_selected_voice(system):
|
|||
|
|
draft_id, result = await enable_historical(system)
|
|||
|
|
m = deepcopy(result["manifest"])
|
|||
|
|
speaker = m["spec"]["dialogue"]["speakers"][0]["id"]
|
|||
|
|
uid = "4" * 32
|
|||
|
|
m["spec"]["dialogue"]["utterances"] = [
|
|||
|
|
{"id": uid, "speaker_id": speaker, "text": "你终于回来了。"}
|
|||
|
|
]
|
|||
|
|
m["spec"]["dialogue"]["sequences"][0]["utterance_ids"] = [uid]
|
|||
|
|
system.settings.tts_base_url = "http://test-tts/v1"
|
|||
|
|
saved = await system.client.post(
|
|||
|
|
f"/api/editors/{draft_id}/save",
|
|||
|
|
json={"expected_version": result["version"], "manifest": m},
|
|||
|
|
headers={"Idempotency-Key": "save-preview"},
|
|||
|
|
)
|
|||
|
|
assert saved.status_code == 200, saved.text
|
|||
|
|
plan = await system.client.post(
|
|||
|
|
f"/api/editors/{draft_id}/plan",
|
|||
|
|
json={
|
|||
|
|
"expected_version": saved.json()["version"],
|
|||
|
|
"output_goal": "media",
|
|||
|
|
"targets": ["speech:" + uid],
|
|||
|
|
},
|
|||
|
|
)
|
|||
|
|
assert plan.status_code == 200, plan.text
|
|||
|
|
assert {s["kind"] for s in plan.json()["steps"]} == {"audio.speech", "audio.normalize"}
|
|||
|
|
assert not plan.json()["issues"]
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_preparation_content_hash_does_not_depend_on_shot_position():
|
|||
|
|
from app.domain.dialogue import upgrade_dialogue_manifest
|
|||
|
|
from app.services.orchestration.dialogue_engine import preparation_recipes
|
|||
|
|
from types import SimpleNamespace
|
|||
|
|
|
|||
|
|
m = upgrade_dialogue_manifest(
|
|||
|
|
{
|
|||
|
|
"schema_version": 1,
|
|||
|
|
"source_kind": "story",
|
|||
|
|
"spec": story(),
|
|||
|
|
"shot_ids": ["2" * 32],
|
|||
|
|
"bindings": {},
|
|||
|
|
"audio": {"mode": "silent", "voice": "", "speed": 1, "segments": []},
|
|||
|
|
"captions": {"mode": "none", "cues": []},
|
|||
|
|
}
|
|||
|
|
)
|
|||
|
|
uid = "4" * 32
|
|||
|
|
m["spec"]["dialogue"]["utterances"] = [
|
|||
|
|
{"id": uid, "speaker_id": m["spec"]["dialogue"]["speakers"][0]["id"], "text": "你好。"}
|
|||
|
|
]
|
|||
|
|
m["spec"]["dialogue"]["sequences"][0]["utterance_ids"] = [uid]
|
|||
|
|
settings = SimpleNamespace(tts_model="kokoro-82m")
|
|||
|
|
before = preparation_recipes(m, {}, {"output_goal": "film"}, settings, {})
|
|||
|
|
m["spec"]["shots"][0]["edit"]["duration_frames"] = 240
|
|||
|
|
after = preparation_recipes(m, {}, {"output_goal": "film"}, settings, {})
|
|||
|
|
assert before[0]["context_hash"] == after[0]["context_hash"]
|
|||
|
|
assert {r["kind"] for r in before} == {
|
|||
|
|
"audio.speech",
|
|||
|
|
"audio.normalize",
|
|||
|
|
"audio.dialogue.inspect",
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_cross_shot_stem_uses_local_intersection_not_global_position():
|
|||
|
|
from app.services.orchestration.dialogue_engine import _stem_segments
|
|||
|
|
|
|||
|
|
prepared = {
|
|||
|
|
"placements": [
|
|||
|
|
{
|
|||
|
|
"shot_id": "s",
|
|||
|
|
"speaker_id": "p",
|
|||
|
|
"utterance_id": "u",
|
|||
|
|
"start_sample": 100000,
|
|||
|
|
"end_sample": 104000,
|
|||
|
|
"shot_start_sample": 2000,
|
|||
|
|
"shot_end_sample": 6000,
|
|||
|
|
"source_start_sample": 3000,
|
|||
|
|
"source_end_sample": 7000,
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
}
|
|||
|
|
m = {"bindings": {"normalized_speech:u": {"asset_id": "a" * 32}}}
|
|||
|
|
assert _stem_segments(prepared, "s", "p", m)[0]["offset_sample"] == 2000
|
|||
|
|
|
|||
|
|
|
|||
|
|
async def test_fork_prepared_creates_separate_editable_draft_with_durable_origin(system):
|
|||
|
|
draft_id, original = await enable_historical(system)
|
|||
|
|
owner = (await system.client.get("/api/auth/me")).json()["user"]["id"]
|
|||
|
|
async with system.app.state.db.session() as session:
|
|||
|
|
run = WorkflowRun(
|
|||
|
|
owner_id=owner,
|
|||
|
|
draft_id=draft_id,
|
|||
|
|
draft_revision=1,
|
|||
|
|
source_draft_version=original["version"],
|
|||
|
|
spec_snapshot=original["manifest"]["spec"],
|
|||
|
|
spec_hash="a" * 64,
|
|||
|
|
run_kind="story_auto",
|
|||
|
|
state="blocked",
|
|||
|
|
output_goal="film",
|
|||
|
|
plan_snapshot={"manifest": original["manifest"]},
|
|||
|
|
prepared_plan={
|
|||
|
|
"effective_manifest": original["manifest"],
|
|||
|
|
"steps": [],
|
|||
|
|
"production_materialized": True,
|
|||
|
|
"timing": {"shots": [{"shot_id": "2" * 32}], "total_frames": 120},
|
|||
|
|
},
|
|||
|
|
result_manifest=original["manifest"],
|
|||
|
|
)
|
|||
|
|
session.add(run)
|
|||
|
|
await session.commit()
|
|||
|
|
rid = run.id
|
|||
|
|
body = {"expected_version": original["version"], "run_id": rid, "name": "准备稿副本"}
|
|||
|
|
response = await system.client.post(
|
|||
|
|
f"/api/editors/{draft_id}/dialogue/fork-prepared",
|
|||
|
|
json=body,
|
|||
|
|
headers={"Idempotency-Key": "fork-prepared"},
|
|||
|
|
)
|
|||
|
|
assert response.status_code == 201, response.text
|
|||
|
|
result = response.json()
|
|||
|
|
assert result["draft_id"] != draft_id
|
|||
|
|
assert result["manifest"]["base_run_id"] is None
|
|||
|
|
assert result["manifest"]["spec"]["schema_version"] == 5
|
|||
|
|
assert result["origin"] == {"source_draft_id": draft_id, "source_run_id": rid}
|
|||
|
|
replay = await system.client.post(
|
|||
|
|
f"/api/editors/{draft_id}/dialogue/fork-prepared",
|
|||
|
|
json=body,
|
|||
|
|
headers={"Idempotency-Key": "fork-prepared"},
|
|||
|
|
)
|
|||
|
|
assert replay.status_code == 201 and replay.json()["draft_id"] == result["draft_id"]
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_dialogue_preparation_keeps_independent_legacy_narration():
|
|||
|
|
from app.domain.dialogue import upgrade_dialogue_manifest
|
|||
|
|
from app.services.orchestration.dialogue_engine import preparation_recipes
|
|||
|
|
from types import SimpleNamespace
|
|||
|
|
|
|||
|
|
m = upgrade_dialogue_manifest(
|
|||
|
|
{
|
|||
|
|
"schema_version": 1,
|
|||
|
|
"source_kind": "story",
|
|||
|
|
"spec": story(),
|
|||
|
|
"shot_ids": ["2" * 32],
|
|||
|
|
"bindings": {},
|
|||
|
|
"audio": {
|
|||
|
|
"mode": "generated_narration",
|
|||
|
|
"voice": "zm_yunxi",
|
|||
|
|
"speed": 1,
|
|||
|
|
"segments": [{"id": "5" * 32, "shot_id": "2" * 32, "text": "夜色降临了。"}],
|
|||
|
|
},
|
|||
|
|
"captions": {"mode": "script", "cues": []},
|
|||
|
|
}
|
|||
|
|
)
|
|||
|
|
rows = preparation_recipes(
|
|||
|
|
m, {}, {"output_goal": "film"}, SimpleNamespace(tts_model="kokoro-82m"), {}
|
|||
|
|
)
|
|||
|
|
speech = [r for r in rows if r["kind"] == "audio.speech"]
|
|||
|
|
assert len(speech) == 1 and speech[0]["input"]["prompt"] == "夜色降临了。"
|
|||
|
|
assert speech[0]["binding_key"] == "audio:" + "5" * 32
|
|||
|
|
assert len([r for r in rows if r["kind"] == "audio.normalize"]) == 1
|
|||
|
|
|
|||
|
|
|
|||
|
|
async def test_voice_preview_cannot_be_forked_as_prepared_shot_structure(system):
|
|||
|
|
draft_id, original = await enable_historical(system)
|
|||
|
|
owner = (await system.client.get("/api/auth/me")).json()["user"]["id"]
|
|||
|
|
async with system.app.state.db.session() as session:
|
|||
|
|
run = WorkflowRun(
|
|||
|
|
owner_id=owner,
|
|||
|
|
draft_id=draft_id,
|
|||
|
|
draft_revision=1,
|
|||
|
|
spec_snapshot=original["manifest"]["spec"],
|
|||
|
|
spec_hash="a" * 64,
|
|||
|
|
run_kind="story_auto",
|
|||
|
|
state="succeeded",
|
|||
|
|
output_goal="media",
|
|||
|
|
prepared_plan={
|
|||
|
|
"effective_manifest": original["manifest"],
|
|||
|
|
"steps": [],
|
|||
|
|
"production_materialized": True,
|
|||
|
|
},
|
|||
|
|
result_manifest=original["manifest"],
|
|||
|
|
)
|
|||
|
|
session.add(run)
|
|||
|
|
await session.commit()
|
|||
|
|
rid = run.id
|
|||
|
|
response = await system.client.post(
|
|||
|
|
f"/api/editors/{draft_id}/dialogue/fork-prepared",
|
|||
|
|
json={"expected_version": original["version"], "run_id": rid, "name": "不应创建"},
|
|||
|
|
headers={"Idempotency-Key": "not-a-timing-plan"},
|
|||
|
|
)
|
|||
|
|
assert response.status_code == 409, response.text
|
|||
|
|
assert (
|
|||
|
|
response.json().get("code", response.json().get("detail", {}).get("code"))
|
|||
|
|
== "preparation_incomplete"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_disabled_dialogue_no_speech_or_unrequested_mix():
|
|||
|
|
from test_dialogue_domain import manifest
|
|||
|
|
from app.domain.dialogue import prepare_dialogue
|
|||
|
|
from app.services.orchestration import dialogue_engine as e
|
|||
|
|
from app.domain.stories import compile_story
|
|||
|
|
from types import SimpleNamespace
|
|||
|
|
|
|||
|
|
m = manifest()
|
|||
|
|
m["spec"]["dialogue"]["enabled"] = False
|
|||
|
|
body = {"output_goal": "film"}
|
|||
|
|
assert e.preparation_recipes(m, {}, body, SimpleNamespace(), {}) == []
|
|||
|
|
p = prepare_dialogue(m, {}, {})
|
|||
|
|
rows = e.production_recipes(p, {}, body, SimpleNamespace(), compile_story(m["spec"], {}))
|
|||
|
|
assert not any(r["kind"] in {"audio.mix", "video.lipsync"} for r in rows)
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_face_reference_selected_variant_and_content_signature():
|
|||
|
|
from app.services.orchestration import dialogue_engine as e
|
|||
|
|
from test_dialogue_domain import manifest, U, ASSET
|
|||
|
|
from app.domain.dialogue import prepare_dialogue
|
|||
|
|
|
|||
|
|
m = manifest()
|
|||
|
|
p = prepare_dialogue(m, {U: dict(asset_id=ASSET, sample_count=50000)}, {})
|
|||
|
|
shot = p["effective_manifest"]["spec"]["shots"][0]
|
|||
|
|
b = m["bindings"]
|
|||
|
|
b["normalized_speech:" + U] = {"sha256": "a" * 64}
|
|||
|
|
sig = e._shot_signature(p, shot, {"context_hash": "x"}, m)
|
|||
|
|
b["frame:" + shot["id"]] = {"sha256": "b" * 64}
|
|||
|
|
assert e._shot_signature(p, shot, {"context_hash": "x"}, m) != sig
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_analyze_includes_listener_with_selected_variant_reference():
|
|||
|
|
from app.services.orchestration import dialogue_engine as e
|
|||
|
|
from app.domain.dialogue import prepare_dialogue
|
|||
|
|
from app.domain.stories import compile_story
|
|||
|
|
from test_dialogue_domain import manifest, U, S, ASSET
|
|||
|
|
from types import SimpleNamespace
|
|||
|
|
|
|||
|
|
m = manifest()
|
|||
|
|
d = m["spec"]["dialogue"]
|
|||
|
|
eid1, eid2, cast1, cast2, listener, appearance = [f"{n:032x}" for n in range(90, 96)]
|
|||
|
|
imgs = ["a" * 32, "b" * 32]
|
|||
|
|
d["speakers"][0]["entity_id"] = eid1
|
|||
|
|
d["speakers"].append(dict(d["speakers"][0], id=listener, entity_id=eid2))
|
|||
|
|
m["spec"]["entities"] = [
|
|||
|
|
dict(id=eid1, reference_asset_ids=[imgs[0]]),
|
|||
|
|
dict(id=eid2, appearances=[dict(id=appearance, reference_asset_ids=[imgs[1]])]),
|
|||
|
|
]
|
|||
|
|
for sh in m["spec"]["shots"]:
|
|||
|
|
sh["cast"] = (
|
|||
|
|
[
|
|||
|
|
dict(id=cast1, entity_id=eid1),
|
|||
|
|
dict(id=cast2, entity_id=eid2, appearance_id=appearance),
|
|||
|
|
]
|
|||
|
|
if sh is m["spec"]["shots"][0]
|
|||
|
|
else []
|
|||
|
|
)
|
|||
|
|
m["spec"]["shots"][0]["performance"]["visible_speaker_ids"] = [S, listener]
|
|||
|
|
m["bindings"]["normalized_speech:" + U] = dict(
|
|||
|
|
asset_id=ASSET,
|
|||
|
|
sha256="f" * 64,
|
|||
|
|
kind="audio",
|
|||
|
|
source="generated",
|
|||
|
|
sample_rate=48000,
|
|||
|
|
sample_count=100001,
|
|||
|
|
)
|
|||
|
|
p = prepare_dialogue(m, m["bindings"], {})
|
|||
|
|
rows = e.production_recipes(
|
|||
|
|
p,
|
|||
|
|
{},
|
|||
|
|
dict(output_goal="film"),
|
|||
|
|
SimpleNamespace(),
|
|||
|
|
compile_story(p["effective_manifest"]["spec"], {}),
|
|||
|
|
)
|
|||
|
|
face = next(r for r in rows if r["kind"] == "video.dialogue.analyze")
|
|||
|
|
assert face["parameters"]["speaker_ids"] == [S, listener]
|
|||
|
|
assert face["input"]["reference_asset_ids"] == imgs
|
|||
|
|
lip = next(r for r in rows if r["kind"] == "video.lipsync")
|
|||
|
|
assert [s["speaker_id"] for s in lip["stems"]] == [S]
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_preview_requires_correct_audio_namespace():
|
|||
|
|
import pytest
|
|||
|
|
from fastapi import HTTPException
|
|||
|
|
from test_dialogue_domain import manifest, U
|
|||
|
|
from app.services.orchestration.dialogue_engine import preparation_recipes
|
|||
|
|
from types import SimpleNamespace
|
|||
|
|
|
|||
|
|
m = manifest()
|
|||
|
|
for target in ["audio:" + U, "speech:" + U]:
|
|||
|
|
if target.startswith("speech:"):
|
|||
|
|
m["spec"]["dialogue"]["enabled"] = False
|
|||
|
|
with pytest.raises(HTTPException) as rejected:
|
|||
|
|
preparation_recipes(
|
|||
|
|
m, {}, dict(output_goal="media", targets=[target]), SimpleNamespace(), {}
|
|||
|
|
)
|
|||
|
|
assert rejected.value.detail["code"] == "invalid_target"
|
|||
|
|
|
|||
|
|
|
|||
|
|
@pytest.mark.parametrize("base_locked", [False, True])
|
|||
|
|
def test_source_rest_replans_only_the_generated_speaking_base(base_locked):
|
|||
|
|
from types import SimpleNamespace
|
|||
|
|
from app.domain.stories import compile_story
|
|||
|
|
from app.domain.video_generation import H3_PROFILE
|
|||
|
|
from app.services.orchestration import dialogue_engine as e
|
|||
|
|
from test_dialogue_domain import A, B, U, S, ASSET, manifest
|
|||
|
|
from app.domain.dialogue import prepare_dialogue
|
|||
|
|
|
|||
|
|
m = manifest()
|
|||
|
|
prompts = ("抬头并轻声说话", "远景窗外路灯")
|
|||
|
|
m["spec"]["shots"][0]["performance"]["lip_sync"] = "required"
|
|||
|
|
entity_id = "e" * 32
|
|||
|
|
m["spec"]["entities"] = [dict(id=entity_id, name="林晚", kind="person")]
|
|||
|
|
m["spec"]["dialogue"]["speakers"][0]["entity_id"] = entity_id
|
|||
|
|
m["spec"]["shots"][0]["cast"] = [dict(id="f" * 32, entity_id=entity_id)]
|
|||
|
|
for shot, prompt in zip(m["spec"]["shots"], prompts, strict=True):
|
|||
|
|
shot["motion_prompt"] = prompt
|
|||
|
|
shot["video_parameters"]["profile"] = H3_PROFILE
|
|||
|
|
m["spec"]["shots"][0]["performance"]["visible_speaker_ids"] = [S]
|
|||
|
|
m["bindings"]["normalized_speech:" + U] = dict(
|
|||
|
|
asset_id=ASSET, sample_count=45000, sample_rate=48000, sha256="a" * 64,
|
|||
|
|
kind="audio", source="generated"
|
|||
|
|
)
|
|||
|
|
prepared = prepare_dialogue(m, m["bindings"], {})
|
|||
|
|
compiled = compile_story(m["spec"], {})
|
|||
|
|
body = {"output_goal": "film"}
|
|||
|
|
settings = SimpleNamespace()
|
|||
|
|
old_contract = {**e._final_render_contract(), "speech_silence_policy": "neutral-rest-v1"}
|
|||
|
|
prepared["final_render_contract"] = old_contract
|
|||
|
|
|
|||
|
|
def recipes(reusable):
|
|||
|
|
return {r["key"]: r for r in e.production_recipes(prepared, reusable, body, settings, compiled)}
|
|||
|
|
|
|||
|
|
old = recipes({})
|
|||
|
|
for sid, key in ((A, "video_0001"), (B, "video_0002")):
|
|||
|
|
m["bindings"]["base_video:" + sid] = dict(
|
|||
|
|
asset_id=(str(int(sid[-1])+5) * 32), kind="video", sha256="b" * 64,
|
|||
|
|
source="generated", context_hash=old[key]["context_hash"],
|
|||
|
|
generation_parameters=old[key]["parameters"], duration_frames=144,
|
|||
|
|
locked=base_locked and sid == A,
|
|||
|
|
)
|
|||
|
|
prepared["effective_manifest"]["bindings"].update(m["bindings"])
|
|||
|
|
effective = prepared["effective_manifest"]
|
|||
|
|
old_signatures = [
|
|||
|
|
e._shot_signature(prepared, shot, compiled_shot, effective)
|
|||
|
|
for shot, compiled_shot in zip(effective["spec"]["shots"], compiled["shots"], strict=True)
|
|||
|
|
]
|
|||
|
|
prepared["final_render_contract"] = {**old_contract, "speech_silence_policy": "source-rest-v2"}
|
|||
|
|
new = recipes(m["bindings"])
|
|||
|
|
new_signatures = [
|
|||
|
|
e._shot_signature(prepared, shot, compiled_shot, effective)
|
|||
|
|
for shot, compiled_shot in zip(effective["spec"]["shots"], compiled["shots"], strict=True)
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
assert "speech_silence_policy" not in old["lip_0001"]["parameters"]
|
|||
|
|
assert "source_visual_policy" not in old["review_0001"]["input"]["expected"]
|
|||
|
|
assert new["review_0001"]["repair_root"] == "video_0001"
|
|||
|
|
assert new["review_0001"]["input"]["expected"]["source_visual_policy"] == "pre-lipsync-visual-v1"
|
|||
|
|
assert "source_visual_policy" not in new["review_0002"]["input"]["expected"]
|
|||
|
|
assert new_signatures[0] != old_signatures[0]
|
|||
|
|
assert new_signatures[1] == old_signatures[1]
|
|||
|
|
assert new["lip_0001"]["parameters"]["speech_silence_policy"] == "source-rest-v2"
|
|||
|
|
assert new["syncqa_0001"]["parameters"]["speech_silence_policy"] == "source-rest-v2"
|
|||
|
|
if not base_locked:
|
|||
|
|
assert new["frame_0001"]["context_hash"] == old["frame_0001"]["context_hash"]
|
|||
|
|
assert new["stem_0001_1"]["input"] == old["stem_0001_1"]["input"]
|
|||
|
|
assert new["video_0002"]["reuse"] == m["bindings"]["base_video:" + B]
|
|||
|
|
assert prepared["effective_manifest"]["spec"]["shots"][0]["motion_prompt"] == prompts[0]
|
|||
|
|
speaking_base = new["video_0001"]
|
|||
|
|
if base_locked:
|
|||
|
|
assert speaking_base["reuse"] == m["bindings"]["base_video:" + A]
|
|||
|
|
assert not speaking_base.get("issue")
|
|||
|
|
else:
|
|||
|
|
assert speaking_base["reuse"] is None
|
|||
|
|
assert speaking_base["context_hash"] != old["video_0001"]["context_hash"]
|
|||
|
|
assert "嘴唇自然闭合" in speaking_base["input"]["prompt"]
|
|||
|
|
assert "后续配音" in speaking_base["input"]["prompt"]
|
|||
|
|
assert prompts[0] in speaking_base["input"]["prompt"]
|