Python的转换WAV到MP3 [英] Python convert wav to mp3

查看:2547
本文介绍了Python的转换WAV到MP3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了pymedia(停产),pyglet(伟大的,但在那里没有转换器)和audiotools(命令行CD抓取),并没有显得合适。

I've looked at pymedia (discontinued), pyglet(great but no converter in there) and audiotools(command line cd ripping), and none seem suitable.

在Python 2.7,你怎么办

In Python 2.7 , how do you do

convert(wavFileLocation, 'mp3')

如果没有Python是这样,你会如何的方式做到这蟒蛇可以调用? (例如,呼叫一个跨平台的命令行工具......如果存在回报(名称,蟒蛇codeForInvocation))

If there is no python way, how would you do it in a manner which python can invoke? (e.g. Call a Cross platform command line tool... if exists return (name, pythonCodeForInvocation) )

推荐答案

使用(命令行),可以连接code WAV到MP3是这样的:

using lame (command line), you can encode wav to mp3 like this:

$ lame --preset insane /path/to/file.wav

这将创建:

file.wav.mp3

在Python中,你可以使用来调用它:

in Python, you could use subprocess to call it:

wav = 'myfile.wav'
cmd = 'lame --preset insane %s' % wav
subprocess.call(cmd, shell=True)

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

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