Update app.py
Browse files
app.py
CHANGED
@@ -47,7 +47,7 @@ def generate_audio():
|
|
47 |
num_waveforms_per_prompt=1,
|
48 |
generator=generator
|
49 |
).audios
|
50 |
-
|
51 |
# Convert to numpy and save to a WAV file
|
52 |
output_audio = audio_output[0].T.float().cpu().numpy()
|
53 |
output_filename = "output.wav"
|
@@ -56,6 +56,21 @@ def generate_audio():
|
|
56 |
|
57 |
# Return the WAV file
|
58 |
return jsonify({"file_path": output_path}), 200
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
except Exception as e:
|
60 |
return jsonify({"error": str(e)}), 500
|
61 |
|
|
|
47 |
num_waveforms_per_prompt=1,
|
48 |
generator=generator
|
49 |
).audios
|
50 |
+
'''
|
51 |
# Convert to numpy and save to a WAV file
|
52 |
output_audio = audio_output[0].T.float().cpu().numpy()
|
53 |
output_filename = "output.wav"
|
|
|
56 |
|
57 |
# Return the WAV file
|
58 |
return jsonify({"file_path": output_path}), 200
|
59 |
+
'''
|
60 |
+
# Convert to numpy
|
61 |
+
output_audio = audio_output[0].T.float().cpu().numpy()
|
62 |
+
|
63 |
+
# Create a temporary file to store the output audio
|
64 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as temp_file:
|
65 |
+
temp_file_path = temp_file.name
|
66 |
+
# Save the audio to the temporary file
|
67 |
+
sf.write(temp_file_path, output_audio, pipe.vae.sampling_rate)
|
68 |
+
|
69 |
+
# Return the file as an attachment
|
70 |
+
return send_file(temp_file_path, as_attachment=True, download_name="output.wav", mimetype="audio/wav")
|
71 |
+
|
72 |
+
|
73 |
+
|
74 |
except Exception as e:
|
75 |
return jsonify({"error": str(e)}), 500
|
76 |
|