I'm working on a project where I'm streaming live audio from an old Android phone to a server (Ubuntu) for python speech recognition. I can listen to the live audio stream with VLC fine but can't figure out how to get it into Python.
I'm using this speech recognition module (https://github.com/Uberi/speech_recognition) which relies on PyAudio for microphone input. What's the best way to get my live network audio into this module?
Is a virtual microphone on the server linked to the network stream the best (and how would I go about this?) or can Python just listen to the stream directly?
I attempted this code but it didn't work, saying AssertionError: Source must be an audio source
import requests
stream_url = "http://username:password@IPAddress:port/audio.wav"
n = requests.get(stream_url, stream=True)
r = sr.Recognizer()
mic = sr.Microphone()
with n as source:
audio = r.listen(source)
try:
print(r.recognize_google(audio))
except UnknownValueError:
print("Couldn't Recognize")
If someone could point me in the right direction that would be awesome. Thanks!