推荐学习书目
› 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 · May 5, 2019 · 6423 views
    This topic created in 2706 days ago, the information mentioned may be changed or developed.

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

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

    Supplement 1  ·  May 5, 2019

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

    python代码:

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

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

    6 replies  •  2019-05-06 11:45:20 +08:00
    ly50247
        1
    ly50247  
       May 5, 2019   ❤️ 1
    可以用 python-ffmpeg,或者直接调用 ffmpeg。
    fengtons
        2
    fengtons  
       May 5, 2019 via Android   ❤️ 1
    foobar2000 可以批量转换
    MeteorCat
        3
    MeteorCat  
       May 5, 2019 via Android   ❤️ 1
    ffmpeg+1
    omph
        4
    omph  
       May 5, 2019   ❤️ 1
    pydub,好像只支持 wav
    Emrys365
        5
    Emrys365  
       May 6, 2019   ❤️ 1
    SoulMelody
        6
    SoulMelody  
       May 6, 2019   ❤️ 1
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2316 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 09:53 · PVG 17:53 · LAX 02:53 · JFK 05:53
    ♥ Do have faith in what you're doing.