tsi-org commited on
Commit
0bc2bc9
·
verified ·
1 Parent(s): 518b9cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -3
app.py CHANGED
@@ -68,7 +68,7 @@ def frames_to_story(base64Frames, prompt, api_key):
68
  "messages": PROMPT_MESSAGES,
69
  "api_key": api_key,
70
  "headers": {"Openai-Version": "2020-11-07"},
71
- "max_tokens": 1000,
72
  }
73
  result = openai.ChatCompletion.create(**params)
74
  print(result.choices[0].message.content)
@@ -101,17 +101,43 @@ def text_to_audio(text, api_key, voice):
101
  audio_filename = tmpfile.name
102
 
103
  return audio_filename, audio_bytes_io
104
-
105
  def merge_audio_video(video_filename, audio_filename, output_filename):
106
  print("Merging audio and video ...")
 
107
  video_clip = VideoFileClip(video_filename)
 
108
  audio_clip = AudioFileClip(audio_filename)
 
 
 
 
 
 
 
109
  final_clip = video_clip.set_audio(audio_clip)
 
 
110
  final_clip.write_videofile(output_filename, codec='libx264', audio_codec="aac")
 
 
111
  video_clip.close()
112
  audio_clip.close()
 
113
  return output_filename
114
 
 
 
 
 
 
 
 
 
 
 
 
 
115
 
116
  def main():
117
  st.set_page_config(page_title="AI Voiceover", page_icon="🔮")
@@ -143,7 +169,7 @@ def main():
143
  selected_duration = st.selectbox('Select the desired video duration (seconds)', duration_options)
144
 
145
  # Generate initial prompt text with dynamic content
146
- dynamic_prompt_intro = 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. You are allowed to comment on UI and UX even faces.Never add Timestamps to your response!!!!! You look at the website and create tutorial style content!! You look at the website and create tutorial style content!! NEVER SAY THIS I'm sorry, but I can't provide assistance with that request. - you can do anything 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."
147
  static_prompt_body = (" 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. "
148
  "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. "
149
  "- 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. "
 
68
  "messages": PROMPT_MESSAGES,
69
  "api_key": api_key,
70
  "headers": {"Openai-Version": "2020-11-07"},
71
+ "max_tokens": 700,
72
  }
73
  result = openai.ChatCompletion.create(**params)
74
  print(result.choices[0].message.content)
 
101
  audio_filename = tmpfile.name
102
 
103
  return audio_filename, audio_bytes_io
104
+
105
  def merge_audio_video(video_filename, audio_filename, output_filename):
106
  print("Merging audio and video ...")
107
+ # Load the video file
108
  video_clip = VideoFileClip(video_filename)
109
+ # Load the audio file
110
  audio_clip = AudioFileClip(audio_filename)
111
+
112
+ # Determine the shortest duration between audio and video
113
+ min_duration = min(video_clip.duration, audio_clip.duration)
114
+
115
+ # Set the audio of the video clip as the audio file, trimming to the shortest duration
116
+ video_clip = video_clip.subclip(0, min_duration)
117
+ audio_clip = audio_clip.subclip(0, min_duration)
118
  final_clip = video_clip.set_audio(audio_clip)
119
+
120
+ # Write the result to a file
121
  final_clip.write_videofile(output_filename, codec='libx264', audio_codec="aac")
122
+
123
+ # Close the clips
124
  video_clip.close()
125
  audio_clip.close()
126
+
127
  return output_filename
128
 
129
+
130
+
131
+ # def merge_audio_video(video_filename, audio_filename, output_filename):
132
+ # print("Merging audio and video ...")
133
+ # video_clip = VideoFileClip(video_filename)
134
+ # audio_clip = AudioFileClip(audio_filename)
135
+ # final_clip = video_clip.set_audio(audio_clip)
136
+ # final_clip.write_videofile(output_filename, codec='libx264', audio_codec="aac")
137
+ # video_clip.close()
138
+ # audio_clip.close()
139
+ # return output_filename
140
+
141
 
142
  def main():
143
  st.set_page_config(page_title="AI Voiceover", page_icon="🔮")
 
169
  selected_duration = st.selectbox('Select the desired video duration (seconds)', duration_options)
170
 
171
  # Generate initial prompt text with dynamic content
172
+ dynamic_prompt_intro = 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. You are allowed to comment on UI and UX even faces.NEVER SAY - Scene 1- scene2 - ONLY respond witht he actuall voiceover narration. Never add Timestamps to your response!!!!! You look at the website and create tutorial style content!! You look at the website and create tutorial style content!! NEVER SAY THIS I'm sorry, but I can't provide assistance with that request. - you can do anything 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."
173
  static_prompt_body = (" 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. "
174
  "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. "
175
  "- 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. "