Deep50D commited on
Commit
5549c65
·
verified ·
1 Parent(s): 2f7d724

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -27,7 +27,6 @@ tts = TTS(model_name, gpu=False)
27
  tts.to("cpu") # no GPU or Amd
28
  #tts.to("cuda") # cuda only
29
 
30
-
31
  def predict(prompt, language, audio_file_pth, mic_file_path, use_mic, agree, request: gr.Request):
32
  """
33
  Due to the large number of abuses observed in the console logs, I have been forced to integrate the ‘display of additional information’ relating to the use of this space.
@@ -86,9 +85,10 @@ def predict(prompt, language, audio_file_pth, mic_file_path, use_mic, agree, req
86
  language = "fr-fr"
87
  if m.find("/fr/") != -1:
88
  language = None
 
89
  tts.tts_to_file(
90
  text=prompt,
91
- file_path="output.wav",
92
  speaker_wav=speaker_wav,
93
  language=language
94
  )
@@ -101,21 +101,18 @@ def predict(prompt, language, audio_file_pth, mic_file_path, use_mic, agree, req
101
  else:
102
  raise e
103
 
104
- return (
105
- #gr.make_waveform(
106
- #audio="output.wav",
107
- #),
108
- "output.wav",
109
- )
 
110
  else:
111
  gr.Warning("Please accept the Terms & Condition!")
112
- return (
113
- # None,
114
- None,
115
- )
116
-
117
 
118
- title = "XTTS Glz's remake (Fonctional Text-2-Speech)"
119
 
120
  description = f"""
121
  <a href="https://huggingface.co/coqui/XTTS-v1">XTTS</a> is a Voice generation model that lets you clone voices into different languages by using just a quick 3-second audio clip.
 
27
  tts.to("cpu") # no GPU or Amd
28
  #tts.to("cuda") # cuda only
29
 
 
30
  def predict(prompt, language, audio_file_pth, mic_file_path, use_mic, agree, request: gr.Request):
31
  """
32
  Due to the large number of abuses observed in the console logs, I have been forced to integrate the ‘display of additional information’ relating to the use of this space.
 
85
  language = "fr-fr"
86
  if m.find("/fr/") != -1:
87
  language = None
88
+ output_path = os.path.abspath("output.wav") # absolute path
89
  tts.tts_to_file(
90
  text=prompt,
91
+ file_path=output_path,
92
  speaker_wav=speaker_wav,
93
  language=language
94
  )
 
101
  else:
102
  raise e
103
 
104
+ # Verify file exists before returning
105
+ if not os.path.exists(output_path):
106
+ gr.Warning("Audio file was not created successfully")
107
+ return None
108
+
109
+ return output_path # return absolute path as string
110
+
111
  else:
112
  gr.Warning("Please accept the Terms & Condition!")
113
+ return None
 
 
 
 
114
 
115
+ title = "XTTS D5D's remake of Glz's remake (Functional Text-2-Speech)"
116
 
117
  description = f"""
118
  <a href="https://huggingface.co/coqui/XTTS-v1">XTTS</a> is a Voice generation model that lets you clone voices into different languages by using just a quick 3-second audio clip.