我将安装Debian / Ubuntu软件包libav-tools并调用
avconv以将mp3解码为临时wav文件:
编辑:您的另一个问题已关闭,所以我将在这里用一个简单的带通滤波示例来扩展我的答案。在您链接的文件中,似乎大多数鸟鸣声都集中在4 kHz-5.5 kHz中。
import osfrom subprocess import check_callfrom tempfile import mktempfrom scikits.audiolab import wavread, playfrom scipy.signal import remez, lfilterfrom pylab import *# convert mp3, read wavmp3filename = 'XC124158.mp3'wname = mktemp('.wav')check_call(['avconv', '-i', mp3filename, wname])sig, fs, enc = wavread(wname)os.unlink(wname)# bandpass filterbands = array([0,3500,4000,5500,6000,fs/2.0]) / fsdesired = [0, 1, 0]b = remez(513, bands, desired)sig_filt = lfilter(b, 1, sig)sig_filt /= 1.05 * max(abs(sig_filt)) # normalizesubplot(211)specgram(sig, Fs=fs, NFFT=1024, noverlap=0)axis('tight'); axis(ymax=8000)title('Original')subplot(212)specgram(sig_filt, Fs=fs, NFFT=1024, noverlap=0)axis('tight'); axis(ymax=8000)title('Filtered')show()play(sig_filt, fs)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)