1.调用系统默认播放器播放
import os
os.system('test.mp3')
语速正常,缺点,弹出播放器窗口,可能点击后反应比较慢
2. pygame 播放
安装 pip install pygame
import pygame
pygame.mixer.init()
track = pygame.mixer.music.load('test.mp3’)
pygame.mixer.music.play()
time.sleep(10)
pygame.mixer.music.stop()
语速失真
3. mp3play 播放
pip install mp3play
import mp3play
def playmusic(path):
clip = mp3play.load(path)
clip.play()
time.sleep(10)
clip.stop()
playmusic('test.mp3')
语速正常,但只能用于python2.7,不支持python3.x