Spaces:
Runtime error
Runtime error
Commit
·
8f888de
1
Parent(s):
9ed9129
big update
Browse files
app.py
CHANGED
|
@@ -25,6 +25,19 @@ s=0
|
|
| 25 |
n=16000
|
| 26 |
|
| 27 |
# Audio parameters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
st.sidebar.markdown(
|
| 30 |
"""
|
|
@@ -54,13 +67,7 @@ if uploaded_file is not None:
|
|
| 54 |
# Reshape the waveform into chunks
|
| 55 |
waveform_chunks = np.array_split(waveform[:num_chunks * chunk_size], num_chunks)
|
| 56 |
st.write("Reached stage 3")
|
| 57 |
-
|
| 58 |
-
input_tensor = torch.tensor(chunk).unsqueeze(0).to(torch.float32)
|
| 59 |
-
result = model(input_tensor)
|
| 60 |
-
if np.abs(result[0][0]) > np.abs(result[0][1]):
|
| 61 |
-
other += 1
|
| 62 |
-
else:
|
| 63 |
-
snore += 1
|
| 64 |
|
| 65 |
total = snore + other
|
| 66 |
snore_percentage = (snore / total) * 100
|
|
|
|
| 25 |
n=16000
|
| 26 |
|
| 27 |
# Audio parameters
|
| 28 |
+
def process_data(waveform_chunks):
|
| 29 |
+
st.write("Reached stage 4")
|
| 30 |
+
for chunk in waveform_chunks:
|
| 31 |
+
st.write("Reached stage 5")
|
| 32 |
+
input_tensor = torch.tensor(chunk).unsqueeze(0).to(torch.float32)
|
| 33 |
+
st.write("Reached stage 6")
|
| 34 |
+
result = model(input_tensor)
|
| 35 |
+
st.write("Reached stage 7")
|
| 36 |
+
if np.abs(result[0][0]) > np.abs(result[0][1]):
|
| 37 |
+
other += 1
|
| 38 |
+
else:
|
| 39 |
+
snore += 1
|
| 40 |
+
return snore, other
|
| 41 |
|
| 42 |
st.sidebar.markdown(
|
| 43 |
"""
|
|
|
|
| 67 |
# Reshape the waveform into chunks
|
| 68 |
waveform_chunks = np.array_split(waveform[:num_chunks * chunk_size], num_chunks)
|
| 69 |
st.write("Reached stage 3")
|
| 70 |
+
snore, other = process_data(waveform_chunks)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
total = snore + other
|
| 73 |
snore_percentage = (snore / total) * 100
|