word-error-rate
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

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: editDistance(utterance1, utterance2)/maxLength(utterance1, utterance2). This allows to generate a normalized error rate across different recognition models.

Usage

npm install word-error-rate

JavaScript

const speechScorer = require("word-error-rate");
speechScorer.calculateEditDistance("one hen", "won hen"); // => 1
speechScorer.wordErrorRate("one hen", "won hen"); // => 0.5
 
speechScorer.calculateEditDistance("one hen two ducks", "won hen too ducts"); // => 3
speechScorer.wordErrorRate("one hen two ducks", "won hen too ducts"); // => 0.75

TypeScript

import { calculateEditDistance, wordErrorRate } from "word-error-rate";
 
calculateEditDistance("one hen", "won hen"); // => 1
wordErrorRate("one hen", "won hen"); // => 0.5
 
calculateEditDistance("one hen two ducks", "won hen too ducts"); // => 3
wordErrorRate("one hen two ducks", "won hen too ducts"); // => 0.75

Readme

Keywords

none

Package Sidebar

Install

npm i word-error-rate

Weekly Downloads

2,751

Version

0.0.7

License

ISC

Unpacked Size

9.94 kB

Total Files

12

Last publish

Collaborators

  • ryvolum