umarabbas890 commited on
Commit
2acb2e9
·
verified ·
1 Parent(s): 6eee829

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -38,16 +38,22 @@ emotion_styles = {
38
  }
39
 
40
  # Generate voice and save as MP3
 
 
41
  def generate_voice(text, speaker_audio_path):
 
 
 
42
  tts.tts_to_file(
43
  text=text,
44
  speaker_wav=speaker_audio_path,
45
- language="en", # 👈 Add this line (use "en" for English, "ur" for Urdu, etc.)
46
  file_path="output.wav"
47
  )
48
  return "output.wav"
49
 
50
 
 
51
  # Convert to MP3 using pydub
52
  mp3_path = output_path.replace(".wav", ".mp3")
53
  sound = AudioSegment.from_wav(output_path)
 
38
  }
39
 
40
  # Generate voice and save as MP3
41
+ import os
42
+
43
  def generate_voice(text, speaker_audio_path):
44
+ if not os.path.isfile(speaker_audio_path):
45
+ raise FileNotFoundError(f"Speaker audio file not found: {speaker_audio_path}")
46
+
47
  tts.tts_to_file(
48
  text=text,
49
  speaker_wav=speaker_audio_path,
50
+ language="en",
51
  file_path="output.wav"
52
  )
53
  return "output.wav"
54
 
55
 
56
+
57
  # Convert to MP3 using pydub
58
  mp3_path = output_path.replace(".wav", ".mp3")
59
  sound = AudioSegment.from_wav(output_path)