Question:
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
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.
playsound('filename')
Hope that helps!!!
That may be, but using audio on replit is highly unreliable unless you have a VNC or Webview session.
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.
@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!
I mean embed a python program into html
ye if you want that would probably work
Is the embed code on the page for it?
Um I do not know if that is a thing…
But u said that I could embed the python
I mean you probably could but only in a webapp?
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.
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.