(data_dir,
                       num_spk,
                       num_utt_per_spk,
                       feat_len=100,
                       feat_dim=40)
return loaded_meta
Generate a dummy data directory and return its meta.
Generate a dummy data directory and return its meta.
Generate a dummy data directory and return its meta .
def gen_dummy_data_dir(data_dir,
                       num_spk,
                       num_utt_per_spk,
                       feat_len=100,
                       feat_dim=40):
  ''' Generate a dummy data directory and return its meta. '''
  os.makedirs(data_dir, exist_ok=True)

  meta = kaldi_dir.KaldiMetaData()
  feats = {}
  vads = {}
  for spk_idx in range(num_spk):
    for utt_idx in range(num_utt_per_spk):
      spk = str(spk_idx)
      utt = '%s_%d' % (spk, utt_idx)
      utt_meta = kaldi_dir.Utt()
      feat_mat = np.ones((feat_len, feat_dim), dtype='float32')
      feats[utt] = feat_mat
      utt_meta.featlen = feat_len
      vad_mat = np.ones((feat_len,), dtype='float32')
      vads[utt] = vad_mat
      utt_meta.spk = spk
      meta.utts[utt] = utt_meta
  meta.collect_spks_from_utts()
  meta.dump(data_dir, True)

  feats_ark_path = os.path.join(data_dir, 'feats.ark')
  feats_scp_path = os.path.join(data_dir, 'feats.scp')
  kaldiio.save_ark(feats_ark_path, feats, scp=feats_scp_path, text=True)
  vad_ark_path = os.path.join(data_dir, 'vad.ark')
  vad_scp_path = os.path.join(data_dir, 'vad.scp')
  kaldiio.save_ark(vad_ark_path, vads, scp=vad_scp_path, text=True)

  loaded_meta = kaldi_dir.KaldiMetaData()
  loaded_meta.load(data_dir)
  return loaded_meta
def gen_dummy_data_dir ( data_dir , num_spk , num_utt_per_spk , feat_len = 100 , feat_dim = 40 ) : os . makedirs ( data_dir , exist_ok = True ) meta = kaldi_dir . KaldiMetaData ( ) feats = { } vads = { } for spk_idx in range ( num_spk ) : for utt_idx in range ( num_utt_per_spk ) : spk = str ( spk_idx ) utt = '%s_%d' % ( spk , utt_idx ) utt_meta = kaldi_dir . Utt ( ) feat_mat = np . ones ( ( feat_len , feat_dim ) , dtype = 'float32' ) feats [ utt ] = feat_mat utt_meta . featlen = feat_len vad_mat = np . ones ( ( feat_len , ) , dtype = 'float32' ) vads [ utt ] = vad_mat utt_meta . spk = spk meta . utts [ utt ] = utt_meta meta . collect_spks_from_utts ( ) meta . dump ( data_dir , True ) feats_ark_path = os . path . join ( data_dir , 'feats.ark' ) feats_scp_path = os . path . join ( data_dir , 'feats.scp' ) kaldiio . save_ark ( feats_ark_path , feats , scp = feats_scp_path , text = True ) vad_ark_path = os . path . join ( data_dir , 'vad.ark' ) vad_scp_path = os . path . join ( data_dir , 'vad.scp' ) kaldiio . save_ark ( vad_ark_path , vads , scp = vad_scp_path , text = True ) loaded_meta = kaldi_dir . KaldiMetaData ( ) loaded_meta . load ( data_dir ) return loaded_meta