(self, stats)
Do CMVN.
    :param stats: Statistics of features.
    :return: Mean and std of features.
Do CMVN.
    :param stats: Statistics of features.
    :return: Mean and std of features.
Do CMVN . : param stats : Statistics of features . : return : Mean and std of features .
def call(self, stats):
    """
    Do CMVN.
    :param stats: Statistics of features.
    :return: Mean and std of features.
    """
    p = self.config

    if isinstance(stats, dict):
      stats_dict = dict(stats)
    else:
      if p.filetype == 'mat':
        stats_dict = {None: kaldiio.load_mat(stats)}
      elif p.filetype == 'ark':
        stats_dict = dict(kaldiio.load_ark(stats))
      else:
        raise ValueError('Not supporting filetype={}'.format(p.filetype))

    if p.utt2spk is not None:
      self.utt2spk = {}
      with io.open(p.utt2spk, 'r', encoding='utf-8') as f:
        for line in f:
          utt, spk = line.rstrip().split(None, 1)
          self.utt2spk[utt] = spk

    elif p.spk2utt is not None:
      self.utt2spk = {}
      with io.open(p.spk2utt, 'r', encoding='utf-8') as f:
        for line in f:
          spk, utts = line.rstrip().split(None, 1)
          for utt in utts.split():
            self.utt2spk[utt] = spk
    else:
      self.utt2spk = None

    self.bias = {}
    self.scale = {}
    for spk, stats in stats_dict.items():
      assert len(stats) == 2, stats.shape

      count = stats[0, -1]

      if not (np.isscalar(count) or isinstance(count, (int, float))):
        count = count.flatten()[0]

      mean = stats[0, :-1] / count
      var = stats[1, :-1] / count - mean * mean
      std = np.maximum(np.sqrt(var), p.std_floor)
      self.bias[spk] = -mean
      self.scale[spk] = 1 / std
def call ( self , stats ) : p = self . config if isinstance ( stats , dict ) : stats_dict = dict ( stats ) else : if p . filetype == 'mat' : stats_dict = { None : kaldiio . load_mat ( stats ) } elif p . filetype == 'ark' : stats_dict = dict ( kaldiio . load_ark ( stats ) ) else : raise ValueError ( 'Not supporting filetype={}' . format ( p . filetype ) ) if p . utt2spk is not None : self . utt2spk = { } with io . open ( p . utt2spk , 'r' , encoding = 'utf-8' ) as f : for line in f : utt , spk = line . rstrip ( ) . split ( None , 1 ) self . utt2spk [ utt ] = spk elif p . spk2utt is not None : self . utt2spk = { } with io . open ( p . spk2utt , 'r' , encoding = 'utf-8' ) as f : for line in f : spk , utts = line . rstrip ( ) . split ( None , 1 ) for utt in utts . split ( ) : self . utt2spk [ utt ] = spk else : self . utt2spk = None self . bias = { } self . scale = { } for spk , stats in stats_dict . items ( ) : assert len ( stats ) == 2 , stats . shape count = stats [ 0 , - 1 ] if not ( np . isscalar ( count ) or isinstance ( count , ( int , float ) ) ) : count = count . flatten ( ) [ 0 ] mean = stats [ 0 , : - 1 ] / count var = stats [ 1 , : - 1 ] / count - mean * mean std = np . maximum ( np . sqrt ( var ) , p . std_floor ) self . bias [ spk ] = - mean self . scale [ spk ] = 1 / std