Skip to content
← Back to Community
Python Sound
Profile icon
Coder2195

Python has not supported sound for quite a while now.

Are the developers planning to add sound?
When will this happen?

Will this even happen?

Voters
Profile icon
Coder2195
Comments
hotnewtop
Profile icon
RYANTADIPARTHI

i don't think they're going to support other modules audio, but they do have an audio system of their own. here's a tutorial on it.

https://docs.repl.it/repls/audio

Profile icon
BananaJellyfish

you can, in fact, have sound with pygame.

Profile icon
Coder2195

@BananaJellyfish give me example

Profile icon
BananaJellyfish

@Coder2195Text well, if ur using pygame, you do pygame.mixer.Sound('insert_sound_name_here'.wav) after importing your sound. im not sure if it is possible without pygame

Profile icon
Coder2195

edit your post so there is an example for proof ... @BananaJellyfish

Profile icon
BananaJellyfish

@Coder2195Text oh actually repl.it wont support the .mixer module... never mind

Profile icon
Coder2195

@BananaJellyfish That what I was talking about

Profile icon
BananaJellyfish

@Coder2195Text oh. I thought you meant in general

Profile icon
BananaJellyfish

Thats in javascript, isnt it? I think they mean sound in [email protected]

Profile icon
Coder2195

@YeetsaJr THIS IS A PYTHON QUESTION NOT NODE JS

Profile icon
EducationalChan
Profile icon
RishiMohanty

sound with python on replit doesn't work. I mean, when you run something with sound It will sometimes play and other times it won't. The tnkter module is also unavailable so you can't use that either. The playsound module gives an error when you try to download the package. os.system also doesn't work for some reason whatsoever. there is a way, I forgot how, where you can play a .wav audio file and it plays without an error but you can't hear it. So basically all in all you can't play audio with python on replit. I'm pretty sure you can do it with Py.Charm because you can use the tnkiter module.

Profile icon
19wintersp

You've already received two good answers, though I'd just like to clarify: Python does not have a built-in sound library, and I doubt they will add one due to the issues with compatibility. Python has third-party libraries made by the community to support sound, some dedicated (such as playsound or simpleaudio) which you can install from PyPi. Replit, however, runs your code remotely on a container in their servers, so any sound produced would not get to you, in the browser, if it was even produced. To combat this, Replit has created an API for playing sound, which allows you to bypass this and get Replit to play the sound directly in the browser. You can do this quite easily with the replit module; see Bookie0's answer.

Profile icon
Coder2195

@19wintersp I went onto the website for "combatting" sound inconvienece... It doesn't work...

Profile icon
19wintersp

@Coder2195Text You need to be an explorer, like it says in massive text at the top. Do you have that turned on?

Profile icon
Coder2195

@19wintersp I already have it on and it doesn't work

Profile icon
19wintersp

@Coder2195Text Could you be more specific about what's not working? The example repls do not work on their own; their audio files are blank.

Profile icon
Coder2195

@19wintersp the audio files are blank

Profile icon
19wintersp
Profile icon
Bookie0

There's already sound in Python, use repl.it audio. Check this out for the full blog.

You'll probably need to be an explorer for that. To be an explorer, go to account:

Screen Shot 2021-02-10 at 2.55.15 PM

And scroll down to roles and check 'explorer':

Screen Shot 2021-02-10 at 2.55.24 PM

Quick program:

from replit import audio # imports library # replace audio_file.mp3 with the actual file # you can use .mp3, .wav, and .aiff source = audio.play_file("audio_file.mp3")

Good luck and have fun! :D