def processAcousticModelTrainPho(class_name,syllableTierName,phonemeTierName,featureFilename,gmmModel_path):
'''
Monophonic acoustic model training
:param mode: sourceSeparation, qmLonUpfLaosheng
:param syllableTierName: 'pinyin', 'dian'
:param phonemeTierName: 'details'
:param featureFilename: 'dic_pho_feature_train.pkl'
:param gmmModel_path: in parameters.py
:return:
'''
# model training
recordings_train = getRecordingNamesSimi('TRAIN',class_name)
dic_pho_feature_train = dumpFeaturePho(class_name,recordings_train,syllableTierName,phonemeTierName)
output = open(featureFilename, 'wb')
pickle.dump(dic_pho_feature_train, output)
output.close()
# model loading
pkl_file = open(featureFilename, 'rb')
dic_pho_feature_train = pickle.load(pkl_file)
pkl_file.close()
n_comp = 40
g = mixture.GaussianMixture(n_components=n_comp,covariance_type='diag')
print len(dic_pho_feature_train.keys())
for ii,key in enumerate(dic_pho_feature_train):
# print key, dic_pho_feature_train[key].shape
print 'fitting gmm ', key, ' ', str(ii), ' of ', str(len(dic_pho_feature_train.keys()))
##-- try just fit the first dim of MFCC
# x = np.expand_dims(dic_pho_feature_train[key][:,0],axis=1)
x = dic_pho_feature_train[key]
print x.shape
if x.shape[0] > n_comp*5:
g.fit(x)
output = open(os.path.join(gmmModel_path,key+'.pkl'),'wb')
pickle.dump(g, output)
output.close()
else:
# yn not fitted, because too few samples
print(key+' is not fitted.')
acousticModelTraining.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录