I went through all the similar questions on this topic and tried everything, but nothing's working.
I tried solutions from the following links : speech recognition python stopped in listen SpeechRecognition producing OSError: No Default Input Device Available Python, Speech Recognition stuck at 'Listening...' speech recognition python code not working etc.
import speech_recognition as sr
def get_audio():
r = sr.Recognizer()
with sr.Microphone() as source:
r.adjust_for_ambient_noise(source, duration=5)
print("listening... ")
audio = r.listen(source)
said = ""
try:
said = r.recognize_google(audio)
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
return said.lower()
print(get_audio())
Error that I am getting is:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Following command gets stuck at 'Say Something..' and does nothing.
python -m speech_recognition
I also tried following code to check the default audio device :
import pyaudio
print(pyaudio.pa.get_default_input_device())
Ouput :
OSError: No Default Input Device Available
What am I doing wrong here?