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.Recogn
with
. you may print something after with
to know that the recording has been stopped.import speech_recognition as sr
recognizer = sr.Recognizer()
mic = sr.Microphone(device_index=1)
with mic as source:
recognizer.adjust_for_ambient_noise(source)
captured_audio = recognizer.record(source=mic, duration=50)