zrjin's picture
Upload feats.py
4feaec5 verified
raw
history blame contribute delete
615 Bytes
from lhotse.features.io import KaldiWriter
import numpy as np
for part in ["train_clean_460", "dev_clean", "test_clean"]:
with open(f"./exp/xvector_nnet_1a/xvectors_{part}/spk_xvector.txt", "r") as f:
with KaldiWriter(f"./exp/xvector_nnet_1a/xvectors_{part}/") as writer:
features = [line.strip().split() for line in f]
for feature in features:
key = feature[0]
feats = feature[2:-1]
feats = [float(f) for f in feats]
assert len(feats) == 512
writer.write(key, np.array([feats], dtype=np.float32))