torchaudio.functional.edit_distance¶
- torchaudio.functional.edit_distance(seq1: Sequence, seq2: Sequence) int [source]¶
Calculate the word level edit (Levenshtein) distance between two sequences.
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:
- Tutorials using
edit_distance
: ASR Inference with CTC Decoder
ASR Inference with CTC Decoder