Skip to content

Commit

Permalink
small enhanecements (#1322)
Browse files Browse the repository at this point in the history
- add extra check of 'x' and 'x_lens' to earlier point in Transducer model
- specify 'utf' encoding when opening text files for writing (recogs,
  errs)
  • Loading branch information
KarelVesely84 authored Oct 19, 2023
1 parent ce372cc commit 543b4cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions egs/librispeech/ASR/pruned_transducer_stateless7/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def forward(

assert x.size(0) == x_lens.size(0) == y.dim0

# x.T_dim == max(x_len)
assert x.size(1) == x_lens.max().item(), (x.shape, x_lens, x_lens.max())

encoder_out, x_lens = self.encoder(x, x_lens)
assert torch.all(x_lens > 0)

Expand Down
4 changes: 2 additions & 2 deletions icefall/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def store_transcripts(
Returns:
Return None.
"""
with open(filename, "w") as f:
with open(filename, "w", encoding="utf8") as f:
for cut_id, ref, hyp in texts:
if char_level:
ref = list("".join(ref))
Expand All @@ -523,7 +523,7 @@ def store_transcripts_and_timestamps(
Returns:
Return None.
"""
with open(filename, "w") as f:
with open(filename, "w", encoding="utf8") as f:
for cut_id, ref, hyp, time_ref, time_hyp in texts:
print(f"{cut_id}:\tref={ref}", file=f)
print(f"{cut_id}:\thyp={hyp}", file=f)
Expand Down

0 comments on commit 543b4cc

Please sign in to comment.