forked from espnet/espnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeats2npy.py
More file actions
executable file
·29 lines (24 loc) · 837 Bytes
/
feats2npy.py
File metadata and controls
executable file
·29 lines (24 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python
# coding: utf-8
import argparse
from kaldiio import ReadHelper
import numpy as np
import os
from os.path import join
import sys
def get_parser():
parser = argparse.ArgumentParser(
description="Convet kaldi-style features to numpy arrays",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument("scp_file", type=str, help="scp file")
parser.add_argument("out_dir", type=str, help="output directory")
return parser
if __name__ == "__main__":
args = get_parser().parse_args(sys.argv[1:])
os.makedirs(args.out_dir, exist_ok=True)
with ReadHelper(f"scp:{args.scp_file}") as f:
for utt_id, arr in f:
out_path = join(args.out_dir, f"{utt_id}-feats.npy")
np.save(out_path, arr, allow_pickle=False)
sys.exit(0)