Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do you add sound in python

+5 votes
asked Sep 25, 2023 by Aadi Agarwal (220 points)

2 Answers

0 votes
answered Sep 25, 2023 by Peter Minarik (89,130 points)

Please, check these articles:

Keep in mind that in OnlineGDB you're running your code on a server, so if the output of a Python code is a command line program, the sound will (or not at all) be played on the server, which you'll never hear as only text is transferred to your browser.

If you're running the code on your local PC or the output of the Python code is a web page, then the sound instrument is going to run on your local PC and the above is not an issue.

Good luck!

+2 votes
answered Oct 6, 2023 by Gulshan Negi (1,580 points)

Nice question. Well, there are lots of ways to do this.

The most common, easy and popular way which I also like and did is by using Playsound Library. 

For example.

from playsound import playsound

playsound('soundfile.mp3')

Thanks

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...