Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,27 +83,27 @@ def generate_audio(prompt, seconds_total=30, steps=100, cfg_scale=7):
|
|
| 83 |
print("Audio normalized and converted.")
|
| 84 |
|
| 85 |
# # Generate a unique filename for the output
|
| 86 |
-
|
| 87 |
-
|
| 88 |
|
| 89 |
# # Save to file
|
| 90 |
-
|
| 91 |
-
|
| 92 |
|
| 93 |
# compressed_filename = compress_file(unique_filename)
|
| 94 |
# return compressed_filename
|
| 95 |
|
| 96 |
# # Return the path to the generated audio file
|
| 97 |
-
|
| 98 |
|
| 99 |
# Convert audio tensor to bytes
|
| 100 |
-
byte_io = io.BytesIO()
|
| 101 |
-
torchaudio.save(byte_io, output, sample_rate, format="wav")
|
| 102 |
-
byte_io.seek(0)
|
| 103 |
-
audio_bytes = byte_io.read()
|
| 104 |
-
print("Audio converted to bytes.")
|
| 105 |
|
| 106 |
-
return audio_bytes
|
| 107 |
|
| 108 |
|
| 109 |
DESCRIPTION = "Welcome to Raptor APIs"
|
|
|
|
| 83 |
print("Audio normalized and converted.")
|
| 84 |
|
| 85 |
# # Generate a unique filename for the output
|
| 86 |
+
unique_filename = f"output_{uuid.uuid4().hex}.wav"
|
| 87 |
+
print(f"Saving audio to file: {unique_filename}")
|
| 88 |
|
| 89 |
# # Save to file
|
| 90 |
+
torchaudio.save(unique_filename, output, sample_rate)
|
| 91 |
+
print(f"Audio saved: {unique_filename}")
|
| 92 |
|
| 93 |
# compressed_filename = compress_file(unique_filename)
|
| 94 |
# return compressed_filename
|
| 95 |
|
| 96 |
# # Return the path to the generated audio file
|
| 97 |
+
return unique_filename
|
| 98 |
|
| 99 |
# Convert audio tensor to bytes
|
| 100 |
+
# byte_io = io.BytesIO()
|
| 101 |
+
# torchaudio.save(byte_io, output, sample_rate, format="wav")
|
| 102 |
+
# byte_io.seek(0)
|
| 103 |
+
# audio_bytes = byte_io.read()
|
| 104 |
+
# print("Audio converted to bytes.")
|
| 105 |
|
| 106 |
+
# return audio_bytes
|
| 107 |
|
| 108 |
|
| 109 |
DESCRIPTION = "Welcome to Raptor APIs"
|