def cook(): for wavfilename in glob(join(COOKED_FOLDER, '*.wav')): print('Cooking ' + split(wavfilename)[1]) signal = Signal(wavfilename) feat = mfcc(signal.data, signal.rate) outname = MFCC_DIR + split(wavfilename)[1].replace('wav', 'txt') out = open(outname, 'w') # out.write(str(len(feat))+' '+str(len(feat[0]))+'\n') for i in range(len(feat)): out.write(str(list(feat[i])).strip('[]').replace(' ', '') + '\n') out.close() print('Done')
def inputs(signal): signal_fft = zeros(256) i = 0 while(i + 400 < len(signal)): signal_fft = vstack([signal_fft, frame_fft(signal[i : i+400], window = 'Hamming', K = 512, N = 400, size1 = 256)]) i += 160 signal_fft = delete(signal_fft, 0, axis = 0) MFCC = zeros(13) for i in signal_fft: MFCC = vstack([MFCC, mfcc(i)]) MFCC = delete( MFCC, 0, axis = 0) return MFCC
def create_json(): (rate, sig) = wav.read("english.wav") mfcc_feat = mfcc(sig, rate) d_mfcc_feat = delta(mfcc_feat, 2) fbank_feat = logfbank(sig, rate) python_arr = fbank_feat[1:3, :] print(python_arr) json_conv = python_arr.tolist() database_format = json.dumps({ "Chris": json_conv }) # Need to change to the user inputed name in the application #with open('coeff2.json', 'w') as json_file: #json_file.write(database_format) #os.system("mv coeff.json newfile.json") return render_template('main.html', dblist=database_format)
def main(): n = 1 step = 15 width = 30 Mono, fs = normalize('../../audio/cmu_us_bdl_arctic/wav/arctic_a0001.wav') ms = makeframe(Mono, width, step, fs) # check Preprocessing.py pitch(n) # check Pitch.py y = formant(fs, Mono) # check Formants.py y = mfcc(fs, Mono) # check MFCC.py nbrf = 15 #nbr de fichier aléatoires sélectionnés pour le rule-based system rulebased(nbrf)
#!/usr/bin/env python from MFCC import mfcc from MFCC import delta from MFCC import logfbank import scipy.io.wavfile as wav (rate,sig) = wav.read("../sounds/english.wav") mfcc_feat = mfcc(sig, rate) d_mfcc_feat = delta(mfcc_feat, 2) fbank_feat = logfbank(sig, rate) print(fbank_feat[1:3,:])
while i < len(signal)-100: # print i object = part(i, signal) i = object.end simplelist.append(object) print "end" global_max = max( map( lambda x: x.maxima, simplelist)) new_list = filter( lambda x: x.maxima >= float(global_max)/16, simplelist) print len(new_list), len(simplelist) sig = [] for i in new_list: sig = concatenate([sig, signal[i.start:i.end]]) # write("edited.wav", rate, sig) signal_fft = zeros(256) i = 0 while(i + 400 < len(signal)): signal_fft = vstack([signal_fft, frame_fft(signal[i : i+400], window = 'Hamming', K = 512, N = 400, size1 = 256)]) i += 160 signal_fft = delete(signal_fft, 0, axis = 0) MFCC = zeros(13) for i in signal_fft: MFCC = vstack([MFCC, mfcc(i)]) MFCC = delete( MFCC, 0, axis = 0) savetxt("MFCC.csv", MFCC, delimiter = ',')