I want to play an audio file on my raspberry pi. So far I have used PyAudio, PyDub and Pygame but none of theme work. I also used omxplayer to play the audio file and the speaker worked which means that raspberry pi is able to detect the speaker attached. So I don't understand what's the problem with code since it doesn't even throw any errors.
For pygame:
from pygame import mixer
import time
mixer.init()
mixer.music.load('Applause/previewand the winner is.mp3')
mixer.music.play()
time.sleep(2)
mixer.music.stop()
For pydub
from pydub import AudioSegment
from pydub.playback import play
from pydub import effects
music = AudioSegment.from_mp3('<File>')
play(music)
Python version : 3.7.3