testdeep123 commited on
Commit
706e84e
·
verified ·
1 Parent(s): 6d16694

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -434,7 +434,7 @@ def generate_media(prompt, user_image=None, current_index=0, total_segments=1):
434
  else:
435
  print(f"Google Images search failed for prompt: {prompt}")
436
 
437
- if random.random() < 0.25:
438
  video_file = os.path.join(TEMP_FOLDER, f"{safe_prompt}_video.mp4")
439
  video_url = search_pexels_videos(prompt, PEXELS_API_KEY)
440
  if video_url:
@@ -494,8 +494,8 @@ def generate_tts(text, voice):
494
  return file_path
495
 
496
  try:
497
- kokoro_voice = 'af_heart' if voice == 'en' else voice
498
- generator = pipeline(text, voice=kokoro_voice, speed=0.9, split_pattern=r'\n+')
499
  audio_segments = []
500
  for i, (gs, ps, audio) in enumerate(generator):
501
  audio_segments.append(audio)
@@ -719,7 +719,7 @@ def create_clip(media_path, asset_type, tts_path, duration=None, effects=None, n
719
  print(f"Subtitle error: {sub_error}")
720
  txt_clip = TextClip(
721
  narration_text,
722
- fontsize=28,
723
  color=CAPTION_COLOR,
724
  align='center',
725
  size=(TARGET_RESOLUTION[0] * 0.7, None)
@@ -839,10 +839,10 @@ def generate_video(user_input, resolution, caption_option):
839
 
840
  print("\nConcatenating clips...")
841
  final_video = concatenate_videoclips(clips, method="compose")
842
- final_video = add_background_music(final_video, bg_music_volume=0.08)
843
 
844
  print(f"Exporting final video to {OUTPUT_VIDEO_FILENAME}...")
845
- final_video.write_videofile(OUTPUT_VIDEO_FILENAME, codec='libx264', fps=30, preset='veryfast')
846
  print(f"Final video saved as {OUTPUT_VIDEO_FILENAME}")
847
 
848
  # Clean up
 
434
  else:
435
  print(f"Google Images search failed for prompt: {prompt}")
436
 
437
+ if random.random() < video_clip_probability:
438
  video_file = os.path.join(TEMP_FOLDER, f"{safe_prompt}_video.mp4")
439
  video_url = search_pexels_videos(prompt, PEXELS_API_KEY)
440
  if video_url:
 
494
  return file_path
495
 
496
  try:
497
+ kokoro_voice = selected_voice if voice == 'en' else voice
498
+ generator = pipeline(text, voice=kokoro_voice, speed=voice_speed, split_pattern=r'\n+')
499
  audio_segments = []
500
  for i, (gs, ps, audio) in enumerate(generator):
501
  audio_segments.append(audio)
 
719
  print(f"Subtitle error: {sub_error}")
720
  txt_clip = TextClip(
721
  narration_text,
722
+ fontsize=font_size,
723
  color=CAPTION_COLOR,
724
  align='center',
725
  size=(TARGET_RESOLUTION[0] * 0.7, None)
 
839
 
840
  print("\nConcatenating clips...")
841
  final_video = concatenate_videoclips(clips, method="compose")
842
+ final_video = add_background_music(final_video, bg_music_volume=bg_music_volume)
843
 
844
  print(f"Exporting final video to {OUTPUT_VIDEO_FILENAME}...")
845
+ final_video.write_videofile(OUTPUT_VIDEO_FILENAME, codec='libx264', fps=fps, preset=preset)
846
  print(f"Final video saved as {OUTPUT_VIDEO_FILENAME}")
847
 
848
  # Clean up