I am writing a code in python which does speech recognition using the pyaudio module. When I first ran the code I got an error saying "no default input device detected" . So I got a USB sound card and a microphone but it still gives me the same error.
How do I get my code to use the usb sound card instead of my comp's inbuilt one? I have Ubuntu 16.04 and Python 3.6.5
This is my python code
import speech_recognition as sr
import pyaudio #I tried using import pyaudio as well
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
try:
print("You said" + r.recognize_sphinx(audio))
except sr.UnknownValueError:
print("Could not understand audio")
except sr.RequestError as e:
print("error; {0}".format(e))
PS- My mic works well with applications like Audacity, so I don't think the mic is broken
this is the screenshot of the pavucontrol