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
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)