用 Python 播放声音 [英] Play a Sound with Python

查看:40
本文介绍了用 Python 播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Python 中播放声音文件 (.wav) 的最简单方法是什么?最简单的意思是最独立的平台和最少的依赖.pygame 当然是一个选择,但对于声音来说似乎有点过分.

What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems overkill for just sound.

推荐答案

The Snack Sound Toolkit 可以播放 wav、au 和 mp3 文件.

The Snack Sound Toolkit can play wav, au and mp3 files.

s = Sound() 
s.read('sound.wav') 
s.play()

这篇关于用 Python 播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆