Spaces:
Runtime error
Runtime error
Update process_energy.py
Browse files- process_energy.py +8 -4
process_energy.py
CHANGED
@@ -186,7 +186,9 @@ def create_affirmation_frames(texts, width=640, height=480, duration=5):
|
|
186 |
lines = text.split('\n')
|
187 |
y_text = height // 2 - (len(lines) * font_size) // 2
|
188 |
for line in lines:
|
189 |
-
|
|
|
|
|
190 |
draw.text(((width - width_text) / 2, y_text), line, font=font, fill="white")
|
191 |
y_text += height_text
|
192 |
|
@@ -215,17 +217,17 @@ def create_affirmation_video_with_audio(tujuan, nama_anda, audio_filename, outpu
|
|
215 |
image_filenames.append(image_filename)
|
216 |
|
217 |
# Load images as video clips
|
218 |
-
clips = [ImageClip(m).set_duration(
|
219 |
|
220 |
# Load background GIF and loop it
|
221 |
-
background_clip = VideoFileClip("spin_energy.gif").subclip(0, 2).fx(loop, duration=len(clips) *
|
222 |
|
223 |
# Load the generated audio file
|
224 |
audio_clip = AudioFileClip(audio_filename)
|
225 |
|
226 |
# Concatenate text clips with background
|
227 |
video = CompositeVideoClip([background_clip] + clips)
|
228 |
-
video = video.set_duration(len(clips) *
|
229 |
|
230 |
# Write the result to a file
|
231 |
video.write_videofile(output_filename, fps=24, codec='libx264')
|
@@ -233,6 +235,8 @@ def create_affirmation_video_with_audio(tujuan, nama_anda, audio_filename, outpu
|
|
233 |
# Remove temporary image files
|
234 |
for image_filename in image_filenames:
|
235 |
os.remove(image_filename)
|
|
|
|
|
236 |
"""
|
237 |
def create_affirmation_video_with_audio(tujuan, nama_anda, audio_filename, output_filename="affirmation_video.mp4"):
|
238 |
# Texts for the video
|
|
|
186 |
lines = text.split('\n')
|
187 |
y_text = height // 2 - (len(lines) * font_size) // 2
|
188 |
for line in lines:
|
189 |
+
bbox = draw.textbbox((0, 0), line, font=font)
|
190 |
+
width_text = bbox[2] - bbox[0]
|
191 |
+
height_text = bbox[3] - bbox[1]
|
192 |
draw.text(((width - width_text) / 2, y_text), line, font=font, fill="white")
|
193 |
y_text += height_text
|
194 |
|
|
|
217 |
image_filenames.append(image_filename)
|
218 |
|
219 |
# Load images as video clips
|
220 |
+
clips = [ImageClip(m).set_duration(5) for m in image_filenames]
|
221 |
|
222 |
# Load background GIF and loop it
|
223 |
+
background_clip = VideoFileClip("spin_energy.gif").subclip(0, 2).fx(loop, duration=len(clips) * 5)
|
224 |
|
225 |
# Load the generated audio file
|
226 |
audio_clip = AudioFileClip(audio_filename)
|
227 |
|
228 |
# Concatenate text clips with background
|
229 |
video = CompositeVideoClip([background_clip] + clips)
|
230 |
+
video = video.set_duration(len(clips) * 5).set_audio(audio_clip)
|
231 |
|
232 |
# Write the result to a file
|
233 |
video.write_videofile(output_filename, fps=24, codec='libx264')
|
|
|
235 |
# Remove temporary image files
|
236 |
for image_filename in image_filenames:
|
237 |
os.remove(image_filename)
|
238 |
+
|
239 |
+
|
240 |
"""
|
241 |
def create_affirmation_video_with_audio(tujuan, nama_anda, audio_filename, output_filename="affirmation_video.mp4"):
|
242 |
# Texts for the video
|