Skip to content

Commit

Permalink
MMS: Fix forced alignment API usage (facebookresearch#5138)
Browse files Browse the repository at this point in the history
  • Loading branch information
vineelpratap authored May 23, 2023
1 parent 87d3005 commit bc8e8b1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions examples/mms/data_prep/align_and_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ def get_alignments(
token_indices = []

blank = dictionary["<blank>"]

targets = torch.tensor(token_indices, dtype=torch.int32).to(DEVICE)
input_lengths = torch.tensor(emissions.shape[0])
target_lengths = torch.tensor(targets.shape[0])

path, _ = F.force_align(
emissions, torch.Tensor(token_indices, device=DEVICE).int(), blank=blank
path, _ = F.forced_align(
emissions, targets, input_lengths, target_lengths, blank=blank
)
path = path.to("cpu").tolist()
segments = merge_repeats(path, {v: k for k, v in dictionary.items()})
Expand Down

0 comments on commit bc8e8b1

Please sign in to comment.