Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

word-error-rate

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

word-error-rate

A set of tools to calculate edit distance and scores on a per word basis

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3K
increased by12.23%
Maintainers
1
Weekly downloads
 
Created
Source

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"); // => 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.25

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.25

FAQs

Package last updated on 02 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc