Mohan Raj
Mohan Raj

Reputation: 197

Python is not playing sound but it finishes the program successfully without errors

I am trying to play sound in Python. When I run my code, it finishes successfully but the audio is not played by my computer.

I have tried with all the libraries like playsound, simpleaudio, pydub and kivy core audio.

Sample code I tried is:

from playsound import playsound

playsound('myfile.wav')

Upvotes: 2

Views: 1669

Answers (2)

jort57
jort57

Reputation: 76

I've had this problem before, use the complete path:

from playsound import playsound
playsound(r"C:\some\path\sound.mp3") # the "r" is necessary, or else your code wont work!

Upvotes: 0

Ashwini Sahu
Ashwini Sahu

Reputation: 9

As i think it should work, check either your audio file (maybe it's empty) or check your audio drivers and audio output.

OR, You can try

pip install playsound one more time

Upvotes: 0

Related Questions