Skip to content
← Back to Community
Play sound in replit
Profile icon
QuantumCodes

the playsound package doesnt work. Is there any way to play a sound on python replit? I want to play an online sound (ie) not downloaded

Voters
Profile icon
QuantumCodes
Comments
hotnewtop
Profile icon
xfinnbar

You can using the replit package, but I recommend making it a website for a better user experience.

Profile icon
QuantumCodes

@xfinnbar example?

Profile icon
xfinnbar

@QuantumCodes

from replit import audio audio.play_file("sound.mp3")

Audio on replit is buggy, so like I said you should probably make a website instead.

Profile icon
QuantumCodes

@xfinnbar but i dont know js or css. Only html

Profile icon
xfinnbar

@QuantumCodes Learn them?????? They're among the most useful coding skills to have.

Profile icon
QuantumCodes

@xfinnbar ok, nvm... i did. But it seems i cannot play a file through url... (i didnt download. Trying to play online)

Profile icon
Coder100

the file must be on your local replit project. @QuantumCodes

Profile icon
QuantumCodes

@Coder100 no way by url?

Profile icon
Coder100

nope
you can just install the mp3 file from the URL @QuantumCodes

Profile icon
QuantumCodes

@Coder100 can we do it while user is running code? Can u give an example? And can we delete it using code?

Profile icon
QuantumCodes

@Coder100 i was using a dictionary api... that also gives pronounciation of the word. I wanted to play that

Profile icon
Coder100

you can use the requests module to download it through the dictionary API if there is one. Otherwise, no luck, maybe you could make it generate an mp3 instead of using dictionary. @QuantumCodes

Profile icon
Carnage498

tru @xfinnbar without CSS or JS, HTML is pretty basic and boring. No style.

Profile icon
QuantumCodes

@Coder100 so i did:

audio = requests.get(link).content

Now? Is this even correct? How do i play this?