HareemFatima commited on
Commit
e5b69e1
1 Parent(s): 99f8c01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -1,5 +1,8 @@
1
- !pip install -U transformers
 
2
  import streamlit as st
 
 
3
  from transformers import pipeline
4
 
5
  # Load the model pipeline
@@ -31,11 +34,16 @@ def classify_audio(audio_input):
31
  # Streamlit app
32
  def main():
33
  st.title("Stutter Classification App")
34
- st.audio("path_to_your_audio_file", format="audio/wav") # Add audio input widget here
35
- if st.button("Classify"):
36
- audio_input = st.audio("path_to_your_audio_file", format="audio/wav") # Add audio input widget here
37
- stutter_type = classify_audio(audio_input)
38
- st.write("Predicted Stutter Type:", stutter_type)
 
 
 
 
 
39
 
40
  if __name__ == "__main__":
41
  main()
 
1
+ !pip install -U transformers sounddevice
2
+
3
  import streamlit as st
4
+ import sounddevice as sd
5
+ import soundfile as sf
6
  from transformers import pipeline
7
 
8
  # Load the model pipeline
 
34
  # Streamlit app
35
  def main():
36
  st.title("Stutter Classification App")
37
+ audio_input = st.audio("Capture Audio", format="audio/wav", start_recording=True, channels=1)
38
+ if st.button("Stop Recording"):
39
+ sd.stop()
40
+ with st.spinner("Classifying..."):
41
+ # Read the recorded audio file
42
+ recording_path = "recording.wav"
43
+ audio_data, sampling_rate = sf.read(recording_path)
44
+ # Classify the audio
45
+ stutter_type = classify_audio(audio_data)
46
+ st.write("Predicted Stutter Type:", stutter_type)
47
 
48
  if __name__ == "__main__":
49
  main()