Spaces:
Sleeping
Sleeping
mistermprah
commited on
Commit
•
a2fa92e
1
Parent(s):
2aa760b
Update app.py
Browse files
app.py
CHANGED
@@ -20,6 +20,7 @@ st.title("Heartbeat Sound Classification")
|
|
20 |
uploaded_file = st.file_uploader("Upload an audio file", type=["wav", "mp3"])
|
21 |
|
22 |
if uploaded_file is not None:
|
|
|
23 |
# Load and display the audio file
|
24 |
audio_bytes = uploaded_file.read()
|
25 |
st.audio(audio_bytes, format='audio/wav')
|
@@ -32,10 +33,11 @@ if uploaded_file is not None:
|
|
32 |
st.write("Classifying the audio...")
|
33 |
results = classify_audio("temp_audio_file.wav")
|
34 |
|
35 |
-
# Display the classification results
|
36 |
-
st.
|
37 |
-
|
38 |
-
|
|
|
39 |
|
40 |
# Examples of audio files for classification
|
41 |
st.write("Examples:")
|
@@ -45,5 +47,6 @@ for example in examples:
|
|
45 |
audio_bytes = open(example, 'rb').read()
|
46 |
st.audio(audio_bytes, format='audio/wav')
|
47 |
results = classify_audio(example)
|
48 |
-
|
49 |
-
|
|
|
|
20 |
uploaded_file = st.file_uploader("Upload an audio file", type=["wav", "mp3"])
|
21 |
|
22 |
if uploaded_file is not None:
|
23 |
+
st.subheader("Uploaded Audio File")
|
24 |
# Load and display the audio file
|
25 |
audio_bytes = uploaded_file.read()
|
26 |
st.audio(audio_bytes, format='audio/wav')
|
|
|
33 |
st.write("Classifying the audio...")
|
34 |
results = classify_audio("temp_audio_file.wav")
|
35 |
|
36 |
+
# Display the classification results in a dedicated output box
|
37 |
+
st.subheader("Classification Results")
|
38 |
+
results_box = st.empty()
|
39 |
+
results_str = "\n".join([f"{label}: {score:.2f}" for label, score in results.items()])
|
40 |
+
results_box.text(results_str)
|
41 |
|
42 |
# Examples of audio files for classification
|
43 |
st.write("Examples:")
|
|
|
47 |
audio_bytes = open(example, 'rb').read()
|
48 |
st.audio(audio_bytes, format='audio/wav')
|
49 |
results = classify_audio(example)
|
50 |
+
st.write("Results:")
|
51 |
+
results_str = "\n".join([f"{label}: {score:.2f}" for label, score in results.items()])
|
52 |
+
st.text(results_str)
|