0
Q:

how to play music in python

from playsound import playsound
playsound('audio.mp3')
9
#!/usr/bin/env python3
# Import playsound module
from playsound import playsound
 
# Input an existing wav filename
wavFile = input("Enter a wav filename: ")
# Play the wav file
playsound(wavFile)
 
# Input an existing mp3 filename
mp3File = input("Enter a mp3 filename: ")
# Play the mp3 file
playsound(mp3File)
1
#pip install playsound
from playsound import playsound
playsound('your mp3 file.mp3')
1
#pip install pygame
import pygame
pygame.mixer.init()
pygame.mixer.music.load("your.mp3")
pygame.mixer.music.play()#add a -1 like so: pygame.mixer.music.play(-1) and the music will repeat forever
0
import os

# Everything stops when played
os.system("afplay sound.wav")

# Everything continues when played
os.system("afplay sound.wav&")
-2

New to Communities?

Join the community