tsi-org commited on
Commit
7d0a5a1
·
verified ·
1 Parent(s): b22f90d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -8
app.py CHANGED
@@ -164,10 +164,9 @@ def main():
164
  option = st.selectbox('Choose the voice you want', list(voice_options.keys()))
165
  classify = voice_options[option]
166
 
167
- duration_options = list(range(10, 121, 10)) # 10 to 120 seconds, in 10 second intervals
168
  selected_duration = st.selectbox('Select the desired video duration (seconds)', duration_options)
169
 
170
- # New dropdown for script generator type
171
  script_type_options = {
172
  'Product Tutorial': 'Product Tutorial',
173
  'TikTok': 'TikTok',
@@ -177,17 +176,35 @@ def main():
177
  }
178
  selected_script_type = st.selectbox('Choose the script generator type', list(script_type_options.keys()))
179
 
180
- # Incorporating the selected script type and duration into the prompt
181
- dynamic_prompt_intro = f"Script type: {selected_script_type}. Generate a voiceover script that is approximately {selected_duration} seconds long, tailored to the content and format of a {selected_script_type.lower()}."
182
-
183
- prompt = st.text_area("Edit the voiceover script prompt as needed:", value=dynamic_prompt_intro, height=300)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
 
185
  if uploaded_file is not None and st.button("START PROCESSING", type="primary"):
186
  with st.spinner("Video is being processed..."):
187
  base64Frame, video_filename, video_duration = video_to_frames(uploaded_file, frame_sampling_rate=1)
188
 
189
- if video_duration > selected_duration:
190
- st.error(f"The video exceeds the selected duration of {selected_duration} seconds.")
191
  return
192
 
193
  text = frames_to_story(base64Frame, prompt, openai_key)
 
164
  option = st.selectbox('Choose the voice you want', list(voice_options.keys()))
165
  classify = voice_options[option]
166
 
167
+ duration_options = list(range(10, 121, 10)) # 10 to 120 seconds, in 10-second intervals
168
  selected_duration = st.selectbox('Select the desired video duration (seconds)', duration_options)
169
 
 
170
  script_type_options = {
171
  'Product Tutorial': 'Product Tutorial',
172
  'TikTok': 'TikTok',
 
176
  }
177
  selected_script_type = st.selectbox('Choose the script generator type', list(script_type_options.keys()))
178
 
179
+ # Define unique prompt templates for each script type, including the dynamic content for "Product Tutorial"
180
+ script_templates = {
181
+ 'Product Tutorial': f"Lets roleplay you are a script generator for tutorials. Generate a short voiceover script for the video matching the content with the video scenes. Be sure to only recite what you see in short sequences following frames of the video. You are allowed to comment on UI and UX even faces. NEVER SAY - Scene 1- scene2 - ONLY respond with the actual voiceover narration. Never add Timestamps to your response! You look at the website and create tutorial style content!! The app is called Pixio. The style should be fun and engaging. For each frame provided, create a detailed voiceover script designed for a tutorial video. Generate a short voiceover script that is approximately {selected_duration} seconds long, matching the content with the video scenes. " +
182
+ "The app is called Pixio. The style should be fun and engaging. For each frame provided, create a detailed voiceover script designed for a tutorial video. " +
183
+ "Never say 'Female 2' or 'VoiceOver' in responses. You output a script to be spoken! - Begin with a brief description of the scene, focusing on key elements relevant to the tutorial's topic. " +
184
+ "- Provide step-by-step instructions or explanations for any actions, processes, or concepts shown in the frame. Use clear and concise language suitable for educational content. " +
185
+ "- Highlight important details or features within the frame that the audience should pay attention to, explaining their significance in the context of the tutorial. " +
186
+ "- Include questions or prompts when appropriate to encourage viewer engagement and reflection on the material presented. " +
187
+ "- Where applicable, draw connections between the content in the current frame and previous frames to build a cohesive narrative or instructional flow. " +
188
+ "- End with a short summary or teaser of what to expect next, maintaining the viewer’s interest and facilitating a smooth transition between sections of the tutorial. " +
189
+ "The goal is to transform the visual information into an accessible and compelling educational narrative that enhances the viewer's understanding and retention of the subject matter.",
190
+ 'TikTok': "Create a captivating and concise script suitable for a TikTok audience, focusing on quick engagement...",
191
+ 'YouTube Short': "Craft a script that captures attention for YouTube Shorts, keeping it informative and direct...",
192
+ 'Website Tutorial': "Develop a detailed and instructive script for navigating and explaining website features...",
193
+ 'General Info': "Provide a general overview script that is informative and broad, suitable for a diverse audience..."
194
+ }
195
+
196
+ # Generate the initial prompt based on selected script type
197
+ initial_prompt = script_templates[selected_script_type]
198
+
199
+ # Allow the user to edit the prompt
200
+ prompt = st.text_area("Edit the voiceover script prompt as needed:", value=initial_prompt.format(selected_duration=selected_duration), height=300)
201
 
202
  if uploaded_file is not None and st.button("START PROCESSING", type="primary"):
203
  with st.spinner("Video is being processed..."):
204
  base64Frame, video_filename, video_duration = video_to_frames(uploaded_file, frame_sampling_rate=1)
205
 
206
+ if video_duration > 120:
207
+ st.error("The video exceeds the maximum allowed duration of 120 seconds.")
208
  return
209
 
210
  text = frames_to_story(base64Frame, prompt, openai_key)