altwer
altwer is a Python package designed for evaluating automatic speech recognition (ASR) results, particularly for languages where multiple correct spellings or expressions of the same word are acceptable. This phenomenon, known as orthographic variation or linguistic variability, is common in languages like Norwegian, Danish, Dutch, and some dialect-rich languages, where regional or formal differences influence spelling and vocabulary. Other languages might allow spellings like both "e-mail" and "email".
For instance, in Norwegian, both "matta" and "matten" might be correct spelling of "the mat" depending on regional usage or style, just as both "broa" and "broen" are valid spellings for "the bridge." Such variability poses challenges for ASR evaluation, as standard WER metrics treat these as errors.
The Problem
In traditional WER evaluation:
- Normalization: Techniques like lowercasing or removing punctuation are often used to reduce variability. However, these methods are insufficient when evaluating languages with valid orthographic or lexical differences, as they cannot account for meaning-preserving variations.
- Ambiguity in Transcriptions: Some transcription guidelines may allow optional elements like fillers (e.g., "uh", "eh", "ah") or minor regional variations, but standard WER evaluation penalizes all deviations from a single reference transcription.
For example:
- Hypothesis: "katten ligger på matta"
- Reference: "katten ligger på matten"
This would result in an error in standard WER, despite both being correct.
The Suggested Solution
altwer addresses this issue by allowing references to specify multiple valid alternatives.
- The altwer-package computes the WER by considering all alternatives in the reference and selecting the one that minimizes the error. If alternate spellings are specified, the best match is computed automatically. In cases where alternate spellings are not specified, altwer should give the same result as jiwer. This approach makes altwer ideal for:
- Handling Orthographic Variation: Allows multiple correct spellings. For example:
[matta|matten]or[organization|organisation]or[email|e-mail]. - Optional Fillers: Handles other cases where you do not want variations to be counted as errors. For example:
[eh|ah|uhh|...|]or[WHO|World Health Organization].
- Use LLMs to automate the creation of this format. Experiments indicates that prompted correctly a Reasoning-model is able to create at least a first draft of this format. We provide some example tempates for doing the conversion.
Installation
Install with pip:
pip install altwer
Usage
from altwer import wer
references = [
"[jenta|jenten] [jogga|jogget] på [broa|broen|brua|bruen]",
"[katten|katta] ligger på [matta|matten]",
"Det var en fin dag."
]
hypotheses = [
"jenta jogga på broa",
"katten ligger på matta",
"Det var en fin dag."
]
# Calculate WER
wer_score = wer(references, hypotheses, verbose=True, lowercase=True, remove_punctuation=True)
print(f"WER: {wer_score:.4f}")
Version 0.4.0
- Ensures compatibility with the latest
jiwerAPI while remaining backwards compatible. - Supports both pipe-separated and legacy JSON-style reference alternatives when expanding matches.
License
MIT
Metadata
Release files for altwer 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| altwer-0.4.0.tar.gz | 6.0 kB | Without provenance | Details for altwer-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| altwer-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for altwer-0.4.0-py3-none-any.whl |
Total release size: 11.7 kB
Release files / altwer-0.4.0.tar.gz
| Download URL | altwer-0.4.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f97d6a4e0edebaa6f07ca89ef072fd78e7958c5dd757411793ea5d1ce2c2246
|
|
BLAKE2b-256 checksum How to use checksums |
a64dbe5aa5755316b6a2a1b34a81c7140c9bbd15dd4ffa17ce5df45acd1796ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / altwer-0.4.0-py3-none-any.whl
| Download URL | altwer-0.4.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b580432af40c3a6d0d3ca037982351ed27e76f062e3a8e2bcdbe68d297312750
|
|
BLAKE2b-256 checksum How to use checksums |
66bff37d11d1bb56ba6b5a30a4008963177a85c42e64f07f40dcf337c11c360f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for altwer 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.