Spaces:
Sleeping
Sleeping
fabiogra
commited on
Commit
•
8422348
1
Parent(s):
3b19940
fix: add try execept on load_audio_segment
Browse files- app/helpers.py +8 -1
app/helpers.py
CHANGED
@@ -8,8 +8,10 @@ from pathlib import Path
|
|
8 |
import matplotlib.pyplot as plt
|
9 |
import numpy as np
|
10 |
import streamlit as st
|
|
|
11 |
from PIL import Image
|
12 |
from pydub import AudioSegment
|
|
|
13 |
from streamlit.runtime.scriptrunner import RerunData, RerunException
|
14 |
from streamlit.source_util import get_pages
|
15 |
from streamlit_player import st_player
|
@@ -39,7 +41,12 @@ def url_is_valid(url):
|
|
39 |
|
40 |
@st.cache_data(show_spinner=False)
|
41 |
def load_audio_segment(path: str, format: str) -> AudioSegment:
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
|
45 |
@st.cache_data(show_spinner=False)
|
|
|
8 |
import matplotlib.pyplot as plt
|
9 |
import numpy as np
|
10 |
import streamlit as st
|
11 |
+
from loguru import logger as log
|
12 |
from PIL import Image
|
13 |
from pydub import AudioSegment
|
14 |
+
|
15 |
from streamlit.runtime.scriptrunner import RerunData, RerunException
|
16 |
from streamlit.source_util import get_pages
|
17 |
from streamlit_player import st_player
|
|
|
41 |
|
42 |
@st.cache_data(show_spinner=False)
|
43 |
def load_audio_segment(path: str, format: str) -> AudioSegment:
|
44 |
+
try:
|
45 |
+
return AudioSegment.from_file(path, format=format)
|
46 |
+
except Exception as e:
|
47 |
+
st.error("Audio file is not valid.")
|
48 |
+
log.warning(e)
|
49 |
+
st.stop()
|
50 |
|
51 |
|
52 |
@st.cache_data(show_spinner=False)
|