日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python 音频处理软件_python处理音频文件(mp3)

發布時間:2023/12/29 python 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 音频处理软件_python处理音频文件(mp3) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

今天aiping點讀筆的MP3源文件出現聲音大小不一致,而且需要將英文單詞MP3與單詞翻譯MP3文件連接起來,剛開始使用ffmpeg效果很差。萬能的gitgub再次證明了它的萬能,我找到了pydub

1 網址:https://github.com/jiaaro/pydub

2 pydub需要依賴 libav或者ffmpeg

3 在mac環境下安裝依賴:(二選一)

brew install libav --with-libvorbis --with-sdl --with-theora

將所有依賴都安裝上~~

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 安裝pydub: ?pip install pydub

5 使用pydub:

enPath = "%s%s/%s"%(enDir,file,enfile) #英文文件的路徑

cnPath = "%s%s/%s"%(cnDir,file,enfile.replace("en_w","cn_w"))#中文文件的路徑

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的聲音大小,防止出現一個聲音大一個聲音小的情況

dbplus = db1 - db2

if dbplus < 0: # song1的聲音更小

song1+=abs(dbplus)

elif dbplus > 0: #song2的聲音更小

song2+=abs(dbplus)

#拼接兩個音頻文件

song = song1 + song2

#導出音頻文件

song.export(targetPath, format="mp3") #導出為MP3格式

總結

以上是生活随笔為你收集整理的python 音频处理软件_python处理音频文件(mp3)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。