I am developing a virtual assistant. I am using google_speech_to_text converter i am unable to keep the audio input continues. I think if there is any way i can use two environments, one will be used for listening and converting text and other for rest of the processing.
I don't want to change my STT engine. i just want to know is it possible to simultaneously switch between environments. If yes, HOW?
Here is my input.py file : whereever I require to take audio input I call the function start_listening()
:
import speech_recognition as sr
import output
import winsound
def start_listening():
r = sr.Recognizer()
with sr.Microphone() as source:
# output.speak("Listening")
r.adjust_for_ambient_noise(source)
audio = r.record(source, duration=5)
try:
return r.recognize_google(audio)
except:
output.speak("Unable to Translate, speak again")
start_listening()
Here is my processing.py file :
import input as listener
import output as speak
import clock
import query_processor as mind
import rideBooking
#First Greeting at the startup , according to the time select the greeting
speak.speak(clock.get_part_of_day())
def searching_for_word(word,sentence):
if word in sentence:
return True
else:
return False
def main_organ():
input = listener.start_listening()
inputType = mind.classify(input)
if inputType == 'whatever':
#run different functions on different commands
main_organ()
#run the app with the below code
if __name__ == "__main__":
main_organ()
While the processing is ON the app is unable to listen. It can only start_listening when the processing is fully completed.