Ask coding questions

← Back to all posts
Python Sound
h
Coder2195Text (35)

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?

Comments
hotnewtop
RYANTADIPARTHI (6000)

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

BananaJellyfish (204)

you can, in fact, have sound with pygame.

BananaJellyfish (204)

@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

Coder2195Text (35)

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

BananaJellyfish (204)

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

BananaJellyfish (204)

@Coder2195Text oh. I thought you meant in general

YeetsaJr (20)

@Coder2195Text if you want an example I'm working on a chatroom project. when you send a message it makes a sound. It's in node.js https://repl.it/@YeetsaJr/TSP-Chatroom#index.js
If you want sound visit the repl docs site: https://docs.repl.it/repls/audio it gives a full in-depth explanation of how to add sound.
Hope this helps!

BananaJellyfish (204)

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

Coder2195Text (35)

@YeetsaJr THIS IS A PYTHON QUESTION NOT NODE JS

YeetsaJr (20)

@BananaJellyfish @Coder2195Text Dude, chill out. Open this, it has an example for python... Read it. https://docs.repl.it/repls/audio

19wintersp (1121)

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.

Coder2195Text (35)

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

19wintersp (1121)

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

Coder2195Text (35)

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

19wintersp (1121)

@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.

Bookie0 (5976)

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:

And scroll down to roles and check 'explorer':

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