D3vShoaib commited on
Commit
fb2c0a1
·
1 Parent(s): da2a3d2

addedin tracebacs for silent voice cloning faliurs

Browse files
Files changed (2) hide show
  1. app.py +16 -5
  2. packages.txt +1 -0
app.py CHANGED
@@ -9,6 +9,8 @@ print("Model loaded.")
9
 
10
  VOICES = ['alba', 'marius', 'javert', 'jean', 'fantine', 'cosette', 'eponine', 'azelma']
11
 
 
 
12
  def generate_speech(text, voice_mode, voice_dropdown, voice_upload):
13
  if not text:
14
  return None
@@ -18,21 +20,30 @@ def generate_speech(text, voice_mode, voice_dropdown, voice_upload):
18
  voice_path = voice_dropdown
19
  else:
20
  if not voice_upload:
21
- return None
22
  voice_path = voice_upload
23
 
24
  print(f"Generating with voice: {voice_path}")
25
- voice_state = model.get_state_for_audio_prompt(voice_path)
26
- audio = model.generate_audio(voice_state, text)
 
 
 
 
 
27
 
28
  # Convert to 16-bit PCM to avoid Gradio warnings
29
  audio_np = audio.cpu().numpy()
30
  audio_int16 = (audio_np * 32767).astype(np.int16)
31
 
32
  return (model.sample_rate, audio_int16)
 
 
33
  except Exception as e:
34
- print(f"Error generating speech: {e}")
35
- return None
 
 
36
 
37
  # Load custom theme with fallback
38
  try:
 
9
 
10
  VOICES = ['alba', 'marius', 'javert', 'jean', 'fantine', 'cosette', 'eponine', 'azelma']
11
 
12
+ import traceback
13
+
14
  def generate_speech(text, voice_mode, voice_dropdown, voice_upload):
15
  if not text:
16
  return None
 
20
  voice_path = voice_dropdown
21
  else:
22
  if not voice_upload:
23
+ raise gr.Error("Please upload an audio file for voice cloning.")
24
  voice_path = voice_upload
25
 
26
  print(f"Generating with voice: {voice_path}")
27
+ try:
28
+ voice_state = model.get_state_for_audio_prompt(voice_path)
29
+ audio = model.generate_audio(voice_state, text)
30
+ except Exception as e:
31
+ full_error = traceback.format_exc()
32
+ print(f"Error in model processing: {full_error}")
33
+ raise gr.Error(f"Model error: {str(e)}")
34
 
35
  # Convert to 16-bit PCM to avoid Gradio warnings
36
  audio_np = audio.cpu().numpy()
37
  audio_int16 = (audio_np * 32767).astype(np.int16)
38
 
39
  return (model.sample_rate, audio_int16)
40
+ except gr.Error:
41
+ raise
42
  except Exception as e:
43
+ full_error = traceback.format_exc()
44
+ print(f"Unexpected error: {full_error}")
45
+ raise gr.Error(f"An unexpected error occurred: {str(e)}")
46
+
47
 
48
  # Load custom theme with fallback
49
  try:
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ffmpeg