def testDataSet(datasetpath, succes_rate):
    for model in os.listdir('GMMModels/'):
        models_name.append(model)
        tmp = Models.retrieveModels('GMMModels/' + model)
        models.append(tmp)
    total_files = 0
    for folder in os.listdir(datasetpath):
        for audio in os.listdir(datasetpath + folder):
            total_files += 1
            samplerate, audiofile = rd(datasetpath + folder + '/' + audio)
            mfcc_features = extract_features(audiofile, samplerate)
            max_score = -999999
            max_model = models[0]
            i = 0
            for model in models:
                score = model.score(mfcc_features)
                if score > max_score:
                    max_score = score
                    max_model = models_name[i]
                i = i + 1

            if max_model[:len(max_model) - 4] == folder:
                succes_rate += 1
    succes_rate = (succes_rate * 1.00) / total_files
    print(str((succes_rate) * 100) + "%")
def testSingleaudio(testpath):
    samplerate, audiofile = rd(testpath)
    mfcc_features = extract_features(audiofile, samplerate)
    maxscore = -999999
    speaker = ""
    for model in os.listdir('GMMModels/'):
        tmp = Models.retrieveModels('GMMModels/' + model)
        score = tmp.score(mfcc_features)
        if score > maxscore:
            maxscore = score
            speaker = model.split(".gmm")[0]
    return speaker
Exemplo n.º 3
0
def singleModelTraining(audiopath,modeldest) :
	mfcc_features = np.asarray(())
	for folder in os.listdir(audiopath) :
		samplerate , audiofile = rd(audiopath + '/'+folder )
		tmp   = extract_features(audiofile,samplerate)
		if mfcc_features.size == 0 :
			mfcc_features = tmp
		else :
			mfcc_features = np.vstack((mfcc_features , tmp))
	gmm = GMM(n_components = 16, max_iter = 200, covariance_type='diag',n_init = 3)
	gmm.fit(mfcc_features)
	Models.saveModels(modeldest , gmm , audiopath[12:])
Exemplo n.º 4
0
def to_array(name):  
    a = np.asarray(((rd(name))[1])[:, 0], dtype = np.float32)   
    return a