so, I am building a python project with some oop
, but when I try to run my program, it gives me this:
TypeError: take_query() missing 1 required positional argument: 'type'
but I have given the program the type
argument, so, I removed the type argument and tried it again, and this time it gave me this:
TypeError: take_query() missing 2 required positional arguments: 'self' and 'type'
that means python is taking self
as an argument, how can I fix that? also, I am doing this in vs code, the code for the class is :
def take_query(self,type):
# Running forever until user says goodbye (or similar)
while (True):
# This class is responsible for converting audio into text
r = sr.Recognizer()
# using the Microphone module from sr that will listen for a query
with sr.Microphone() as source:
# Energy threshold of 300 is recommended by SpeechRecognition's documentation (loudness of the file)
r.energy_threshold = 300
# How long it will wait after the user stops talking to consider the end of a sentence
r.pause_threshold = 0.7
audio = r.listen(source)
# Now trying to use Google Recognizer function that uses Google’s free web search API
# This try except block will check if the words are recognized, else an exception will be handled
try:
print("Processing...")
instruction = r.recognize_google(audio, language="en-in")
print("You said: ", instruction)
except:
pass