I am new to python. I am trying to to call a class's constructor but it is giving me the below error:
TypeError: init() missing 1 required positional argument: 'rec'
And I have the same issue with listen() as below. Please discard the rms()
andrecord()
since they are other functions And here is my code:
class Recorder:
def __init__(rec):
rec.p= pyaudio.PyAudio()
rec.stream= rec.p.open(format=FORMAT, channels=CHANNELS, rate=RATE,input=True,output=True,frames_per_buffer=chunk)
# listen to the sound
def listen(rec):
print('Listening beginning')
while True:
input = rec.stream.read(chunk, execption_on_overflow=False)
rms_val = rec.rms(input)
if rms_val > Threshold:
rec.record()
k = Recorder()
k.listen()