本文整理汇总了Python中SR.test方法的典型用法代码示例。如果您正苦于以下问题:Python SR.test方法的具体用法?Python SR.test怎么用?Python SR.test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SR
的用法示例。
在下文中一共展示了SR.test方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: endpointing
# 需要导入模块: import SR [as 别名]
# 或者: from SR import test [as 别名]
def endpointing(self, current):
energy = 0.0
# print current
# print len(current)
self.is_speech = False
for i in range(len(current)):
energy += pow(current[i], 2)
energy = 10 * numpy.log(energy)
# print self.threshold, self.level, self.background
# print energy
if self.index == 0:
self.level = energy
# threshold equals to max energy of first ten frames divide 4
if self.index < 10 and self.index >= 0:
if self.max_energy < energy:
self.max_energy = energy
self.background += energy
if self.index == 9:
self.background /= 10
self.threshold = self.max_energy / 4
if self.index >= 10:
if energy < self.background:
self.background = energy
else:
self.background += (energy - self.background) * self.adjustment
self.level = (self.level * self.forget_factor + energy) / (self.forget_factor + 1)
if self.level < self.background:
self.level = self.background
if self.level - self.background > self.threshold:
self.is_speech = True
if self.is_speech != self.past_is_speech:
if self.is_speech:
self.begin_index = self.index
# print "speech begin at %d\n" % self.begin_index
# print 'energy = %d\n' % energy
else:
self.end_index = self.index
if self.time_synchronous and self.end_index - self.begin_index > 8:
# if self.need_train:
# self.need_train = 0
# self.DTW_obj = SR.training_model(5, self.using_kmeans)[0]
SR.test(self.time_synchronous, 1, 5, self.using_kmeans, self.begin_index,
self.end_index, self.DTW_obj, self.read_feature_from_file)
# print "speech end at %d\n" % self.end_index
# print 'energy = %d\n' % energy
self.past_is_speech = self.is_speech
self.index += 1