Answer the question
In order to leave comments, you need to log in
How to play audio from URL (python)?
import pyaudio
from urllib.request import urlopen
pyaud = pyaudio.PyAudio()
srate=44100
stream = pyaud.open(format = pyaud.get_format_from_width(1),
channels = 1,
rate = srate,
output = True)
url = "www.anyurl.com"
u = urlopen(url)
data = u.read(8192)
while data:
stream.write(data)
data = u.read(8192)
Answer the question
In order to leave comments, you need to log in
Either convert to wav or use another library:
import pyglet
music = pyglet.resource.media('music.mp3')
music.play()
pyglet.app.run()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question