Search code examples
pythontypeerrorspeech-recognitionspeech-to-text

Type Error: record() missing 1 required positional argument: 'source'


I have just started with python and i'm trying out new modules from random tutorials online. I tried to write it exactly like the tutorial and even changing the name but it still keeps showing me this:

Traceback (most recent call last):
 File "C:/Users/Asjad/PycharmProjects/untitled/hello world.py", line 7, in <module>
   audio = r.record(j)
TypeError: record() missing 1 required positional argument: 'source'

I don't know how to go past this as this a new module and a new error with me

mainscript:

import speech_recognition as sy

file = ("D:\\Audio 1.wav")
r = sy.Recognizer # initialize the recognizer

with sy.AudioFile(file) as j:
    audio = r.record(j)

print('it contains', r.recognise_google(audio))

Solution

  • I think this line r = sy.Recognizermake an instance of Recognizer so you should do that instead r = sy.Recognizer()