python pygame播放音频文件

python pygame播放音频文件

 

pip install pygame

 

 

复制代码
import pygame

# Initialize pygame
pygame.init()

# Load the MP3 file
pygame.mixer.music.load("1.mp3")

# Play the MP3 file
pygame.mixer.music.play()

# Wait for the MP3 file to finish playing
while pygame.mixer.music.get_busy():
    pygame.time.Clock().tick(10)

# Clean up
pygame.quit()
复制代码

 

 

 

########################

posted @   西北逍遥  阅读(56)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· 单线程的Redis速度为什么快?
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
历史上的今天:
2022-04-01 python plot_one_box
2021-04-01 matlab读取数据并操作
2020-04-01 6号主机Anaconda环境
2020-04-01 IfcRelAssociates
点击右上角即可分享
微信分享提示