Categories
Python Answers

How to play a wav file in Python?

Spread the love

Sometimes, we want to play a wav file in Python.

In this article, we’ll look at how to play a wav file in Python.

How to play a wav file in Python?

To play a wav file in Python, we can use the playsound library.

To install it, we run

pip install playsound

Then we use it by writing

from playsound import playsound

playsound('/path/to/a/sound/file/you/want/to/play.wav')

to call playsound with the path of the wav file to play it.

Conclusion

To play a wav file in Python, we can use the playsound library.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *