Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,10 +21,6 @@ torch_dtype = torch.float16 if device == "cuda" else torch.float32
|
|
21 |
pipe = StableAudioPipeline.from_pretrained("stabilityai/stable-audio-open-1.0", torch_dtype=torch_dtype)
|
22 |
pipe = pipe.to(device)
|
23 |
|
24 |
-
# Path to store generated audio files
|
25 |
-
#OUTPUT_PATH = "./generated_audio"
|
26 |
-
#os.makedirs(OUTPUT_PATH, exist_ok=True)
|
27 |
-
|
28 |
# Initialize Flask app
|
29 |
app = Flask(__name__)
|
30 |
|
@@ -57,24 +53,6 @@ def generate_audio():
|
|
57 |
|
58 |
# Send the file in response as attachment for download
|
59 |
return send_file(output_io, as_attachment=False, download_name="output.wav", mimetype='audio/wav')
|
60 |
-
|
61 |
-
'''
|
62 |
-
# Convert to numpy and save to a WAV file
|
63 |
-
output_audio = audio_output[0].T.float().cpu().numpy()
|
64 |
-
output_filename = "output.wav"
|
65 |
-
#output_path = os.path.join(OUTPUT_PATH, output_filename)
|
66 |
-
sf.write(output_path, output_audio, pipe.vae.sampling_rate)
|
67 |
-
|
68 |
-
if os.path.exists(output_path):
|
69 |
-
return send_file(output_path, as_attachment=True)
|
70 |
-
else:
|
71 |
-
return {"error": f"File not found at {output_path}"}, 404
|
72 |
-
|
73 |
-
'''
|
74 |
-
|
75 |
-
# Return the WAV file
|
76 |
-
#return jsonify({"file_path": absolute_output_path}), 200
|
77 |
-
|
78 |
|
79 |
except Exception as e:
|
80 |
return jsonify({"error": str(e)}), 500
|
|
|
21 |
pipe = StableAudioPipeline.from_pretrained("stabilityai/stable-audio-open-1.0", torch_dtype=torch_dtype)
|
22 |
pipe = pipe.to(device)
|
23 |
|
|
|
|
|
|
|
|
|
24 |
# Initialize Flask app
|
25 |
app = Flask(__name__)
|
26 |
|
|
|
53 |
|
54 |
# Send the file in response as attachment for download
|
55 |
return send_file(output_io, as_attachment=False, download_name="output.wav", mimetype='audio/wav')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
except Exception as e:
|
58 |
return jsonify({"error": str(e)}), 500
|