tsi-org commited on
Commit
06855bc
·
verified ·
1 Parent(s): d6762a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -8
app.py CHANGED
@@ -199,23 +199,34 @@ def main():
199
  prompt = st.text_area("Edit the voiceover script prompt as needed:", value=initial_prompt.format(selected_duration=selected_duration), height=300)
200
 
201
 
202
- if uploaded_file is not None and st.button("START PROCESSING"):
203
  with st.spinner("Processing..."):
 
 
 
 
 
 
 
204
  base64Frame, video_filename, video_duration = video_to_frames(uploaded_file, 1)
205
- prompt = script_templates[selected_script_type]
206
  text = frames_to_story(base64Frame, prompt, openai_key)
207
  audio_filename = text_to_audio(text, openai_key, voice_options[voice])
208
  output_video_filename = os.path.splitext(video_filename)[0] + "_output.mp4"
209
- final_video_filename = merge_audio_video(video_filename, audio_filename, output_video_filename, overlay_audio_file)
210
- st.video(final_video_filename)
 
 
211
 
212
- os.remove(video_filename)
213
- os.remove(audio_filename)
214
- os.remove(final_video_filename)
 
 
 
215
 
216
  if __name__ == "__main__":
217
  main()
218
-
219
  # from dotenv import load_dotenv
220
  # import streamlit as st
221
  # from moviepy.editor import VideoFileClip, concatenate_videoclips, AudioFileClip
 
199
  prompt = st.text_area("Edit the voiceover script prompt as needed:", value=initial_prompt.format(selected_duration=selected_duration), height=300)
200
 
201
 
202
+ if uploaded_file is not None and st.button("START PROCESSING"):
203
  with st.spinner("Processing..."):
204
+ # Assuming save_temporary_audio_file and other necessary functions are defined
205
+ # Ensure overlay_audio_file is saved to a temporary file if present
206
+ overlay_audio_path = None
207
+ if overlay_audio_file is not None:
208
+ overlay_audio_path = save_temporary_audio_file(overlay_audio_file)
209
+
210
+ # Process the uploaded video file
211
  base64Frame, video_filename, video_duration = video_to_frames(uploaded_file, 1)
212
+ prompt = script_templates.get(selected_script_type, "Default prompt if script type not found").format(selected_duration=selected_duration)
213
  text = frames_to_story(base64Frame, prompt, openai_key)
214
  audio_filename = text_to_audio(text, openai_key, voice_options[voice])
215
  output_video_filename = os.path.splitext(video_filename)[0] + "_output.mp4"
216
+ final_video_filename = merge_audio_video(video_filename, audio_filename, output_video_filename, overlay_audio_path)
217
+
218
+ if final_video_filename:
219
+ st.video(final_video_filename)
220
 
221
+ # Cleanup
222
+ os.remove(video_filename)
223
+ os.remove(audio_filename)
224
+ if overlay_audio_path:
225
+ os.remove(overlay_audio_path)
226
+ # Consider how to handle final_video_filename as it might be needed for the user to download/view
227
 
228
  if __name__ == "__main__":
229
  main()
 
230
  # from dotenv import load_dotenv
231
  # import streamlit as st
232
  # from moviepy.editor import VideoFileClip, concatenate_videoclips, AudioFileClip