Update app.py
Browse files
app.py
CHANGED
@@ -60,11 +60,11 @@ def convert_tts(model_name, audio_file, slang_rate):
|
|
60 |
if not result or result[0] is None:
|
61 |
req_logger.error("Processing failed - no result")
|
62 |
return {"error": "Processing failed"}, None
|
63 |
-
|
64 |
# Get the result and return directly
|
65 |
result_tuple = result[0]
|
66 |
|
67 |
-
#
|
68 |
if isinstance(result_tuple, tuple) and len(result_tuple) == 3:
|
69 |
info, _, (tgt_sr, audio_output) = result_tuple
|
70 |
|
@@ -72,7 +72,7 @@ def convert_tts(model_name, audio_file, slang_rate):
|
|
72 |
req_logger.error("No audio output generated")
|
73 |
return {"error": "No audio output generated"}, None
|
74 |
|
75 |
-
# Save output
|
76 |
output_filename = f"output_{request_id}.wav"
|
77 |
output_path = os.path.join("outputs", output_filename)
|
78 |
os.makedirs("outputs", exist_ok=True)
|
@@ -84,10 +84,9 @@ def convert_tts(model_name, audio_file, slang_rate):
|
|
84 |
req_logger.info("Saving raw audio output")
|
85 |
with open(output_path, "wb") as f:
|
86 |
f.write(audio_output)
|
87 |
-
|
88 |
req_logger.info(f"Successfully saved to {output_path}")
|
89 |
return {"info": info}, output_path
|
90 |
-
|
91 |
else:
|
92 |
req_logger.error(f"Invalid result format: {result_tuple}")
|
93 |
return {"error": "Invalid result format"}, None
|
|
|
60 |
if not result or result[0] is None:
|
61 |
req_logger.error("Processing failed - no result")
|
62 |
return {"error": "Processing failed"}, None
|
63 |
+
|
64 |
# Get the result and return directly
|
65 |
result_tuple = result[0]
|
66 |
|
67 |
+
# Check if result_tuple is in the expected format
|
68 |
if isinstance(result_tuple, tuple) and len(result_tuple) == 3:
|
69 |
info, _, (tgt_sr, audio_output) = result_tuple
|
70 |
|
|
|
72 |
req_logger.error("No audio output generated")
|
73 |
return {"error": "No audio output generated"}, None
|
74 |
|
75 |
+
# Save the output
|
76 |
output_filename = f"output_{request_id}.wav"
|
77 |
output_path = os.path.join("outputs", output_filename)
|
78 |
os.makedirs("outputs", exist_ok=True)
|
|
|
84 |
req_logger.info("Saving raw audio output")
|
85 |
with open(output_path, "wb") as f:
|
86 |
f.write(audio_output)
|
87 |
+
|
88 |
req_logger.info(f"Successfully saved to {output_path}")
|
89 |
return {"info": info}, output_path
|
|
|
90 |
else:
|
91 |
req_logger.error(f"Invalid result format: {result_tuple}")
|
92 |
return {"error": "Invalid result format"}, None
|