python处理声音的包:pygame,playsound
import wave import math import glob import matplotlib.pyplot as pl import pygame import time musicPath="D:\\12.wav" pygame.mixer.init()#初始化 pygame.init() track = pygame.mixer.music.load(musicPath)#加载音乐 pygame.mixer.music.play()#播放 while pygame.mixer.music.get_busy(): time.sleep(0.1)
注明:在遇到声音不播放的情况时,可能是因为:
pygame.mixer.init()#初始化 pygame.init()
两者顺序写反了