MCPcopy Create free account
hub / github.com/Tencent/digitalhuman / StoryVideoGenerator

Class StoryVideoGenerator

ScriptAgent/code/director_agent.py:1605–2055  ·  view source on GitHub ↗

Responsible for script splitting, calling API to generate node videos, and synthesizing the final video.

Source from the content-addressed store, hash-verified

1603 return video_files, next_index, last_video
1604
1605class StoryVideoGenerator:
1606 """Responsible for script splitting, calling API to generate node videos, and synthesizing the final video."""
1607
1608 def __init__(
1609 self,
1610 api: Api,
1611 output_dir: str,
1612 model: str,
1613 size: str,
1614 seconds: int,
1615 max_retry: int,
1616 reference_mode: str,
1617 style_key: str,
1618 veo_aspect: Optional[str] = None,
1619 veo_audio: Optional[bool] = None,
1620 tts_estimator: Optional[PaddlespeechTTSDurationEstimator] = None,
1621 duration_padding: float = 1.5,
1622 reference_first_frame: Optional[str] = None,
1623 ) -> None:
1624 self.api = api
1625 self.output_dir = resolve_path(output_dir)
1626 self.model = model
1627 self.size = size
1628 self.seconds = seconds
1629 self.max_retry = max_retry
1630 if reference_mode not in REFERENCE_MODE_CHOICES:
1631 raise ValueError(f"Unknown reference image mode: {reference_mode}")
1632 self.reference_mode = reference_mode
1633 self.veo_aspect = veo_aspect
1634 self.veo_audio = veo_audio
1635 self.style_key = style_key
1636 self.tts_estimator = tts_estimator
1637 self.duration_padding = max(0.0, duration_padding)
1638 self.reference_first_frame = reference_first_frame
1639
1640 os.makedirs(self.output_dir, exist_ok=True)
1641 self._reference_spec: Optional[ReferenceImageSpec] = None
1642
1643 def _build_prompt(
1644 self,
1645 node_text: str,
1646 index: int,
1647 total: int,
1648 characters_text: str,
1649 scene_text: str,
1650 station_text: str,
1651 node_seconds: int,
1652 time_span: Optional[Tuple[int, int]] = None,
1653 ) -> str:
1654 segments = [
1655 CONTINUITY_PROMPT,
1656 STYLE_PROMPTS[self.style_key],
1657 f"Shot Number: {index}/{total}.",
1658 ]
1659
1660 # Add clear duration instructions
1661 if time_span is not None and time_span[1] > time_span[0]:
1662 # Has timestamp info, explain the time range from original script

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected