• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python features.mfcc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中scikits.talkbox.features.mfcc函数的典型用法代码示例。如果您正苦于以下问题:Python mfcc函数的具体用法?Python mfcc怎么用?Python mfcc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mfcc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: load_validation_set

def load_validation_set():
    """
    Output
        a tuple of features: (fft features, mfcc features, mean-std features)
    Description
        extracts three types of features from validation set.
    """
    ffts = dict()
    mfccs = dict()
    mean_stds = dict()

    for i in validation_ids:
        path = './validation/validation.{i}.wav'.format(i=i)

        _, X = read_wav(path)

        # FFT
        fft = np.array(abs(sp.fft(X)[:1000]))
        ffts.update({i: fft})

        # MFCC
        ceps, mspec, spec = mfcc(X)
        num_ceps = len(ceps)
        x = np.mean(ceps[int(num_ceps*1/10):int(num_ceps*9/10)], axis=0)
        mfccs.update({i: x})


        # Mean-Std
        [Fs, x] = audioBasicIO.readAudioFile(path);
        F = audioFeatureExtraction.stFeatureExtraction(x, Fs, 0.050*Fs, 0.025*Fs);
        mean_std = []
        for f in F:
            mean_std.extend([f.mean(), f.std()])
        mean_stds.update({i: np.array(mean_std)})
    return (ffts, mfccs, mean_stds)
开发者ID:hyunwooj,项目名称:unm-cs429,代码行数:35,代码来源:run.py


示例2: BED_extract

def BED_extract(path, nfft=784):
	list_data = numpy.array([])
	list_label = numpy.array([])
	#W:anger:0 N:neutral:1 F:happiness:2 T:sadness:3
	dic = {'W':0,'L':1,'E':3,'A':0,'F':2,'T':3,'N':1}

	for root, dir, files in os.walk(path):

		rootpath = os.path.join(os.path.abspath(path), root)

		for file in files:
			if os.path.splitext(file)[1].lower()=='.wav':
				filepath = os.path.join(rootpath, file)

				SR, X = wavfile.read(filepath)

				_, _, spec = mfcc(X, fs=SR, nfft=(nfft*2))

				print(filepath)

				list_data = numpy.append(list_data, numpy.mean(spec, axis=0)[:nfft]/numpy.max(spec))
				list_label = numpy.append(list_label, int(dic[file[5]]))

	list_data = numpy.reshape(list_data, (len(list_data)/nfft, nfft))

	return list_data, list_label
开发者ID:j-pong,项目名称:tensorflow_test,代码行数:26,代码来源:input_data.py


示例3: apply

    def apply(self, data):
        all_ceps = []
        for ch in data:
            ceps, mspec, spec = mfcc(ch)
            all_ceps.append(ceps.ravel())

        return np.array(all_ceps)
开发者ID:BabelTower,项目名称:seizure-detection,代码行数:7,代码来源:transforms.py


示例4: getmfccdata

def getmfccdata(path):
    """
    This function extracts the mfcc data from the wav files

    Parameters:
    -----------
    path - path to get the directory name of the songs present "E:\UNM\CS 529 - Intro to Machine Learning\Assignment 3\opihi.cs.uvic.ca\sound\genres"

    Returns:
    --------
    mfccdata - mfcc data matrix of size (600,13)
    """
    classesmatrix = np.zeros((no_of_docs, 1))                       # Stores the song, genre information in classesmatrix.txt file -> Line number as song index, genre
    mfccdata = np.zeros((no_of_docs, no_of_mfcc_features))          # Matrix (600,13) to store the fft features information of all the songs in 6 genres
    fileindex = 0                                                   # to store the current offset of the song
    for subdir, dirs, files in os.walk(path):                       # Traversing all the files in 6 genres
        if os.path.basename(subdir) in genres.keys():
            for f in files:
                if f.endswith('.wav'):
                    print "Processing file : " + f
                    sample_rate, X = scipy.io.wavfile.read(os.path.join(subdir, f))
                    ceps, mspec, spec = mfcc(X)
                    num_ceps = ceps.shape[0]
                    mfcc_features = np.mean(ceps[int(num_ceps * 1 / 10):int(num_ceps * 9 / 10)], axis=0)   # Extracts 13 features.
                    for i in range(len(mfcc_features)):
                        mfccdata[fileindex][i] = mfcc_features[i]
                    classesmatrix[fileindex] = genres[os.path.basename(subdir)]     # Storing the genre of every song in a matrix.
                    fileindex += 1
    np.savetxt('classesmatrix.txt', classesmatrix, '%d')                        # Writing the classesmatrix to a file.
    return mfccdata
开发者ID:vamshins,项目名称:Logistic-Regression,代码行数:30,代码来源:LogisticRegression.py


示例5: BED_extract

def BED_extract(path, nfft):
  list_data = numpy.array([])
  list_label = numpy.array([])
  
  """
  dic = {'W':[1,0],'L':[0,1],'E':[0,1],'A':[0,1],'F':[1,0],'T':[0,1],'N':[0.5,0.5]}
  """
  dic = {'W':[0,1],'L':[0,1],'E':[0,1],'A':[0,1],'F':[1,0],'T':[0,1],'N':[0.5,0.5]}
  

  for root, dir, files in os.walk(path):

    rootpath = os.path.join(os.path.abspath(path), root)

    for file in files:
      if os.path.splitext(file)[1].lower()=='.wav':
        filepath = os.path.join(rootpath, file)

        SR, X = wavfile.read(filepath)

        _, _, spec = mfcc(X, fs=SR, nfft=(nfft*2))

        list_data = numpy.append(list_data, numpy.mean(spec, axis=0)[:nfft]/numpy.max(spec))
        list_label = numpy.append(list_label, dic[file[5]])

  list_data = numpy.reshape(list_data, (len(list_data)/nfft, nfft))
  list_label = numpy.reshape(list_label, (len(list_label)/label_length, label_length))

  return list_data, list_label
开发者ID:j-pong,项目名称:tensorflow_test,代码行数:29,代码来源:BEDLDC_input_distance.py


示例6: sparkFeatureExt

def sparkFeatureExt(line):
        print line
        string1= file
        cut=string1[72:]
        cut=cut[:-10]
        intClass=ClassToInt(cut)

        (samplerate, wavedata) = wavfile.read(file)
        (s1,n1)= spectral_centroid(wavedata,512,samplerate)
        (sr1,nr1)= spectral_rolloff(wavedata,512,samplerate)
        (sf1,nf1)= spectral_flux(wavedata,512,samplerate)
        (rms,ts) = root_mean_square(wavedata, 512, samplerate);
        rms= rms[~np.isnan(rms)] #rms array contains NAN values and we have to remove these values
        (zcr,ts1) = zero_crossing_rate(wavedata, 512, samplerate);
        (MFCCs, mspec, spec) = mfcc(wavedata)
        MFCC_coef=list()
        ran=MFCCs.shape
        ran1=ran[0]
        for ind1 in range(13):
            sum=0
            summ=0
            for ind in range(ran1):
                sum+=MFCCs[ind,ind1]
            MFCC_coef.append(sum/ran1)
        eng= stEnergy(wavedata)
        #Win = 0.050
        #Step = 0.050
        #eps = 0.00000001
        return s1,sr1,sf1,rms,zcr,eng,MFCC_coef,intClass
开发者ID:vikaspalkar,项目名称:Parallel-Music-Genre-Classification,代码行数:29,代码来源:SparkFeatureExt.py


示例7: create_ceps

def create_ceps(fn):

    #print(">>>: [%s]" % fn)
    sample_rate, X = scipy.io.wavfile.read(fn)
    #print(">    - [%d]" % sample_rate)
    ceps, mspec, spec = mfcc(X,nceps=13)
    write_ceps(ceps, fn)
开发者ID:foreverjay,项目名称:machinelearning-1,代码行数:7,代码来源:ceps.py


示例8: apply

    def apply(self, data, meta=None):
        all_ceps = []
        for ch in data:
            ceps, mspec, spec = mfcc(ch)
            all_ceps.append(ceps.ravel())

        return to_np_array(all_ceps)
开发者ID:MichaelHills,项目名称:seizure-prediction,代码行数:7,代码来源:transforms.py


示例9: mfccIFY

def mfccIFY(dict_read):
    dict = {}
    for each in dict_read.keys():
        [sample_rate,X] = dict_read.get(each)
        ceps, mspec, spec = mfcc(X)
        dict[each] = ceps
    return dict
开发者ID:kcreddy,项目名称:Machine-Learning,代码行数:7,代码来源:Final_Classifier.py


示例10: compute_features

def compute_features(source, features):
    """
        compute features for all the tracks
    """
    for label in source.keys():
        for i in range(0,100):
            base_path = os.path.join(FT_DIR, "%s_%d" % (label, i))
            ft = []
            if 'zcr' in features:
                zcr, ts = zero_crossing_rate(source[label][i]['wavedata'], 512, source[label][i]['sample_rate'])
                ft.append(zcr)

            if 'rms' in features:
                rms, ts = root_mean_square(source[label][i]['wavedata'], 512, source[label][i]['sample_rate'])
                ft.append(rms)

            if 'sc' in features:
                sc, ts = spectual_centroid(source[label][i]['wavedata'], 2048, source[label][i]['sample_rate'])
                ft.append(sc)

            if 'sr' in features:
                sr, ts = spectral_rolloff(source[label][i]['wavedata'], 2048, source[label][i]['sample_rate'])
                ft.append(sr)

            if 'sf' in features:
                sf, ts = spectral_flux(source[label][i]['wavedata'], 2048, source[label][i]['sample_rate'])
                ft.append(sf)

            if 'mfcc' in features:
                ceps, mspec, spec = mfcc(source[label][i]['wavedata'])
                ft.append(ceps)

            write_features(ft, base_path)
开发者ID:nwang57,项目名称:genreClassifier,代码行数:33,代码来源:features.py


示例11: convert

def convert(path):
	data = {}
	data["sample_rate"], X = scipy.io.wavfile.read(path)
	data["ceps"], data["mspec"], data["spec"] = mfcc(X) #save everything it gives us in case it's useful lmao

	cep_count = len(data["ceps"])
	input_vector = np.array([np.mean(data["ceps"][int(cep_count / 10):int(cep_count * 9 / 10)], axis=0)])
	return input_vector
开发者ID:Laserbear,项目名称:deepkeylistener,代码行数:8,代码来源:mffc_converter.py


示例12: create_ceps

def create_ceps(fn):
    """
        Creates the MFCC features. 
    """    
    sample_rate, X = scipy.io.wavfile.read(fn)
    X[X==0]=1
    ceps, mspec, spec = mfcc(X)
    write_ceps(ceps, fn)
开发者ID:Shreya29,项目名称:music-genre-classifier,代码行数:8,代码来源:ceps.py


示例13: mfcc_sound_features

 def mfcc_sound_features(self):
     ceps, mspec, spec = mfcc(self.audio)
     
     num_ceps = len(ceps)
     #v = np.mean(ceps[int(num_ceps / 10):int(num_ceps * 9 / 10)], axis=0)
     v = np.mean(ceps, axis=0)
     
     return v
开发者ID:gkahn13,项目名称:pr2_play,代码行数:8,代码来源:extract_feature_vector.py


示例14: create_ceps

def create_ceps(wavfile):
	sampling_rate, song_array = scipy.io.wavfile.read(wavfile)
	"""Get MFCC
	ceps  : ndarray of MFCC
	mspec : ndarray of log-spectrum in the mel-domain
	spec  : spectrum magnitude
	"""
	ceps, mspec, spec = mfcc(song_array)
	write_ceps(ceps, wavfile)
开发者ID:suhasshrinivasan,项目名称:music-genre-classification,代码行数:9,代码来源:extract-features-MFCC.py


示例15: show

 def show(self, example):
   sound = audiolab.sndfile(self.base + example.file)
   frames = sound.read_frames(sound.get_nframes()) * 0.8
   mfcc = features.mfcc(frames[example.start: example.stop:2], fs=41000)
   print mfcc[0].shape
   fig = plt.figure()
   fig.set_size_inches(20, 20)
   ax = fig.add_subplot(111)
   ax.imshow(mfcc[0].transpose()[:, :100])
开发者ID:srush,项目名称:peoplesounds,代码行数:9,代码来源:data.py


示例16: create_ceps

def create_ceps(fn, op='plain'):
	sample_rate, X = wavfile.read(fn)
	
	if op == 'norm':
		norm = StandardScaler()
		X = norm.fit_transform(X)
	
	ceps, mspec, spec = mfcc(X)
	
	write_ceps(ceps, fn, op)
开发者ID:marlonsd,项目名称:MusicalGenreClassification,代码行数:10,代码来源:audio_load.py


示例17: get_features

def get_features(filename,feature_type):
    if feature_type == 'mfcc':
        test_audio_file = wave.open(filename, 'r')
        fileContents = get_audio(test_audio_file)
        # get mfcc coeffs and don't look at first (corresponds to energy in signal)
        coeffs = mfcc(fileContents,fs=44100)[0][1:] # [1] is mel coeffs, and [2] is entire FFT data???
        test_audio_file.close()
    elif feature_type == 'nlse':
        coeffs = timbrespace(filename)        # default hopsize=3, i.e. 50%, i.e. 150 ms
    return coeffs
开发者ID:aronglennon,项目名称:automatic_programming_sound_synthesis,代码行数:10,代码来源:features_functions.py


示例18: generate_mfcc

def generate_mfcc(path,test = False):
  """ 
    generating each song's fft
  """
  sample_rate, X = wavfile.read(path)
  ceps, mspec, spec = mfcc(X)
  if test==True:
    print "writing test data"
    write_mfcc(path,ceps,True)
  else:
    write_mfcc(path,ceps)
开发者ID:satyakrishnagorti,项目名称:MusicGenreClassification,代码行数:11,代码来源:mfcc_utils.py


示例19: get_mfcc2

def get_mfcc2(filename):
    from scikits.talkbox.features import mfcc
    import os
    import scipy

    rate, signal = scipy.io.wavfile.read(filename)
    ceps, mspec, spec = mfcc(signal)
    base_filename, ext = os.path.splitext(filename)
    data_filename = base_filename + ".ceps"
    np.save(data_filename, ceps)
    print(" Written %s" % data_filename)
开发者ID:HuiChangZhai,项目名称:huichangzhai.github.io,代码行数:11,代码来源:App.py


示例20: create_ceps

def create_ceps():
    for genre in GENRES:
        wav_list = glob.glob(os.path.join(BASE_DIR, genre, '*.' + 'wav'))
        npy_list = glob.glob(os.path.join(BASE_DIR, genre, '*.' + 'npy'))
        npy_list = [name[:-9] for name in npy_list]
        for fn in wav_list:
            if fn[:-4] not in npy_list:
                sample_rate, X = scipy.io.wavfile.read(fn)
                ceps, mspec, spec = mfcc(X)
                write_ceps(ceps, fn)
                print 'created ', fn[:-4] + '.ceps.npy'
开发者ID:Josephinity,项目名称:Music-Genre-Recognition,代码行数:11,代码来源:init.py



注:本文中的scikits.talkbox.features.mfcc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python timeseries.date_array函数代码示例发布时间:2022-05-27
下一篇:
Python tools.categorical函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap