{
  "format": "mosael-workflow",
  "version": 1,
  "workflow_revision": 1,
  "name": "Digital human of any length",
  "description": "One portrait and one script: it voices the script, cuts it into segments and has the person speak on from the tail of the last, joined into one unbroken video. Needs consent for the face and voice.",
  "graph_hash": "31aa15082ed5f1464ba060b69ff8ed66765d145accdf06309ac864e2cd23e0fb",
  "graph": {
    "meta": {
      "template_id": "long_talk_video",
      "template_version": 5,
      "source": "official"
    },
    "nodes": [
      {
        "id": "start",
        "type": "start",
        "name": "Start",
        "position": {
          "x": 40,
          "y": 300
        },
        "config": {
          "params": {
            "script": "",
            "face_asset_id": "",
            "voice_id": "",
            "scene": "",
            "consent": "",
            "segment_seconds": 10.125,
            "overlap_seconds": 1.625
          },
          "required_params": [
            "script",
            "face_asset_id",
            "voice_id",
            "consent"
          ],
          "param_options": {
            "consent": [
              {
                "value": "yes",
                "label": "已取得授权 / Consent obtained"
              }
            ]
          }
        }
      },
      {
        "id": "speak",
        "type": "synthesize_speech",
        "name": "Voice the script",
        "position": {
          "x": 340,
          "y": 300
        },
        "config": {
          "text": "{{start.script}}",
          "engine": "builtin:clone",
          "voice": "{{start.voice_id}}"
        }
      },
      {
        "id": "tighten",
        "type": "tighten_pauses",
        "name": "Tighten the pauses",
        "position": {
          "x": 490,
          "y": 460
        },
        "config": {
          "asset_id": "",
          "max_pause": 0.6
        },
        "inputs": [
          "asset_id"
        ]
      },
      {
        "id": "voice_info",
        "type": "asset",
        "name": "How long the voice runs",
        "position": {
          "x": 640,
          "y": 300
        },
        "config": {
          "asset_id": ""
        },
        "inputs": [
          "asset_id"
        ]
      },
      {
        "id": "plan",
        "type": "chain_plan",
        "name": "Work out how many segments",
        "position": {
          "x": 940,
          "y": 300
        },
        "config": {
          "target_seconds": "",
          "longest_seconds": "{{start.segment_seconds}}",
          "allowed_seconds": "{{start.segment_seconds}}",
          "overlap_seconds": "{{start.overlap_seconds}}",
          "fps": 24,
          "shortest_seconds": 5.166666666666667
        },
        "inputs": [
          "target_seconds"
        ]
      },
      {
        "id": "video_project",
        "type": "project_sequence_create",
        "name": "Create the project and timeline",
        "position": {
          "x": 940,
          "y": 60
        },
        "config": {
          "name": "数字人",
          "fps": 24,
          "width": 1920,
          "height": 1080
        }
      },
      {
        "id": "voice_open",
        "type": "media_clip",
        "name": "Take the voice for the first segment",
        "position": {
          "x": 1240,
          "y": 300
        },
        "config": {
          "asset_id": "",
          "start": 0,
          "end": ""
        },
        "inputs": [
          "asset_id",
          "end"
        ]
      },
      {
        "id": "opening",
        "type": "ai_generate",
        "name": "Speak the first segment",
        "position": {
          "x": 1540,
          "y": 300
        },
        "config": {
          "provider": "",
          "provider_profile_id": "",
          "model": "",
          "kind": "video",
          "prompt": "<Picture 1> is the person in the reference photo; keep the face, hair and clothes exactly. {{start.scene}} Highest priority: whenever the person is on screen the mouth keeps speaking, the lips, jaw and cheeks follow <Audio 1> syllable by syllable, opening and closing naturally every half second, teeth and the inside of the mouth visible. Photorealistic documentary footage, real skin with pores, natural micro-expressions, eye blinks, subtle breathing, natural available light, film grain, no beauty filter, no CGI look. One continuous shot, the camera stays still, no cut.",
          "parameters": {
            "52.project_folder": "mosael/{{video_project.project_id}}",
            "52.scene_number": 1,
            "7.length": "{{plan.opening_frames}}"
          },
          "source_assets": [
            "{{start.face_asset_id}}:reference_image",
            "{{voice_open.asset_id}}:driving_audio"
          ],
          "consent": "{{start.consent}}"
        }
      },
      {
        "id": "segments",
        "type": "loop_foreach",
        "name": "Speak segment after segment",
        "position": {
          "x": 1840,
          "y": 300
        },
        "config": {
          "items": "",
          "inputs": {
            "scene": "{{start.scene}}",
            "consent": "{{start.consent}}",
            "face_asset_id": "{{start.face_asset_id}}",
            "voice_asset_id": "{{tighten.asset_id}}",
            "latent_folder": "mosael/{{video_project.project_id}}",
            "overlap_seconds": "{{start.overlap_seconds}}"
          },
          "body": {
            "nodes": [
              {
                "id": "voice",
                "type": "media_clip",
                "name": "Take the voice for this segment",
                "position": {
                  "x": 80,
                  "y": 260
                },
                "config": {
                  "asset_id": "{{input.voice_asset_id}}",
                  "start": "{{loop.item.clip_from}}",
                  "end": "{{loop.item.to_seconds}}"
                }
              },
              {
                "id": "extend",
                "type": "ai_generate",
                "name": "Carry on speaking",
                "position": {
                  "x": 390,
                  "y": 140
                },
                "config": {
                  "provider": "",
                  "provider_profile_id": "",
                  "model": "",
                  "kind": "video",
                  "prompt": "<Picture 1> is the person in the reference photo; keep the face, hair and clothes exactly. {{input.scene}} Highest priority: whenever the person is on screen the mouth keeps speaking, the lips, jaw and cheeks follow <Audio 1> syllable by syllable, opening and closing naturally every half second, teeth and the inside of the mouth visible. Photorealistic documentary footage, real skin with pores, natural micro-expressions, eye blinks, subtle breathing, natural available light, film grain, no beauty filter, no CGI look. One continuous shot, the camera stays still, no cut.",
                  "parameters": {
                    "50.project_folder": "{{input.latent_folder}}",
                    "50.scene_number": "{{loop.item.previous_scene}}",
                    "52.project_folder": "{{input.latent_folder}}",
                    "52.scene_number": "{{loop.item.scene}}",
                    "7.length": "{{loop.item.frames}}"
                  },
                  "source_assets": [
                    "{{input.face_asset_id}}:reference_image",
                    "{{voice.asset_id}}:driving_audio"
                  ],
                  "consent": "{{input.consent}}"
                }
              }
            ],
            "edges": [
              {
                "id": "voice_extend",
                "source": "voice",
                "target": "extend"
              }
            ]
          },
          "output": "{{extend.asset_id}}",
          "previous_initial": ""
        },
        "inputs": [
          "items",
          "previous_initial"
        ]
      },
      {
        "id": "clear_timeline",
        "type": "timeline_clear",
        "name": "Clear the timeline",
        "position": {
          "x": 2140,
          "y": 300
        },
        "config": {
          "sequence_id": ""
        },
        "inputs": [
          "sequence_id"
        ]
      },
      {
        "id": "append_opening",
        "type": "timeline_append",
        "name": "Lay down the first segment",
        "position": {
          "x": 2440,
          "y": 300
        },
        "config": {
          "sequence_id": "",
          "asset_id": ""
        },
        "inputs": [
          "sequence_id",
          "asset_id"
        ]
      },
      {
        "id": "assemble",
        "type": "loop_foreach",
        "name": "Add every later segment",
        "position": {
          "x": 2740,
          "y": 300
        },
        "config": {
          "items": "",
          "inputs": {
            "sequence_id": "{{video_project.sequence_id}}",
            "overlap_seconds": "{{start.overlap_seconds}}"
          },
          "body": {
            "nodes": [
              {
                "id": "append_segment",
                "type": "timeline_append",
                "name": "Add it to the timeline",
                "position": {
                  "x": 80,
                  "y": 140
                },
                "config": {
                  "sequence_id": "{{input.sequence_id}}",
                  "start": "{{input.overlap_seconds}}",
                  "asset_id": "{{loop.item}}"
                }
              }
            ],
            "edges": []
          },
          "output": "{{loop.item}}"
        },
        "inputs": [
          "items"
        ]
      },
      {
        "id": "export_final",
        "type": "export_sequence",
        "name": "Export the finished video",
        "position": {
          "x": 3040,
          "y": 300
        },
        "config": {
          "sequence_id": "",
          "quality": "high"
        },
        "inputs": [
          "sequence_id"
        ]
      },
      {
        "id": "output",
        "type": "output",
        "name": "Hand over the finished video",
        "position": {
          "x": 3340,
          "y": 300
        },
        "config": {
          "values": {
            "video_asset_id": "{{export_final.asset_id}}",
            "segments": "{{segments.results}}"
          }
        }
      }
    ],
    "edges": [
      {
        "id": "start_speak",
        "source": "start",
        "target": "speak"
      },
      {
        "id": "speak_tighten",
        "source": "speak",
        "target": "tighten"
      },
      {
        "id": "tighten_info",
        "source": "tighten",
        "target": "voice_info"
      },
      {
        "id": "info_plan",
        "source": "voice_info",
        "target": "plan"
      },
      {
        "id": "plan_project",
        "source": "plan",
        "target": "video_project"
      },
      {
        "id": "plan_voice",
        "source": "plan",
        "target": "voice_open"
      },
      {
        "id": "project_opening",
        "source": "video_project",
        "target": "opening"
      },
      {
        "id": "voice_opening",
        "source": "voice_open",
        "target": "opening"
      },
      {
        "id": "opening_segments",
        "source": "opening",
        "target": "segments"
      },
      {
        "id": "segments_clear",
        "source": "segments",
        "target": "clear_timeline"
      },
      {
        "id": "clear_opening",
        "source": "clear_timeline",
        "target": "append_opening"
      },
      {
        "id": "opening_assemble",
        "source": "append_opening",
        "target": "assemble"
      },
      {
        "id": "assemble_export",
        "source": "assemble",
        "target": "export_final"
      },
      {
        "id": "export_output",
        "source": "export_final",
        "target": "output"
      },
      {
        "id": "d-speak-asset_id-tighten-asset_id",
        "source": "speak",
        "target": "tighten",
        "kind": "data",
        "source_output": "asset_id",
        "target_input": "asset_id"
      },
      {
        "id": "d-tighten-asset_id-voice_info-asset_id",
        "source": "tighten",
        "target": "voice_info",
        "kind": "data",
        "source_output": "asset_id",
        "target_input": "asset_id"
      },
      {
        "id": "d-voice_info-duration-plan-target_seconds",
        "source": "voice_info",
        "target": "plan",
        "kind": "data",
        "source_output": "duration",
        "target_input": "target_seconds"
      },
      {
        "id": "d-tighten-asset_id-voice_open-asset_id",
        "source": "tighten",
        "target": "voice_open",
        "kind": "data",
        "source_output": "asset_id",
        "target_input": "asset_id"
      },
      {
        "id": "d-plan-opening_seconds-voice_open-end",
        "source": "plan",
        "target": "voice_open",
        "kind": "data",
        "source_output": "opening_seconds",
        "target_input": "end"
      },
      {
        "id": "d-plan-rounds-segments-items",
        "source": "plan",
        "target": "segments",
        "kind": "data",
        "source_output": "rounds",
        "target_input": "items"
      },
      {
        "id": "d-opening-asset_id-segments-previous_initial",
        "source": "opening",
        "target": "segments",
        "kind": "data",
        "source_output": "asset_id",
        "target_input": "previous_initial"
      },
      {
        "id": "d-video_project-sequence_id-clear_timeline-sequence_id",
        "source": "video_project",
        "target": "clear_timeline",
        "kind": "data",
        "source_output": "sequence_id",
        "target_input": "sequence_id"
      },
      {
        "id": "d-video_project-sequence_id-append_opening-sequence_id",
        "source": "video_project",
        "target": "append_opening",
        "kind": "data",
        "source_output": "sequence_id",
        "target_input": "sequence_id"
      },
      {
        "id": "d-opening-asset_id-append_opening-asset_id",
        "source": "opening",
        "target": "append_opening",
        "kind": "data",
        "source_output": "asset_id",
        "target_input": "asset_id"
      },
      {
        "id": "d-segments-results-assemble-items",
        "source": "segments",
        "target": "assemble",
        "kind": "data",
        "source_output": "results",
        "target_input": "items"
      },
      {
        "id": "d-video_project-sequence_id-export_final-sequence_id",
        "source": "video_project",
        "target": "export_final",
        "kind": "data",
        "source_output": "sequence_id",
        "target_input": "sequence_id"
      }
    ]
  }
}
