Registry / data / texterrors

texterrors

JSON →
library1.1.8pypypi✓ verified 86d ago

texterrors is a Python library and command-line tool designed to score ASR (Automatic Speech Recognition) or transcription output against a reference. It provides metrics such as Word Error Rate (WER) and Character Error Rate (CER), supports standard and character-aware alignment, generates detailed error reports, and can produce colored output for inspection. The library also features comparison of multiple hypothesis files, per-group metrics (e.g., per-speaker WER), keyword and OOV (Out-Of-Vocabulary) evaluation, oracle WER, and simple entity accuracy. It aims to be an easy-to-use, modify, and extend alternative to older tools like `sclite`. The current version is 1.1.6, and it receives active maintenance and frequent updates.

pip install texterrors
INSTALL
IMPORT
SIG · TEXTERRORS
T
texterrors
datapythonv1.1.8
Install
7.2s avg
Import
666ms
Disk
127MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 7.5s
py 3.11
✓ —
✓ 6.53s
py 3.12
✓ —
✓ 5.78s
py 3.13
✕ build_error
✕ build_error
py 3.9
✓ —
✓ 8.83s
127MB installed
● package 127MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

align_texts
from texterrors import align_texts
This is the primary function for programmatic text alignment and error rate calculation.

This quickstart demonstrates how to use the `align_texts` function to calculate WER and CER programmatically. It takes tokenized reference and hypothesis lists and returns a detailed JSON object with various metrics. For more complex features such as colored output, per-group analysis, or simple entity accuracy, the `texterrors` command-line tool is often more convenient and directly supported.

from texterrors import align_texts # Reference and hypothesis texts as lists of tokens reference_tokens = ["this", "is", "a", "test", "sentence"] hypothesis_tokens = ["this", "is", "test", "sentance"] # Perform alignment and get metrics # The return_detailed_json=True flag provides comprehensive results. # For full features (like colored output, group metrics, entity accuracy), # the command-line interface is often more direct. result = align_texts( reference_tokens, hypothesis_tokens, ref_id="ref_utt_1", # Optional: utterance ID hyp_id="hyp_utt_1", # Optional: utterance ID return_detailed_json=True # Get comprehensive results ) print(f"WER: {result['wer']:.2f}%") print(f"CER: {result['cer']:.2f}%") print(f"Substitutions: {result['substitutions']}") print(f"Deletions: {result['deletions']}") print(f"Insertions: {result['ins']}") print("\nFirst 10 alignment details (token level):") for item in result['aligned_tokens'][:10]: print(item)
texterrors --version
Debug
Known issues
breakingThe `weighted WER` feature was removed, and `simple entity accuracy` was introduced in its place. Code relying on `weighted WER` will break.
fix
Migrate any usage of `weighted WER` to use the new `simple entity accuracy` features if applicable, or remove the deprecated functionality.
affects: <1.1.6
breakingThe extension module (handling core performance-critical parts) was migrated from `pybind11` to `nanobind` and the build system moved to `CMake/scikit-build-core`. This primarily affects users building `texterrors` from source or in complex C++/Python environments.
fix
Ensure your development environment has `nanobind` and `CMake` properly configured if building from source. For most users installing via `pip install texterrors`, pre-built wheels should handle this transparently.
affects: <1.1.6
gotchaCharacter-aware alignment, while a powerful feature, can result in a slightly higher WER compared to traditional tools (e.g., Kaldi's `sclite`) due to its more granular alignment strategy. Since 22.06.22, character-aware alignment is *off* by default.
fix
Be aware of this difference when comparing results. If precise parity with traditional tools is required, ensure character-aware alignment is explicitly disabled, or understand the implications if it's enabled.
affects: All versions
gotchaWhen using the command-line tool's colored output (`-c` flag), the output should be viewed with a pager like `less -R` to correctly interpret ANSI escape codes and display colors.
fix
Pipe the output to `less -R` (e.g., `texterrors -c ref.txt hyp.txt | less -R`).
affects: All versions
gotchaThe command-line tool expects specific input file formats. For files where each line starts with an utterance ID, the `--isark` flag is required. For CTM-like input including timing fields, `--isctm` is needed.
fix
Always check the `--help` output for the correct input flags (`texterrors -h`) and use them as appropriate for your data format.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'texterrors'
The `texterrors` package has not been installed in the current Python environment.
fix
pip install texterrors
ValueError: Reference and hypothesis files must have the same number of lines.
The input reference and hypothesis text files contain a different number of lines, preventing a one-to-one comparison for each utterance.
fix
Ensure both `reference_file` and `hypothesis_file` have the exact same number of lines, corresponding to each utterance pair.
TypeError: 'str' object is not iterable
The `texterrors.wer` and `texterrors.compute` functions expect `list[str]` (a list of lines) for their reference and hypothesis arguments, but received single `str` objects instead.
fix
Pass the reference and hypothesis as lists containing the strings, even for a single utterance: `texterrors.wer(["hello world"], ["hallo world"])`.
unrecognized arguments: --some_invalid_arg
The command-line interface was invoked with an argument that is not recognized or supported by the `texterrors` tool or its current version.
fix
Consult `texterrors --help` or the documentation for available arguments and correct spelling.
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position ...
The input reference or hypothesis file is not encoded in UTF-8, but `texterrors` attempts to read it using the default UTF-8 encoding.
fix
Specify the correct encoding using the `--encoding` argument in the command-line tool, e.g., `texterrors --encoding latin-1 ref.txt hyp.txt`.
Upgrade
Version history
1.1.8latest on PyPI · released Jun 9, 2026
Audit
Dependencies
pythonrequiredRequired Python version.
regexrequiredA dependency for advanced regular expression operations, which was explicitly fixed in a past release.
Agent activity
23 hits · last 30 days
node
18
OpenAI (training)
1
Resources
texterrors — pip install texterrors · libregistry