I am using the SpeechRecognition Python package to get the audio from the user.
import speech_recognition as sr
# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
This piece of code when executed starts listening for the audio input from the user. If the user does not speak for a while it automatically stops.
- I want to know how can we get to know that it has stopped listening to audio?
- How can I manually disable it ? I mean if i want to listen audio for 50 seconds and then stop listening to any further audio?