播放音频与Python [英] Play audio with Python

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

问题描述

我怎么能播放的音频(它会像1秒声音)从Python脚本?

How can I play audio (it would be like a 1 second sound) from a Python script?

这将是最好的,如果它是独立的平台,但首先它需要在Mac上工作。

It would be best if it was platform independent, but firstly it needs to work on a Mac.

我知道我可以只从内部的Python执行 afplay file.mp3 命令,但有可能做到这一点原始的Pyt​​hon?我会更好,如果它不依赖于外部库。

I know I could just execute the afplay file.mp3 command from within Python, but is it possible to do it in raw Python? I would also be better if it didn't rely on external libraries.

推荐答案

您可以找到有关Python的音频信息在这里: HTTP:/ /wiki.python.org/moin/Audio/

You can find information about Python audio here: http://wiki.python.org/moin/Audio/

它看起来并不像它可以播放.mp3文件,无需外部库。你既可以你的.mp3文件转换为一个.wav或其他格式,或使用如 PyMedia

It doesn't look like it can play .mp3 files without external libraries. You could either convert your .mp3 file to a .wav or other format, or use a library like PyMedia.

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

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