How play Sounds of .MP3 and .wav in Python

 To play a sound there are various ways but I 'll be telling u the easiest .

 Using playsound

  • Installing Playsound module :    

      1) Open Command Prompt
            - Go to Start and search for cmd.
            - OR press Windows + R and in the dialogue box type 'cmd' and then OK.

      2) In the Command Prompt type  py -m pip install -U playsound --user  .

      3) After few seconds it will start downloading.


  • How to use playsound?

            import playsound
    playsound.playsound('<location of audio file>',True)

   
    Example:

If location of file is inside Local Disk E and inside Minim TOTALCOOLSTUFFS and then inside MP3 and name of file is hello .mp3. Then the location of file will be :
E:\Minim TOTALCOOLSTUFFS\MP3\hello.mp3

The location is case as well as space sensitive.

Run the program and the sound will start playing after few seconds.



    




Comments