shaheerawan3 commited on
Commit
1315880
·
verified ·
1 Parent(s): 1ab4e27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -503,6 +503,20 @@ class EnhancedVideoGenerator:
503
  self.ELEVEN_LABS_API_KEY = "sk_acdad9d2d82d504bddbe5ed4aa290ca772c106aed5b128ba" # Replace with your key
504
 
505
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
506
  def apply_video_effects(self, frame: np.ndarray, effect_params: dict) -> np.ndarray:
507
  """Apply various video effects to a frame"""
508
  try:
 
503
  self.ELEVEN_LABS_API_KEY = "sk_acdad9d2d82d504bddbe5ed4aa290ca772c106aed5b128ba" # Replace with your key
504
 
505
 
506
+
507
+ def generate_fallback_audio(self, script: str) -> AudioFileClip:
508
+ """Generate fallback audio using gTTS when primary audio generation fails"""
509
+ try:
510
+ audio_path = self.temp_dir / "voice.mp3"
511
+ tts = gTTS(text=script, lang='en', slow=False)
512
+ tts.save(str(audio_path))
513
+ return AudioFileClip(str(audio_path))
514
+ except Exception as e:
515
+ self.logger.error(f"Fallback audio generation failed: {e}")
516
+ # Create silent audio clip with duration based on word count
517
+ duration = len(script.split()) * 0.3 # Approximate speaking time
518
+ return AudioFileClip(duration=duration)
519
+
520
  def apply_video_effects(self, frame: np.ndarray, effect_params: dict) -> np.ndarray:
521
  """Apply various video effects to a frame"""
522
  try: