I have a Python voice-enabled chatbot that plays and records audio. However, the chatbot is also recognizing its own audio output as input. Is there a way to prevent this? Is there a specific app that can be used to route audio from one app to another?
def play_audio(file_name):
audio_path = os.path.join(path, file_name)
data, fs = sf.read(audio_path)
sd.play(data, fs)
sd.wait()
def rec_audio():
recog = sr.Recognizer()
with sr.Microphone() as source:
print("Listening... From Site Rec..")
audio = recog.listen(source)
data = ""
try:
data = recog.recognize_google(audio)
print("User: " + data)
except sr.UnknownValueError:
print("Machine coudn't process..")
play_audio("voice break.mp3")
except sr.RequestError as ex:
print("Google side" + str(ex))
play_audio("RequestError.mp3")
return data
both of these code run simultaneously using threading. is there any way to route the audios??
I wanted the machine not to recognize its own playback audio but to observe the audio only from the microphone..