Python library for converting files to MP3 and setting their quality

前端 未结 6 1960
天涯浪人
天涯浪人 2020-12-14 18:35

I\'m trying to find a Python library that would take an audio file (e.g. .ogg, .wav) and convert it into mp3 for playback on a webpage.

Also, any thoughts on settin

6条回答
  •  被撕碎了的回忆
    2020-12-14 19:25

    I wrote a library designed to do that =D

    from pydub import AudioSegment
    AudioSegment.from_file("/input/file").export("/output/file", format="mp3")
    

    Easy!

    to specify a bitrate, just use the bitrate kwarg…

    from pydub import AudioSegment
    sound = AudioSegment.from_file("/input/file")
    sound.export("/output/file", format="mp3", bitrate="128k")
    

提交回复
热议问题