Skip to content

Commit

Permalink
Checkpoint before Yun's model
Browse files Browse the repository at this point in the history
  • Loading branch information
rajatkuls committed Aug 9, 2017
1 parent ee56d45 commit 3025a4e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
models
yun
*.swp
*~
*.pyc
22 changes: 13 additions & 9 deletions labelTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}



Expand All @@ -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]
Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions wrap-b.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
7 changes: 5 additions & 2 deletions wrap-d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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)
Expand All @@ -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')
Expand Down

0 comments on commit 3025a4e

Please sign in to comment.