Spaces:
Running
Running
Commit
·
f96caac
1
Parent(s):
6621c82
fix model names.
Browse files
app.py
CHANGED
@@ -105,6 +105,11 @@ def generate_srt(segments):
|
|
105 |
return srt.compose(subtitles)
|
106 |
|
107 |
def prepare_chapter_prompt(srt_text):
|
|
|
|
|
|
|
|
|
|
|
108 |
system_prompt = (
|
109 |
"You are a highly skilled video content segmentation and optimization expert. "
|
110 |
"Your task is to analyze a transcript of a YouTube video provided in SRT format and produce engaging and concise chapter headers. "
|
@@ -113,6 +118,7 @@ def prepare_chapter_prompt(srt_text):
|
|
113 |
"- 'Chapter Title' must be a catchy, audience-friendly title that summarizes the key idea or transition at that point in the video.\n\n"
|
114 |
"IMPORTANT: Although these instructions are in English, please ensure that your output is in the same language as the provided SRT transcript."
|
115 |
)
|
|
|
116 |
user_prompt = (
|
117 |
"Below is the transcript of a YouTube video in SRT format:\n\n"
|
118 |
"```\n"
|
@@ -122,7 +128,9 @@ def prepare_chapter_prompt(srt_text):
|
|
122 |
"Each chapter header should be formatted as:\n"
|
123 |
"mm:ss Chapter Title"
|
124 |
)
|
125 |
-
|
|
|
|
|
126 |
|
127 |
def format_prompt_html(prompt):
|
128 |
"""
|
@@ -184,7 +192,7 @@ iface = gr.Interface(
|
|
184 |
description=(
|
185 |
"Upload an audio file (e.g., MP3) of your YouTube video and select the audio language. "
|
186 |
"The app will transcribe the audio using Whisper, generate subtitles in SRT format, "
|
187 |
-
"and prepare a single, complete prompt that instructs ChatGPT
|
188 |
"Click the 'Copy Prompt' button to copy the entire prompt, and a brief 'Prompt Copied!' message will appear."
|
189 |
)
|
190 |
)
|
|
|
105 |
return srt.compose(subtitles)
|
106 |
|
107 |
def prepare_chapter_prompt(srt_text):
|
108 |
+
"""
|
109 |
+
Prepare a complete prompt (system + user instructions) for ChatGPT models.
|
110 |
+
Although the prompt is in English, it instructs the model to output chapter headers in the same language as the provided SRT transcript.
|
111 |
+
The output format should be one chapter per line: "mm:ss Chapter Title".
|
112 |
+
"""
|
113 |
system_prompt = (
|
114 |
"You are a highly skilled video content segmentation and optimization expert. "
|
115 |
"Your task is to analyze a transcript of a YouTube video provided in SRT format and produce engaging and concise chapter headers. "
|
|
|
118 |
"- 'Chapter Title' must be a catchy, audience-friendly title that summarizes the key idea or transition at that point in the video.\n\n"
|
119 |
"IMPORTANT: Although these instructions are in English, please ensure that your output is in the same language as the provided SRT transcript."
|
120 |
)
|
121 |
+
|
122 |
user_prompt = (
|
123 |
"Below is the transcript of a YouTube video in SRT format:\n\n"
|
124 |
"```\n"
|
|
|
128 |
"Each chapter header should be formatted as:\n"
|
129 |
"mm:ss Chapter Title"
|
130 |
)
|
131 |
+
|
132 |
+
final_prompt = system_prompt + "\n\n" + user_prompt
|
133 |
+
return final_prompt
|
134 |
|
135 |
def format_prompt_html(prompt):
|
136 |
"""
|
|
|
192 |
description=(
|
193 |
"Upload an audio file (e.g., MP3) of your YouTube video and select the audio language. "
|
194 |
"The app will transcribe the audio using Whisper, generate subtitles in SRT format, "
|
195 |
+
"and prepare a single, complete prompt that instructs ChatGPT -> o1 model to generate a chapter breakdown in the format 'mm:ss Chapter Title'.\n\n"
|
196 |
"Click the 'Copy Prompt' button to copy the entire prompt, and a brief 'Prompt Copied!' message will appear."
|
197 |
)
|
198 |
)
|