Approximate the WER of an ASR transcript
Project description
Word Error Rate for automatic speech recognition
This repository contains a simple python package to approximate the WER of a transcript. It computes the minimum-edit distance between the ground-truth sentence and the hypothesis sentence of a speech-to-text API. The minimum-edit distance is calculated using the Wagner-Fisher algorithm. Because this algorithm computes the character-level minimum-edit distance, every word in a sentence is assigned a unique integer, and the edit-distance is computed over a string of integers.
Installation
You should be able to install this package using pip:
$ pip install jiwer
Usage
The most simple use-case is computing the edit distance between two strings:
from jiwer import wer
ground_truth = "hello world"
hypothesis = "hello duck"
error = wer(ground_truth, hypothesis)
You can also compute the WER over multiple sentences:
from jiwer import wer
ground_truth = ["hello world", "i like monthy python"]
hypothesis = ["hello duck", "i like python"]
error = wer(ground_truth, hypothesis)
When the amount of ground-truth sentences and hypothesis sentences differ, a minimum alignment is done over the merged sentence:
ground_truth = ["hello world", "i like monthy python", "what do you mean, african or european swallow?"]
hypothesis = ["hello", "i like", "python", "what you mean swallow"]
# is equivelent to
ground_truth = "hello world i like monhty python what do you mean african or european swallow"
hypothesis = "hello i like python what you mean swallow"
Additional preprocessing
Some additional preprocessing can be done on the input. By default, whitespace is removed, everything is set to lower-case,
.
and ,
are removed, everything between []
and <>
(common for Kaldi models) is removed and each word is tokenized by
splitting by one or more spaces. Additionally, common abbreviations, such as won't
, let's
,n't
will be expanded if
standardize=True
is passed along the wer
method.
from jiwer import wer
ground_truth = "he's my neminis"
hypothesis = "he is my <unk> [laughter]"
wer(ground_truth, hypothesis, standardize=True)
# is equivelent to
ground_truth = "he is my neminis"
hypothesis = "he is my"
wer(ground_truth, hypothesis)
Also, there is an option give a list of words to remove from the transcription, such as "yhe", or "so".
from jiwer import wer
ground_truth = "yhe about that bug"
hypothesis = "yeah about that bug"
wer(ground_truth, hypothesis, words_to_filter=["yhe", "yeah"])
# is equivelent to
ground_truth = "about that bug"
hypothesis = "about that bug"
wer(ground_truth, hypothesis)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jiwer-1.3.1.tar.gz
.
File metadata
- Download URL: jiwer-1.3.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5cfb608b168a032ae071b9f4bc8ffdf653a7e9150d7997940b72a0a6b2ec4f2 |
|
MD5 | afb696dbe722bcb951a29bc65118787c |
|
BLAKE2b-256 | 8e1e198a34b1d1dace818b9627a417cf02d9cf7fc2d4daa275c380dfea0ee728 |
File details
Details for the file jiwer-1.3.1-py3-none-any.whl
.
File metadata
- Download URL: jiwer-1.3.1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5971fc85ce18502230b7e183f716a3828707999e598e5a2517df1b0a5dff78fb |
|
MD5 | 05fa7fe4aa901da3dcd66ef10c6c8180 |
|
BLAKE2b-256 | ce05d9fd03f30f710a4c691b03010bca2b4c3e6b1ee543a77d70c8a5ff560106 |