def main(): kannada = "C:\\Users\\bhuvan\\Desktop\\training set\\Kannada\\wav" hindi = "C:\\Users\\bhuvan\\Desktop\\training set\\Hindi\\wav" kan_files = test_gmm_win.list_files(['--dirpath=' + kannada]) hindi_files = test_gmm_win.list_files(['--dirpath=' + hindi]) nobj = gmm.GaussianMixtureModel.loadobject("C:\\Users\\bhuvan\\sonus\\gmm-object") kan_detected = 0 hin_detected = 0 for i in range(600, 800): a = sonusreader.SonusReader.from_file(os.path.join(kannada, kan_files[i])) b = sonusreader.SonusReader.from_file(os.path.join(hindi, hindi_files[i])) adata = mfcc.mfcc(a.data, samplerate=a.samplerate) bdata = mfcc.mfcc(b.data, samplerate=b.samplerate) if nobj.fit(adata) == 0: kan_detected = kan_detected + 1 if nobj.fit(bdata) == 1: hin_detected = hin_detected + 1 print '-' * 30 print 'Language', '\t\ttested files', '\t\tdetected files' print 'Kannada' , '\t\t' + str(200), '\t\t' + str(kan_detected) print 'Hindi', '\t\t' + str(200), '\t\t' + str(hin_detected) print '-' * 30
def main(): kannada = "C:\\Users\\bhuvan\\Desktop\\training set\\Kannada\\wav" hindi = "C:\\Users\\bhuvan\\Desktop\\training set\\Hindi\\wav" kan_files = list_files(['--dirpath=' + kannada]) hindi_files = list_files(['--dirpath=' + hindi]) numfiles = min(len(kan_files), len(hindi_files)) len_train_set = int(round(0.6 * numfiles)) training_set = [] for i in range(len_train_set): training_set.append((os.path.join(kannada, kan_files[i]), os.path.join(hindi, hindi_files[i]))) data = [] audio1 = sonusreader.SonusReader.from_file(training_set[0][0]) audio2 = sonusreader.SonusReader.from_file(training_set[0][1]) mfcc1 = mfcc.mfcc(audio1.data, samplerate=audio1.samplerate) mfcc2 = mfcc.mfcc(audio2.data, samplerate=audio2.samplerate) data = np.vstack((mfcc1, mfcc2)) for example in training_set[1:]: audio1 = sonusreader.SonusReader.from_file(example[0]) audio2 = sonusreader.SonusReader.from_file(example[1]) mfcc1 = mfcc.mfcc(audio1.data, samplerate=audio1.samplerate) mfcc2 = mfcc.mfcc(audio2.data, samplerate=audio2.samplerate) d = np.vstack((mfcc1, mfcc2)) data = np.vstack((data, d)) print 'done' GMM = gmm.GaussianMixtureModel(data, 2, options={ 'method':'uniform' }) GMM.expectationMaximization() gmm.GaussianMixtureModel.saveobject(GMM, filepath="C:\\Users\\bhuvan\\sonus\\uniform")