Upload feats.py
Browse files
feats.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from lhotse.features.io import KaldiWriter
|
2 |
+
import numpy as np
|
3 |
+
|
4 |
+
for part in ["train_clean_460", "dev_clean", "test_clean"]:
|
5 |
+
with open(f"./exp/xvector_nnet_1a/xvectors_{part}/spk_xvector.txt", "r") as f:
|
6 |
+
with KaldiWriter(f"./exp/xvector_nnet_1a/xvectors_{part}/") as writer:
|
7 |
+
features = [line.strip().split() for line in f]
|
8 |
+
for feature in features:
|
9 |
+
key = feature[0]
|
10 |
+
feats = feature[2:-1]
|
11 |
+
feats = [float(f) for f in feats]
|
12 |
+
assert len(feats) == 512
|
13 |
+
writer.write(key, np.array([feats], dtype=np.float32))
|