word-error-rate
This package scores a speech recognition service's recognition quality. It calculates Levenshtein Edit Distance on a per word basis, since speech recognition services will never misspell a word. If, for example, is given an audio file that says "one coconut" and mishears "won coconut", the edit distance it will calculate will be 1. If we were instead calculating edit distance on a per-character basis, it would have calculated a distance of 2 (the number of transformations necessary to turn "won" into "one"). This package also surfaces a function to calculate word error rate, which can be described formulaically as: 1 - (editDistance(utterance1, utterance2)/maxLength(utterance1, utterance2))
. This allows to generate a normalized score across different recognition models.
Usage
npm install word-error-rate
JavaScript
const speechScorer = require("word-error-rate");
speechScorer.calculateEditDistance("one hen", "won hen");
speechScorer.wordErrorRate("one hen", "won hen");
speechScorer.calculateEditDistance("one hen two ducks", "won hen too ducts");
speechScorer.wordErrorRate("one hen two ducks", "won hen too ducts");
TypeScript
import { calculateEditDistance, wordErrorRate } from "word-error-rate";
calculateEditDistance("one hen", "won hen");
wordErrorRate("one hen", "won hen");
calculateEditDistance("one hen two ducks", "won hen too ducts");
wordErrorRate("one hen two ducks", "won hen too ducts");