one function keeps getting called in multi threading
I am trying to thread a speech_recognition function to run in the background continuously and the checkingAudio function to see what text was spoken and take actions accordingly, I tried to thread the 2 functions to run in parallel but the speech recon function is getting called over and over again, I have never worked with threading and followed a tutorial on youtube to thread my functions, I get that I could have made a very stupid mistake so I request the person who answers the question to be a little elaborate in their answer and my mistake. Thank you.
You must be logged in to post. Please login or register an account.
So I just deleted a While loop in my listening statement, and after that I got the error TypeError: checkingAudio() missing 1 required positional argument: 'self' which as far as I can guess is that my function checkingAudio is at least getting called I'll update my post as soon as I get it working
-sahilshukla 7 years ago
You must be logged in to post. Please login or register an account.
As it turns out, I didn't use threading at all, I just called the functions in my main thread. I didn't make them the target nor did I used
t1.start
anyways here's the working code,
while 1: listener = listen() # Make the object t1 = threading.Thread(target=listener.listening) # Note: No parens or we invoke in main thread t2 = threading.Thread(target=listener.checkingAudio) # Note: No parens t1.start() # Actually launch threads t2.start() t1.join() t2.join()
-sahilshukla 7 years ago
You must be logged in to post. Please login or register an account.