Skip to main content

Evaluate ASR output while accounting for orthographic variation.

Project description

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:

  1. 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.
  2. 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.

  1. 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].
  1. 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 jiwer API while remaining backwards compatible.
  • Supports both pipe-separated and legacy JSON-style reference alternatives when expanding matches.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

altwer-0.4.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

altwer-0.4.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file altwer-0.4.0.tar.gz.

File metadata

  • Download URL: altwer-0.4.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for altwer-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2f97d6a4e0edebaa6f07ca89ef072fd78e7958c5dd757411793ea5d1ce2c2246
MD5 19b8dd83f083876431ad382c89c2e08c
BLAKE2b-256 a64dbe5aa5755316b6a2a1b34a81c7140c9bbd15dd4ffa17ce5df45acd1796ef

See more details on using hashes here.

File details

Details for the file altwer-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: altwer-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for altwer-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b580432af40c3a6d0d3ca037982351ed27e76f062e3a8e2bcdbe68d297312750
MD5 12f18b53c18a2c9429bfa7025a151475
BLAKE2b-256 66bff37d11d1bb56ba6b5a30a4008963177a85c42e64f07f40dcf337c11c360f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page