Help me play sound

How do I make a function to play a sound in python?
Repl link:
You don’t really need the link


replit is really buggy for console sound, so it doesn’t really work unless you have a VNC or webview repl

1 Like

So if I find a way to put it in an HTML page then it would work?


yes that would work


Pip has a module called playsound that allows you to, well, play sound! To install, use this program:

import os
os.system("pip install playsound")

That will install the package to your repl.
Then have this code:

from playsound import playsound

then all you have to do is enter this line of code replacing filename with the name of the file.


Hope that helps!!!

1 Like

That may be, but using audio on replit is highly unreliable unless you have a VNC or Webview session.

1 Like

Thank you for that. I probably should have tested as I have only used it in python on my computer! THANKS

I’m not saying your code won’t work, it might (haven’t tested myself), but if it does it will probably be unreliable. (ESP if on cover page.)

as I said sound doesn’t work on replit.

1 Like

@Firepup650 @bigminiboss I see what you are saying! Thanks for all the feedback! I will make a mental note about that, and maybe test it out. That program works in IDLE on the computer (on a Windows defiantly, I haven’t tried on a mac) So @Esb678 listen to bigminiboss and firepup650. They know what they are doing! :slight_smile:

1 Like

I mean embed a python program into html

1 Like

ye if you want that would probably work

Is the embed code on the page for it?

1 Like

Um I do not know if that is a thing…

But u said that I could embed the python

1 Like

I mean you probably could but only in a webapp?

Replit has a audio library
Here is the video:

Hope it works
If works please mark it as Solution

As has been stated multiple times in this thread, replit’s audio library is unreliable, and really only works in the editor and does not function on the cover page.

1 Like

ok i guess this is literally unsolveable

Not necessarily, if you create a website you could play audio. Of course, that wouldn’t be with Python, that would be with HTML and JavaScript.