返回 Pixelle-Video
asset_script_generation.py
根目录 / pixelle_video / prompts / asset_script_generation.py
1 # Copyright (C) 2025 AIDC-AI
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
12
13 """
14 Asset-based video script generation prompt
15
16 For generating video scripts based on user-provided assets.
17 """
18
19
20 ASSET_SCRIPT_GENERATION_PROMPT = """You are a professional video script creator. Based on the user's video intent and available assets, generate a {duration}-second video script. Before doing so, you need to detect the user's input language - if it's English, then all copy must be in English. Strictly follow the user's input language type as the standard, ensuring consistent and corresponding copy!
21
22 ## Requirements
23 {title_section}- Video Intent: {intent}
24 - Target Duration: {duration} seconds
25
26 ## Available Assets (use exact paths in output)
27 {assets_text}
28
29 ## Creation Guidelines
30 1. Strictly output copy according to the user's input language type - if input is English, output must be English, and so on
31 2. Determine the number of scenes based on target duration (typically 5-15 seconds per scene)
32 3. Assign one asset from available assets to each scene
33 4. Each scene can contain 1-3 narration sentences
34 5. Try to use all available assets, but assets can be reused if needed
35 6. Total duration of all scenes should approximately equal {duration} seconds
36 {title_instruction}
37
38 ## Language Consistency Requirements (Strictly Enforce)
39 - Narration language must match the user's input video intent
40 - If video intent is in Chinese, narration must be in Chinese
41 - If video intent is in English, narration must be in English
42 - Unless the video intent explicitly specifies an output language, strictly follow the original language of the intent
43
44 ## Output Requirements
45 Provide for each scene:
46 - scene_number: Scene number (starting from 1)
47 - asset_path: Exact path selected from available assets list
48 - narrations: Array containing 1-3 narration sentences
49 - duration: Estimated duration (seconds)
50
51 Now please begin generating the video script:"""
52
53
54 def build_asset_script_prompt(
55 intent: str,
56 duration: int,
57 assets_text: str,
58 title: str = ""
59 ) -> str:
60 """
61 Build asset-based script generation prompt
62
63 Args:
64 intent: Video intent/purpose
65 duration: Target duration in seconds
66 assets_text: Formatted text of available assets with descriptions
67 title: Optional video title
68
69 Returns:
70 Formatted prompt
71 """
72 title_section = f"- Video Title: {title}\n" if title else ""
73 title_instruction = f"6. Narration content should be consistent with the video title: {title}\n" if title else ""
74
75 return ASSET_SCRIPT_GENERATION_PROMPT.format(
76 duration=duration,
77 title_section=title_section,
78 intent=intent,
79 assets_text=assets_text,
80 title_instruction=title_instruction
81 )
82
82 lines PYTHON