Prudvireddy commited on
Commit
41f517e
·
verified ·
1 Parent(s): 862e1e5

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +6 -5
tools.py CHANGED
@@ -128,11 +128,12 @@ def apply_zoom_in_effect(clip, zoom_factor=1.2):
128
  return clip.fl(zoom_in_effect, apply_to=['mask'])
129
 
130
  @tool
131
- def create_video_from_images_and_audio(images_dir, speeches_dir, zoom_factor=1.2):
132
  """Creates video using images and audios.
133
  Args:
134
  images_dir: path to images folder
135
- speeches_dir: path to speeches folder"""
 
136
  client = Groq(api_key='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')
137
  # images_paths = sorted(os.listdir(images_dir))
138
  # audio_paths = sorted(os.listdir(speeches_dir))
@@ -145,7 +146,7 @@ def create_video_from_images_and_audio(images_dir, speeches_dir, zoom_factor=1.2
145
  img_clip = ImageClip(os.path.join(images_dir, images_paths[i]))
146
  audioclip = AudioFileClip(os.path.join(speeches_dir, audio_paths[i]))
147
  videoclip = img_clip.set_duration(audioclip.duration)
148
- zoomed_clip = apply_zoom_in_effect(videoclip, zoom_factor)
149
 
150
  with open(os.path.join(speeches_dir, audio_paths[i]), "rb") as file:
151
  transcription = client.audio.transcriptions.create(
@@ -168,8 +169,8 @@ def create_video_from_images_and_audio(images_dir, speeches_dir, zoom_factor=1.2
168
  clips.append(final_clip)
169
 
170
  final_clip = concatenate_videoclips(clips)
171
- temp_final_video = tempfile.NamedTemporaryFile(delete=False, suffix='.mp4').name
172
- final_clip.write_videofile(temp_final_video, codec='libx264', fps=24)
173
 
174
  # Close all video files properly
175
  for clip in clips:
 
128
  return clip.fl(zoom_in_effect, apply_to=['mask'])
129
 
130
  @tool
131
+ def create_video_from_images_and_audio(images_dir, speeches_dir, final_video_filename):
132
  """Creates video using images and audios.
133
  Args:
134
  images_dir: path to images folder
135
+ speeches_dir: path to speeches folder
136
+ final_video_filename: the topic name which will be used as finla video file name"""
137
  client = Groq(api_key='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')
138
  # images_paths = sorted(os.listdir(images_dir))
139
  # audio_paths = sorted(os.listdir(speeches_dir))
 
146
  img_clip = ImageClip(os.path.join(images_dir, images_paths[i]))
147
  audioclip = AudioFileClip(os.path.join(speeches_dir, audio_paths[i]))
148
  videoclip = img_clip.set_duration(audioclip.duration)
149
+ zoomed_clip = apply_zoom_in_effect(videoclip, 1.3)
150
 
151
  with open(os.path.join(speeches_dir, audio_paths[i]), "rb") as file:
152
  transcription = client.audio.transcriptions.create(
 
169
  clips.append(final_clip)
170
 
171
  final_clip = concatenate_videoclips(clips)
172
+
173
+ final_clip.write_videofile(final_video_filename, codec='libx264', fps=24)
174
 
175
  # Close all video files properly
176
  for clip in clips: