經(jīng)典的深度學(xué)習(xí)網(wǎng)絡(luò)AlexNet使用數(shù)據(jù)擴(kuò)充(Data Augmentation)的方式擴(kuò)大數(shù)據(jù)集,取得較好的分類效果。在深度學(xué)習(xí)的圖像領(lǐng)域中,通過(guò)平移、 翻轉(zhuǎn)、加噪等方法進(jìn)行數(shù)據(jù)擴(kuò)充。但是,在音頻(Audio)領(lǐng)域中,如何進(jìn)行數(shù)據(jù)擴(kuò)充呢?
音頻的數(shù)據(jù)擴(kuò)充,主要有以下四種方式:
音頻剪裁(Clip)
音頻旋轉(zhuǎn)(Roll)
音頻調(diào)音(Tune)
音頻加噪(Noise)
音頻解析基于librosa音頻庫(kù);矩陣操作基于scipy和numpy科學(xué)計(jì)算庫(kù)。
以下是Python的實(shí)現(xiàn)方式
01
音頻剪裁
import librosa
from scipy.io import wavfile y, sr = librosa.load("../data/love_illusion.mp3")
# 讀取音頻print y.shape, sr wavfile.write("../data/love_illusion_20s.mp3", sr, y[20 * sr:40 * sr])
# 寫入音頻
02
音頻旋轉(zhuǎn)
import cv2
import librosa
from scipy.io import wavfile y, sr = librosa.load("../data/raw/love_illusion_20s.mp3")
# 讀取音頻ly = len(y) y_tune = cv2.resize(y, (1, int(len(y) * 1.2))).squeeze() lc = len(y_tune) - ly y_tune = y_tune[int(lc / 2):int(lc / 2) + ly]print y.shape, sr wavfile.write("../data/raw/xxx_tune.mp3", sr, y_tune)
# 寫入音頻
03
音頻調(diào)音
import cv2
import librosa
from scipy.io import wavfile y, sr = librosa.load("../data/raw/love_illusion_20s.mp3")
# 讀取音頻ly = len(y) y_tune = cv2.resize(y, (1, int(len(y) * 1.2))).squeeze() lc = len(y_tune) - ly y_tune = y_tune[int(lc / 2):int(lc / 2) + ly]print y.shape, sr wavfile.write("../data/raw/xxx_tune.mp3", sr, y_tune)
# 寫入音頻
04
音頻加噪
import librosa
from scipy.io import wavfile
import numpy as np
y, sr = librosa.load("../data/raw/love_illusion_20s.mp3")
# 讀取音頻wn = np.random.randn(len(y)) y = np.where(y != 0.0, y + 0.02 * wn, 0.0)
# 噪聲不要添加到0上!print y.shape, sr wavfile.write("../data/raw/love_illusion_20s_w.mp3", sr, y)
# 寫入音頻
-
音頻
+關(guān)注
關(guān)注
29文章
3029瀏覽量
83161 -
python
+關(guān)注
關(guān)注
56文章
4825瀏覽量
86382
原文標(biāo)題:Python音頻的數(shù)據(jù)擴(kuò)充
文章出處:【微信號(hào):machinelearningai,微信公眾號(hào):機(jī)器學(xué)習(xí)算法與人工智能】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
請(qǐng)問(wèn)問(wèn)手機(jī)與電腦之間在沒(méi)有網(wǎng)絡(luò)的情況下如何進(jìn)行數(shù)據(jù)傳輸!
利用Python進(jìn)行數(shù)據(jù)分析之時(shí)間序列基礎(chǔ)
如何利用Python進(jìn)行數(shù)據(jù)分析
如何進(jìn)行數(shù)字信號(hào)處理呢?有哪幾個(gè)基本步驟呢?
串口通信中外設(shè)與開(kāi)發(fā)板串口通信是如何進(jìn)行數(shù)據(jù)傳輸?shù)模?/a>
STM32 USART串口是如何進(jìn)行數(shù)據(jù)處理的呢
PC機(jī)的串口調(diào)試助手與STM32是如何進(jìn)行數(shù)據(jù)收發(fā)的
什么是信號(hào)處理?如何進(jìn)行數(shù)字信號(hào)處理呢?
數(shù)據(jù)庫(kù)教程之如何進(jìn)行數(shù)據(jù)庫(kù)設(shè)計(jì)

在風(fēng)格遷移中如何進(jìn)行數(shù)據(jù)增強(qiáng)
藍(lán)牙m(xù)idi和藍(lán)牙音頻或者藍(lán)牙audio有什么區(qū)別呢

e絡(luò)盟大幅擴(kuò)充PUI Audio產(chǎn)品系列以強(qiáng)化音頻產(chǎn)品組合

評(píng)論