Shortcuts

torchaudio.functional.edit_distance

torchaudio.functional.edit_distance(seq1: Sequence, seq2: Sequence) int[source]

Calculate the word level edit (Levenshtein) distance between two sequences.

This feature supports the following devices: CPU

The function computes an edit distance allowing deletion, insertion and substitution. The result is an integer.

For most applications, the two input sequences should be the same type. If two strings are given, the output is the edit distance between the two strings (character edit distance). If two lists of strings are given, the output is the edit distance between sentences (word edit distance). Users may want to normalize the output by the length of the reference sequence.

Parameters:
  • seq1 (Sequence) – the first sequence to compare.

  • seq2 (Sequence) – the second sequence to compare.

Returns:

The distance between the first and second sequences.

Return type:

int

Tutorials using edit_distance:
ASR Inference with CTC Decoder

ASR Inference with CTC Decoder

ASR Inference with CTC Decoder

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources