Spaces:
Runtime error
Runtime error
deveix
commited on
Commit
·
cb75233
1
Parent(s):
04f4397
save temp file
Browse files- app/main.py +2 -2
app/main.py
CHANGED
|
@@ -295,7 +295,7 @@ async def handle_cnn(file: UploadFile = File(...)):
|
|
| 295 |
print("got into request")
|
| 296 |
print(file.content_type)
|
| 297 |
# Ensure that we are handling an MP3 file
|
| 298 |
-
if file.content_type
|
| 299 |
file_extension = ".mp3"
|
| 300 |
elif file.content_type == "audio/wav":
|
| 301 |
file_extension = ".wav"
|
|
@@ -310,7 +310,7 @@ async def handle_cnn(file: UploadFile = File(...)):
|
|
| 310 |
# Save file to a temporary file if needed or process directly from memory
|
| 311 |
with open(temp_filename, "wb") as f:
|
| 312 |
f.write(contents)
|
| 313 |
-
|
| 314 |
spectrograms = []
|
| 315 |
|
| 316 |
clips = preprocess_audio_cnn(temp_filename)
|
|
|
|
| 295 |
print("got into request")
|
| 296 |
print(file.content_type)
|
| 297 |
# Ensure that we are handling an MP3 file
|
| 298 |
+
if file.content_type in ["audio/mpeg", "audio/mp3", "application/octet-stream"]:
|
| 299 |
file_extension = ".mp3"
|
| 300 |
elif file.content_type == "audio/wav":
|
| 301 |
file_extension = ".wav"
|
|
|
|
| 310 |
# Save file to a temporary file if needed or process directly from memory
|
| 311 |
with open(temp_filename, "wb") as f:
|
| 312 |
f.write(contents)
|
| 313 |
+
print(f"File saved as {temp_filename}")
|
| 314 |
spectrograms = []
|
| 315 |
|
| 316 |
clips = preprocess_audio_cnn(temp_filename)
|