返回 Pixelle-Video
content_narration.py
根目录 / pixelle_video / prompts / content_narration.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 Content narration generation prompt
15
16 For extracting/refining narrations from user-provided content.
17 """
18
19
20 CONTENT_NARRATION_PROMPT = """# Role Definition
21 Globally, you must strictly output copy in the corresponding language type according to the user's language type.
22 You are a professional content refinement expert, skilled at extracting core points from user-provided content and transforming them into scripts suitable for short videos.
23
24 # Core Task
25 The user will provide content (which may be long or short), and you need to extract narrations for {n_storyboard} video storyboards (for TTS to generate video audio).
26
27 # User-Provided Content
28 {content}
29
30 # Output Requirements
31
32 ## Narration Specifications
33 - Language consistency requirement: Strictly output copy according to the user's input language type - if input is English, output must be English, and so on
34 - Purpose: For TTS to generate short video audio
35 - Word count limit: Strictly control to {min_words}~{max_words} words (minimum not less than {min_words} words)
36 - Ending format: Do not use punctuation at the end
37 - Refinement strategy:
38 * If user content is long: Extract {n_storyboard} core points, remove redundant information
39 * If user content is short: Appropriately expand while retaining core viewpoints, add examples or explanations
40 * If user content is just right: Optimize expression to make it more suitable for voice narration
41 - Style requirement: Maintain the core viewpoint of user content, but express it in a more colloquial way suitable for TTS
42 - Opening suggestion: The first storyboard can use a question or scene introduction to attract audience attention
43 - Core content: Middle storyboards expand on the core points of user content
44 - Ending suggestion: The last storyboard provides a summary or inspiration
45 - Emotion and tone: Gentle, sincere, natural, like sharing viewpoints with a friend
46 - Prohibitions: No URLs, emojis, numeric numbering, no empty talk or clichés
47 - Word count check: After generation, must self-verify that each segment is not less than {min_words} words
48
49 ## Storyboard Coherence Requirements
50 - {n_storyboard} storyboards should expand based on the core viewpoint of user content, forming a complete expression
51 - Maintain logical coherence and natural transitions
52 - Each storyboard should sound like the same person narrating, with consistent tone
53 - Ensure the refined content is faithful to the user's original meaning, but more suitable for short video presentation
54
55 # Output Format
56 Strictly output in the following JSON format, do not add any additional text explanations:
57
58 ```json
59 {{
60 "narrations": [
61 "First {min_words}~{max_words} word narration",
62 "Second {min_words}~{max_words} word narration",
63 "Third {min_words}~{max_words} word narration"
64 ]
65 }}
66 ```
67
68 # Important Reminders
69 1. Only output JSON format content, do not add any explanations
70 2. Ensure JSON format is strictly correct and can be directly parsed by the program
71 3. Narrations must be strictly controlled between {min_words}~{max_words} words
72 4. Must output exactly {n_storyboard} storyboard narrations
73 5. Content must be faithful to the user's original meaning, but optimized for voice narration expression
74 6. Output format is {{"narrations": [narration array]}} JSON object
75
76 Now, please extract {n_storyboard} storyboard narrations from the above content. Only output JSON, no other content.
77 """
78
79
80 def build_content_narration_prompt(
81 content: str,
82 n_storyboard: int,
83 min_words: int,
84 max_words: int
85 ) -> str:
86 """
87 Build content refinement narration prompt
88
89 Args:
90 content: User-provided content
91 n_storyboard: Number of storyboard frames
92 min_words: Minimum word count
93 max_words: Maximum word count
94
95 Returns:
96 Formatted prompt
97 """
98 return CONTENT_NARRATION_PROMPT.format(
99 content=content,
100 n_storyboard=n_storyboard,
101 min_words=min_words,
102 max_words=max_words
103 )
104
105
105 lines PYTHON