I am trying to make a virtual assistant in python, and I want it to continuously listen for audio I tried this:
import speech_recognition as sr
def get_audio():
r = sr.Recognizer()
with sr.Microphone() as source:
r.adjust_for_ambient_noise(source)
audio = r.listen(source)
text = ""
try:
said = r.recognize_google(audio)
except:
pass
return text.lower()
while True:
text += get_audio()
print(text)
but I noticed that there are gaps in between so I need help to find a method via which the program is listening continuously without any gaps.