diff --git a/.gitignore b/.gitignore index 57bc4b6..438ca90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ models +yun *.swp *~ *.pyc diff --git a/labelTools.py b/labelTools.py index 1ac9c5b..006a720 100644 --- a/labelTools.py +++ b/labelTools.py @@ -89,14 +89,16 @@ "CXF": "OCH", # other child far } -silDict = {'SIL':0,'SPE':1} -classDict = {'CHI':1,'MOT':2,'FAT':3,'OCH':4,'OAD':5,'OTH':6} # child mother father otherchild otheradult -classDictBinary = {'CHI':1,'MOT':2,'FAT':2,'OCH':1,'OAD':2,'OTH':3} # child adult -classDictTernary = {'CHI':1,'MOT':2,'FAT':3,'OCH':1,'OAD':4,'OTH':4} # child male female +revDictSil = {0:'SIL',1:'SPE'} +revDict = {1:'CHI',2:'MOT',3:'FAT',4:'OCH',5:'OAD',6:'OTH'} +revDictBinary = {1:'CHI',2:'ADU',3:'OTH'} +revDictTernary = {1:'CHI',2:'WOM',3:'MAN',4:'OTH'} + +silDict = {'SIL':0,'SPE':1,'rev':revDictSil} +classDict = {'CHI':1,'MOT':2,'FAT':3,'OCH':4,'OAD':5,'OTH':6,'rev':revDict} # child mother father otherchild otheradult +classDictBinary = {'CHI':1,'MOT':2,'FAT':2,'OCH':1,'OAD':2,'OTH':3,'rev':revDictBinary} # child adult +classDictTernary = {'CHI':1,'MOT':2,'FAT':3,'OCH':1,'OAD':4,'OTH':4,'rev':revDictTernary} # child male female -revDict = {1:'CHI',2:'MOT',3:'FAT',4:'OCH',5:'OAD',6:'OTH'} -revDictBinary = {1:'CHI',2:'ADU',3:'OTH'} -revDictTernary = {1:'CHI',2:'WOM',3:'MAN',4:'OTH'} @@ -122,7 +124,8 @@ def stmNewLine(medianame,label,start,end): return '\t'.join([medianame,label,medianame+'_'+label,str(start),str(end)]) + '\n' def writeToStm(y,labelsDict,medianame,outfilename): - revDict = {v:k for k,v in labelsDict.items()} + # revDict = {v:k for k,v in labelsDict.items()} + revDict = labelsDict['rev'] revDict[silDict['SIL']] = 'SIL' y = np.asarray(y) boundaries = list((y[:-1] != y[1:]).nonzero()[0] + 1) + [y.shape[0]-1] @@ -142,7 +145,8 @@ def audacityNewLine(start,end,label): def writeToAudacity(y,labelsDict,outfilename): - revDict = {v:k for k,v in labelsDict.items()} + # revDict = {v:k for k,v in labelsDict.items()} + revDict = labelsDict['rev'] revDict[silDict['SIL']] = 'SIL' y = np.asarray(y) boundaries = list((y[:-1] != y[1:]).nonzero()[0] + 1) + [y.shape[0]-1] diff --git a/wrap-b.py b/wrap-b.py index aa3b5cd..885e7e1 100644 --- a/wrap-b.py +++ b/wrap-b.py @@ -26,6 +26,7 @@ model = sys.argv[2] # model saved by wrap-a outfileFolder = sys.argv[3] except: + print 'System inputs not detected, using defaults' model = 'models/a_classifier_all.p' outfileFolder = 'models' diff --git a/wrap-d.py b/wrap-d.py index 68e0ac6..e358576 100644 --- a/wrap-d.py +++ b/wrap-d.py @@ -35,6 +35,7 @@ outfileFolder = sys.argv[3] speechModel = sys.argv[4] except: + print 'System inputs not detected, using defaults' classModel = 'models/class_short_short_class2.p' outfileFolder = 'models' speechModel = 'models/a_classifier_all.p' @@ -46,6 +47,8 @@ classDictBinary = labelTools.classDictBinary classDictTernary = labelTools.classDictTernary +thisClassDict = classDictTernary + X_test = extractFeatures.getRawStVectorPerWav(inputWav,stWin,stStep) X_test = X_test.T y_class_test = clf.predict(X_test) @@ -67,8 +70,8 @@ medianame = extractFeatures.basename(inputWav) -labelTools.writeToStm(y_out,classDictBinary,medianame,outfileFolder+'/'+medianame+'.stm') -labelTools.writeToAudacity(y_out,classDictBinary,outfileFolder+'/'+medianame+'.txt') +labelTools.writeToStm(y_out,thisClassDict,medianame,outfileFolder+'/'+medianame+'.stm') +labelTools.writeToAudacity(y_out,thisClassDict,outfileFolder+'/'+medianame+'.txt') pickle.dump(y_out,open(outfileFolder+'/'+medianame+'_y_out.p','w')) os.system('cp '+inputWav+' '+outfileFolder+'/'+medianame+'.wav')