Spaces:
Sleeping
Sleeping
Update utils/audio_processing.py
Browse files
utils/audio_processing.py
CHANGED
|
@@ -49,7 +49,7 @@ def download_audio_as_wav(url, max_filesize_mb=70):
|
|
| 49 |
break
|
| 50 |
|
| 51 |
if not audio_path or not os.path.exists(audio_path):
|
| 52 |
-
st.error("
|
| 53 |
return None
|
| 54 |
|
| 55 |
# Convert to WAV (outside temp_dir so it persists)
|
|
@@ -63,7 +63,7 @@ def download_audio_as_wav(url, max_filesize_mb=70):
|
|
| 63 |
except subprocess.CalledProcessError as e:
|
| 64 |
error_msg = e.stderr.decode() if hasattr(e, "stderr") else str(e)
|
| 65 |
if "st" in globals():
|
| 66 |
-
st.error("
|
| 67 |
st.code(error_msg)
|
| 68 |
else:
|
| 69 |
print("Error during processing:", error_msg)
|
|
@@ -74,7 +74,7 @@ def download_audio_as_wav(url, max_filesize_mb=70):
|
|
| 74 |
|
| 75 |
except Exception as e:
|
| 76 |
if "st" in globals():
|
| 77 |
-
st.error("
|
| 78 |
st.code(str(e))
|
| 79 |
else:
|
| 80 |
print("Unexpected error:", e)
|
|
@@ -103,7 +103,7 @@ def trim_audio(input_wav_path, max_duration_sec=120):
|
|
| 103 |
return trimmed_file.name
|
| 104 |
|
| 105 |
except Exception as e:
|
| 106 |
-
st.error(f"
|
| 107 |
if trimmed_file and os.path.exists(trimmed_file.name):
|
| 108 |
os.remove(trimmed_file.name)
|
| 109 |
return None
|
|
|
|
| 49 |
break
|
| 50 |
|
| 51 |
if not audio_path or not os.path.exists(audio_path):
|
| 52 |
+
st.error("No supported audio file found after download.")
|
| 53 |
return None
|
| 54 |
|
| 55 |
# Convert to WAV (outside temp_dir so it persists)
|
|
|
|
| 63 |
except subprocess.CalledProcessError as e:
|
| 64 |
error_msg = e.stderr.decode() if hasattr(e, "stderr") else str(e)
|
| 65 |
if "st" in globals():
|
| 66 |
+
st.error("Audio download or conversion failed.")
|
| 67 |
st.code(error_msg)
|
| 68 |
else:
|
| 69 |
print("Error during processing:", error_msg)
|
|
|
|
| 74 |
|
| 75 |
except Exception as e:
|
| 76 |
if "st" in globals():
|
| 77 |
+
st.error("Unexpected error occurred.")
|
| 78 |
st.code(str(e))
|
| 79 |
else:
|
| 80 |
print("Unexpected error:", e)
|
|
|
|
| 103 |
return trimmed_file.name
|
| 104 |
|
| 105 |
except Exception as e:
|
| 106 |
+
st.error(f"Error trimming audio: {e}")
|
| 107 |
if trimmed_file and os.path.exists(trimmed_file.name):
|
| 108 |
os.remove(trimmed_file.name)
|
| 109 |
return None
|