V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
JohnChiu
V2EX  ›  Python

Python 有转换音频采样率的库吗?

  •  
  •   JohnChiu ·
    jozhn · 2019-05-05 20:50:35 +08:00 · 5311 次点击
    这是一个创建于 1811 天前的主题,其中的信息可能已经有所发展或是发生改变。

    已有 mp3 文件的码率都是 44100Hz,想全部转换为 16000Hz,Windows 下手动可以使用 Audacity 这个软件,但是有很多 mp3 的话就很麻烦。

    所以 Python 有没有什么库可以实现转换音频的采样率呢?

    第 1 条附言  ·  2019-05-05 21:25:41 +08:00

    谢谢大家,测试了ffmpeg-python,完成需求,不过压缩率较高所以时长会长一些。

    python代码:

    import ffmpeg
    
    ffmpeg.input('input.mp3').output('output.mp3', ar=16000).run()
    

    另外看到stackoverflow上说sox专门处理音频也不错。

    6 条回复    2019-05-06 11:45:20 +08:00
    ly50247
        1
    ly50247  
       2019-05-05 21:04:07 +08:00   ❤️ 1
    可以用 python-ffmpeg,或者直接调用 ffmpeg。
    fengtons
        2
    fengtons  
       2019-05-05 21:09:31 +08:00 via Android   ❤️ 1
    foobar2000 可以批量转换
    MeteorCat
        3
    MeteorCat  
       2019-05-05 21:11:25 +08:00 via Android   ❤️ 1
    ffmpeg+1
    omph
        4
    omph  
       2019-05-05 21:25:34 +08:00   ❤️ 1
    pydub,好像只支持 wav
    Emrys365
        5
    Emrys365  
       2019-05-06 11:02:18 +08:00   ❤️ 1
    SoulMelody
        6
    SoulMelody  
       2019-05-06 11:45:20 +08:00   ❤️ 1
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2736 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:45 · PVG 22:45 · LAX 07:45 · JFK 10:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.