'Python pyaudio error while recording from microphone

I was trying to convert speech to text via pyaduio.The program was working fine for a few hours but suddenly my visual studio 2019 keeps on marking an error in the 6th line for no reason. Does anyone know how to fix it? tnx :)

import speech_recognition as sr
import pyaudio

 r = sr.Recognizer()
 mic = sr.Microphone(device_index=1)
 with mic as source:
         audio_data = r.record(source, duration= 3)
         print("I recognize speaking")
         text = r.recognize_google(audio_data)       
         print("I heard: ",text)


Solution 1:[1]

The problem was that google api is restricted to certain amount of uses without paying, and I ran out of free uses.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1