Skip to content

Commit 38cc512

Browse files
Merge pull request #153 from hyperion-ml/persephone-refactor
np.bool -> bool
2 parents 501859a + b8fe5cb commit 38cc512

File tree

9 files changed

+14
-23
lines changed

9 files changed

+14
-23
lines changed

hyperion/bin/eval_xvec_cosine_scoring_from_transfer_adv_test_wav.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def eval_cosine_scoring(
243243
vad = v_reader.read([key.seg_set[j]])[0]
244244
tot_frames = len(vad)
245245
speech_frames = np.sum(vad)
246-
vad = torch.as_tensor(vad.astype(np.bool, copy=False), dtype=torch.bool).to(
246+
vad = torch.as_tensor(vad.astype(bool, copy=False), dtype=torch.bool).to(
247247
device
248248
)
249249
model.vad_t = vad
@@ -361,9 +361,7 @@ def main():
361361

362362
parser.add_argument("--vad", dest="vad_spec", default=None)
363363
parser.add_argument(
364-
"--vad-path-prefix",
365-
default=None,
366-
help=("scp file_path prefix for vad"),
364+
"--vad-path-prefix", default=None, help=("scp file_path prefix for vad"),
367365
)
368366

369367
parser.add_argument("--model-path", required=True)

hyperion/bin/generate_adv_attacks_xvector_classif.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,18 +208,13 @@ def generate_attacks(
208208
vad = v_reader.read([key])[0]
209209
tot_frames = len(vad)
210210
speech_frames = np.sum(vad)
211-
vad = torch.as_tensor(vad.astype(np.bool, copy=False), dtype=torch.bool).to(
211+
vad = torch.as_tensor(vad.astype(bool, copy=False), dtype=torch.bool).to(
212212
device
213213
)
214214
model.vad = vad
215215
logging.info(
216216
"utt %s detected %d/%d (%.2f %%) speech frames"
217-
% (
218-
key,
219-
speech_frames,
220-
tot_frames,
221-
speech_frames / tot_frames * 100,
222-
)
217+
% (key, speech_frames, tot_frames, speech_frames / tot_frames * 100,)
223218
)
224219

225220
t2 = time.time()
@@ -329,9 +324,7 @@ def main():
329324

330325
parser.add_argument("--vad", dest="vad_spec", default=None)
331326
parser.add_argument(
332-
"--vad-path-prefix",
333-
default=None,
334-
help=("scp file_path prefix for vad"),
327+
"--vad-path-prefix", default=None, help=("scp file_path prefix for vad"),
335328
)
336329

337330
parser.add_argument("--model-path", required=True)

hyperion/bin/generate_adv_attacks_xvector_verif.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def generate_attacks(
217217
vad = v_reader.read([key.seg_set[j]])[0]
218218
tot_frames = len(vad)
219219
speech_frames = np.sum(vad)
220-
vad = torch.as_tensor(vad.astype(np.bool, copy=False), dtype=torch.bool).to(
220+
vad = torch.as_tensor(vad.astype(bool, copy=False), dtype=torch.bool).to(
221221
device
222222
)
223223
model.vad_t = vad

hyperion/np/classifiers/greedy_fusion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def fit(self, x, class_ids, sample_weights=None):
226226
num_cands = len(cand_systems)
227227
cand_min_dcf = np.zeros((num_cands,), dtype=float_cpu())
228228
cand_act_dcf = np.zeros((num_cands,), dtype=float_cpu())
229-
all_pos = np.zeros((num_cands,), dtype=np.bool)
229+
all_pos = np.zeros((num_cands,), dtype=bool)
230230
cand_weights = []
231231
for j in range(num_cands):
232232
system_idx_ij = np.concatenate(

hyperion/np/diarization/diar_ahc_plda.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _plot_score_hist(scores, output_file, thr=None, gmm=None):
6666
output_dir = Path(output_file).parent
6767
output_dir.mkdir(parents=True, exist_ok=True)
6868

69-
mask = np.triu(np.ones(scores.shape, dtype=np.bool), 1)
69+
mask = np.triu(np.ones(scores.shape, dtype=bool), 1)
7070
scores_r = scores[mask].ravel()
7171

7272
_, bins, _ = plt.hist(
@@ -96,7 +96,7 @@ def _plot_score_hist(scores, output_file, thr=None, gmm=None):
9696
@staticmethod
9797
def _unsup_gmm_calibration(scores):
9898
"""Performs unsupervised calibration on the scores by training a GMM."""
99-
mask = np.triu(np.ones(scores.shape, dtype=np.bool), 1)
99+
mask = np.triu(np.ones(scores.shape, dtype=bool), 1)
100100
scores_r = scores[mask].ravel()[:, None] # N x 1
101101
gmm_1c = GMM(num_comp=1)
102102
gmm_1c.fit(scores_r, epochs=1)

hyperion/np/pdfs/jfa/jfa_total.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def TT(self):
281281
def _upptr(self):
282282
"""Upper triangular mask."""
283283
if self.__upptr is None:
284-
self.__upptr = np.triu(np.ones(self.y_dim, dtype=np.bool))
284+
self.__upptr = np.triu(np.ones(self.y_dim, dtype=bool))
285285
return self.__upptr
286286

287287
@staticmethod

hyperion/utils/info_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def get_loc(self, keys):
347347
if isinstance(loc, int):
348348
return loc
349349

350-
if isinstance(loc, np.ndarray) and loc.dtype == np.bool:
350+
if isinstance(loc, np.ndarray) and loc.dtype == bool:
351351
return np.nonzero(loc)[0]
352352

353353
return list(range(loc.start, loc.stop, loc.step))

hyperion/utils/rttm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ def get_bin_sample_mask_for_spk(
636636

637637
tend[tend > max_samples] = max_samples
638638

639-
vad = np.zeros((max_samples,), dtype=np.bool)
639+
vad = np.zeros((max_samples,), dtype=bool)
640640
for i, j in zip(tbeg, tend):
641641
if j > i:
642642
vad[i:j] = True

hyperion/utils/vad_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def vad_timestamps_to_bin(
135135
if max_frames is not None and num_frames < max_frames:
136136
num_frames = max_frames
137137

138-
vad = np.zeros((num_frames,), dtype=np.bool)
138+
vad = np.zeros((num_frames,), dtype=bool)
139139
frame_start = np.ceil(
140140
(in_timestamps[:, 0] - (pad + frame_center)) / frame_shift
141141
).astype(dtype=np.int)
@@ -242,7 +242,7 @@ def intersect_segment_timestamps_with_vad(in_timestamps, vad_timestamps):
242242
vad_start = vad_timestamps[:, 0]
243243
vad_end = vad_timestamps[:, 1]
244244
num_vad_segs = len(vad_start)
245-
speech_idx = np.zeros((in_timestamps.shape[0],), dtype=np.bool)
245+
speech_idx = np.zeros((in_timestamps.shape[0],), dtype=bool)
246246
out_timestamps = []
247247
out_timestamps2speech_segs = []
248248
count_speech = 0

0 commit comments

Comments
 (0)