Mridul commited on
Commit
cb6e2f4
1 Parent(s): e5edec2

Updating Readme and stop button

Browse files
Files changed (2) hide show
  1. README.md +66 -12
  2. helper.py +11 -4
README.md CHANGED
@@ -1,12 +1,66 @@
1
- ---
2
- title: VAD BTP
3
- emoji: 🐨
4
- colorFrom: purple
5
- colorTo: green
6
- sdk: streamlit
7
- sdk_version: 1.28.2
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Human Voice Activity Detector
2
+
3
+ This project is a Human Voice Activity Detector built using Streamlit, PyAudio, Matplotlib, Librosa, and PyTorch. It allows users to upload audio files, and detect speech segments in the provided audio.
4
+
5
+ ## Setup
6
+
7
+ Open the folder in your preferred IDE and before running the project, make sure to install the required dependencies. You can use the following commands:
8
+
9
+ ```bash
10
+ pip install -r requirements.txt
11
+ ```
12
+ Additionally, if you are running the project in a virtual environment, activate it before installing the dependencies.
13
+
14
+ ## Running the App
15
+
16
+ To run the Streamlit app, use the following command:
17
+
18
+ ```bash
19
+ streamlit run app.py
20
+ ```
21
+ This will start the app and open it in your default web browser. You can then interact with the Human Voice Activity Detector.
22
+
23
+ ## Usage
24
+
25
+ ### Recording Audio
26
+
27
+ ```bash
28
+ 1.Enter a filename and set the duration for recording in the provided form.
29
+ 2.Click the "Record" button to start recording from the microphone.
30
+ 3.Click the "Stop Recording" button to stop the recording.
31
+ 4.Download the recorded audio using the provided download button.
32
+ ```
33
+
34
+ ### Upload the Recorded Audio File
35
+ ```bash
36
+ 1.Use the "Upload Audio" button to upload a WAV file.
37
+ 2.The app will display the waveform and play the raw audio.
38
+ ```
39
+
40
+ ### Speech Detection
41
+
42
+ ```bash
43
+ 1.The app processes the audio file using a pre-trained speech detection model.
44
+ 2.Detected speech segments are highlighted in the waveform plot.
45
+ 3.If no speech is detected, an error message is displayed.
46
+ ```
47
+ ### Resetting the App
48
+
49
+ ```bash
50
+ Click the "Reset" button to clear the current recording or uploaded audio and start over
51
+ ```
52
+
53
+ ## Important Notes
54
+
55
+ ```bash
56
+ • Ensure that the required system dependencies for PyAudio are installed. If not, uncomment the # RUN apt-get update && apt-get install -y portaudio19-dev line in the requirements.txt file.
57
+ • The app uses a pre-trained speech detection model from the "snakers4/silero-vad" repository. It will automatically download the model during the first run.
58
+ ```
59
+
60
+ ## Contributors
61
+
62
+ #### • Mridul kant Kaushik
63
+ #### • Shubham Shandilya
64
+
65
+ ##
66
+ # Happy voice detecting!
helper.py CHANGED
@@ -19,6 +19,7 @@ def record_Audio(filename, duration):
19
 
20
  recording_state = st.session_state.get("recording_state", False)
21
  recording_info_placeholder = st.empty()
 
22
  if recording_state:
23
 
24
  recording_info_placeholder.info("Recording... ")
@@ -42,15 +43,21 @@ def record_Audio(filename, duration):
42
  output_device_index=default_output_device_index)
43
 
44
 
45
- stop_button = st.button("Stop Recording")
46
-
 
 
 
47
  for _ in range(0, RATE // CHUNK * RECORD_TIME):
48
 
49
  f.writeframes(stream.read(CHUNK))
50
 
51
  if stop_button:
52
- break
53
-
 
 
 
54
 
55
  recording_info_placeholder.success("Recording Completed\nThese are the results:")
56
 
 
19
 
20
  recording_state = st.session_state.get("recording_state", False)
21
  recording_info_placeholder = st.empty()
22
+ stop_button_placeholder = st.empty()
23
  if recording_state:
24
 
25
  recording_info_placeholder.info("Recording... ")
 
43
  output_device_index=default_output_device_index)
44
 
45
 
46
+ if recording_state:
47
+ stop_button = st.button("Stop Recording")
48
+ else:
49
+ stop_button_placeholder.empty()
50
+
51
  for _ in range(0, RATE // CHUNK * RECORD_TIME):
52
 
53
  f.writeframes(stream.read(CHUNK))
54
 
55
  if stop_button:
56
+ stop_button = st.empty()
57
+ st.session_state["recording_done"] = True
58
+ recording_info_placeholder.info("Recording Stopped")
59
+ stream.close()
60
+ p.terminate()
61
 
62
  recording_info_placeholder.success("Recording Completed\nThese are the results:")
63