Update voice_processing.py
Browse files- voice_processing.py +6 -17
voice_processing.py
CHANGED
@@ -136,10 +136,7 @@ async def tts(
|
|
136 |
use_uploaded_voice,
|
137 |
uploaded_voice,
|
138 |
):
|
139 |
-
start_time = time.time()
|
140 |
-
success = False
|
141 |
edge_output_filename = get_unique_filename("mp3")
|
142 |
-
|
143 |
try:
|
144 |
# Default values for parameters
|
145 |
speed = 0
|
@@ -207,28 +204,20 @@ async def tts(
|
|
207 |
|
208 |
info = f"Success. Time: tts: {edge_time:.2f}s, npy: {times[0]:.2f}s, f0: {times[1]:.2f}s, infer: {times[2]:.2f}s"
|
209 |
print(info)
|
210 |
-
|
211 |
return (
|
212 |
info,
|
213 |
edge_output_filename if not use_uploaded_voice else None,
|
214 |
(tgt_sr, audio_opt),
|
215 |
)
|
216 |
|
217 |
-
except EOFError:
|
218 |
-
info = "Output not valid. This may occur when input text and speaker do not match."
|
219 |
-
print(info)
|
220 |
-
return info, None, None
|
221 |
-
|
222 |
except Exception as e:
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
finally:
|
228 |
-
duration = time.time() - start_time
|
229 |
-
tts_monitor.record_request(duration, success)
|
230 |
-
if not success and os.path.exists(edge_output_filename):
|
231 |
os.remove(edge_output_filename)
|
|
|
232 |
|
233 |
voice_mapping = {
|
234 |
"Mongolian Male": "mn-MN-BataaNeural",
|
|
|
136 |
use_uploaded_voice,
|
137 |
uploaded_voice,
|
138 |
):
|
|
|
|
|
139 |
edge_output_filename = get_unique_filename("mp3")
|
|
|
140 |
try:
|
141 |
# Default values for parameters
|
142 |
speed = 0
|
|
|
204 |
|
205 |
info = f"Success. Time: tts: {edge_time:.2f}s, npy: {times[0]:.2f}s, f0: {times[1]:.2f}s, infer: {times[2]:.2f}s"
|
206 |
print(info)
|
207 |
+
|
208 |
return (
|
209 |
info,
|
210 |
edge_output_filename if not use_uploaded_voice else None,
|
211 |
(tgt_sr, audio_opt),
|
212 |
)
|
213 |
|
|
|
|
|
|
|
|
|
|
|
214 |
except Exception as e:
|
215 |
+
print(f"Error in TTS task: {str(e)}")
|
216 |
+
import traceback
|
217 |
+
traceback.print_exc()
|
218 |
+
if os.path.exists(edge_output_filename):
|
|
|
|
|
|
|
|
|
219 |
os.remove(edge_output_filename)
|
220 |
+
return str(e), None, None
|
221 |
|
222 |
voice_mapping = {
|
223 |
"Mongolian Male": "mn-MN-BataaNeural",
|