mistermprah commited on
Commit
bc6c98d
1 Parent(s): a2fa92e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -10,7 +10,7 @@ def classify_audio(filepath):
10
  preds = pipe(filepath)
11
  outputs = {}
12
  for p in preds:
13
- outputs[p["label"]] = p["score"]
14
  return outputs
15
 
16
  # Streamlit app layout
@@ -43,10 +43,11 @@ if uploaded_file is not None:
43
  st.write("Examples:")
44
  examples = ['normal.wav', 'murmur.wav', 'extra_systole.wav', 'extra_hystole.wav', 'artifact.wav']
45
  for example in examples:
46
- st.write(example)
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)
 
 
10
  preds = pipe(filepath)
11
  outputs = {}
12
  for p in preds:
13
+ outputs[p["label"].replace('_', ' ')] = p["score"]
14
  return outputs
15
 
16
  # Streamlit app layout
 
43
  st.write("Examples:")
44
  examples = ['normal.wav', 'murmur.wav', 'extra_systole.wav', 'extra_hystole.wav', 'artifact.wav']
45
  for example in examples:
46
+ if st.button(example):
47
+ st.subheader(f"Example: {example}")
48
+ audio_bytes = open(example, 'rb').read()
49
+ st.audio(audio_bytes, format='audio/wav')
50
+ results = classify_audio(example)
51
+ st.write("Results:")
52
+ results_str = "\n".join([f"{label}: {score:.4f}" for label, score in results.items()])
53
+ st.text(results_str)