+ 6

How do i play a audio file in python?

18th Oct 2018, 3:45 PM
LONGTIE👔
LONGTIE👔 - avatar
13 Réponses
+ 6
import winsound winsound.PlaySound('sound.wav', winsound.SND_FILENAME) https://stackoverflow.com/questions/307305/play-a-sound-with-JUMP_LINK__&&__python__&&__JUMP_LINK
18th Oct 2018, 4:41 PM
Mert Yazıcı
Mert Yazıcı - avatar
18th Oct 2018, 4:39 PM
Mert Yazıcı
Mert Yazıcı - avatar
18th Oct 2018, 5:28 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 4
I don't have any other things. Maybe you can find something here https://wiki.python.org/moin/Audio/
18th Oct 2018, 5:50 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 3
Mert Yazıcı im not using linux, im using Windows
18th Oct 2018, 4:40 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 3
Mert Yazıcı do you know of any cross platform friendly ways to do it? and do i put the path in the SND_FILENAME area?
18th Oct 2018, 5:22 PM
LONGTIE👔
LONGTIE👔 - avatar
19th Oct 2018, 12:24 PM
Oma Falk
Oma Falk - avatar
+ 2
Mert Yazıcı i think that only works with python 2
18th Oct 2018, 5:49 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 2
pygame works fine for just that !
22nd Oct 2018, 2:56 PM
Beyar
Beyar  - avatar
+ 1
LONGTIE👔 winsound.SND_FILENAME is a constant indicating the first argument to Playsound() is a filename. Reference: https://docs.python.org/3/library/winsound.html
19th Oct 2018, 1:33 PM
Gordon
Gordon - avatar
+ 1
CodeIt in the example they use 'foo.mp3' would i put the path of the song in the quotes instead.
23rd Oct 2018, 12:30 AM
LONGTIE👔
LONGTIE👔 - avatar
+ 1
yes, please replace that in sample to include both path and filename
23rd Oct 2018, 12:34 AM
Gordon
Gordon - avatar