Today aiping Point reading pen MP3 source files appear inconsistent sound size, and need to be English word MP3 and Word translation MP3 file connection, just start using ffmpeg effect is poor. The Almighty Gitgub proved its omnipotence again, and I found Pydub.
1 Website: https://github.com/jiaaro/pydub
2 Pydub need to rely on LIBAV or ffmpeg
3 installation in a Mac environment dependency: (Two choice one)
Brew Install LIBAV--with-libvorbis--with-sdl--with-theora All dependencies are installed on ~~brew install ffmpeg--WITH-FDK-AAC--with-ffplay --with-freetype--with-frei0r--with-libass--with-libvo-aacenc--with-libvorbis--with-libvpx--with-opencore-amr-- With-openjpeg--with-opus--with-rtmpdump--with-schroedinger--with-speex--with-theora--with-tools--WITH-FDK-AAC- -with-freetype--with-ffplay--with-ffplay--with-freetype--with-frei0r--with-libass--with-libbluray-- With-libcaca--with-libquvi--with-libvidstab--with-libvo-aacenc--with-libvorbis--with-libvpx--with-opencore-amr --with-openjpeg--with-openssl--with-opus--with-rtmpdump--with-schroedinger--with-speex--with-theora-- With-tools--with-x265
4 Installing PYDUB:PIP Install Pydub
5 Using Pydub:
Enpath = "%s%s/%s"% (endir,file,enfile) #英文文件的路径 cnpath = "%s%s/%s"% (Cndir,file,enfile.replace ("En_w", "Cn_w")) # The path of the Chinese file TargetPath = "%s%s/%s"% (Todir,file,enfile.replace ("En_w", "All")) #合并文件的路径 #加载MP3文件 song1 = Audiosegment.from_mp3 (enpath) song2 = Audiosegment.from_mp3 (cnpath) #取得两个MP3文件的声音分贝 db1 = Song1.dbfs DB2 = Song2.dbfs song1 = song1[300:] #从300ms开始截取英文MP3 #调整两个MP3的声音大小 to prevent a sound from appearing large one sound small case Dbplus = db1 -DB2 if Dbplus < 0: # song1 sounds smaller song1+=abs (dbplus) elif dbplus > 0: #song2的声音更小 song2+=abs ( Dbplus) #拼接两个音频文件 song = song1 + song2 #导出音频文件 song.export (TargetPath, format= "MP3") #导出为MP3格式
Python Processing audio files (mp3)