Search code examples
pythonspeech

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

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