Registry / ai-ml / whisper-normalizer

whisper-normalizer

JSON →
library0.1.12pypypi✓ verified 89d ago

Whisper Normalizer (version 0.1.12) is a Python package that implements the text standardization and normalization approach used in OpenAI's Whisper ASR model. It provides robust text normalization functionalities, crucial for evaluating Automatic Speech Recognition (ASR) systems by reducing unintentional penalties in metrics like WER and CER. The library extends beyond basic English normalization to include specialized normalizers for Indic languages, addressing challenges such as diacritic preservation. The project appears to have an active development and release cadence.

pip install whisper-normalizer
INSTALL
IMPORT
SIG · WHISPER-NORMALIZER
W
whisper-normalizer
ai-mlpythonv0.1.12
Install
2.4s avg
Import
167ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.1.12 · 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
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.174s · 22.8MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 2.4s · import 0.160s · 24MB
21MB installed
● package 21MB
Code
Verified usage

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

EnglishTextNormalizer
✓ from whisper_normalizer.english import EnglishTextNormalizer
BasicTextNormalizer
✓ from whisper_normalizer.basic import BasicTextNormalizer
MalayalamNormalizer
✓ from whisper_normalizer.indic_normalizer import MalayalamNormalizer
✗ from whisper_normalizer.basic import BasicTextNormalizer
BasicTextNormalizer can remove crucial diacritics and change meaning in Indic languages. Use language-specific normalizers like MalayalamNormalizer for correct results.

Demonstrates the use of EnglishTextNormalizer, BasicTextNormalizer, and a specific Indic normalizer (MalayalamNormalizer) to process and normalize text. This highlights the different normalization strategies available for various linguistic contexts.

from whisper_normalizer.english import EnglishTextNormalizer from whisper_normalizer.basic import BasicTextNormalizer from whisper_normalizer.indic_normalizer import MalayalamNormalizer # English Text Normalization english_normalizer = EnglishTextNormalizer() text_en = "I'm a little teapot, short & stout. Tip me over and pour me out! $20 million." normalized_en = english_normalizer(text_en) print(f"English (input): {text_en}") print(f"English (output): {normalized_en}\n") # Basic Text Normalization (general purpose, but use with caution for Indic languages) basic_normalizer = BasicTextNormalizer() text_basic = "Hello [music] world (coughs). café résumé naïve." normalized_basic = basic_normalizer(text_basic) print(f"Basic (input): {text_basic}") print(f"Basic (output): {normalized_basic}\n") # Malayalam Text Normalization (example for Indic languages) malayalam_normalizer = MalayalamNormalizer() text_ml = "എന്റെ കമ്പ്യൂട്ടറിനു് എന്റെ ഭാഷ." normalized_ml = malayalam_normalizer(text_ml) print(f"Malayalam (input): {text_ml}") print(f"Malayalam (output): {normalized_ml}")
whisper-normalizer --version
Debug
Known issues
gotchaUsing `BasicTextNormalizer` or `EnglishTextNormalizer` for Indic languages can lead to unintended loss of crucial diacritics and semantic changes. These normalizers are optimized for English and general text processing, not for the unique characteristics of Indic scripts.
fix
Always import and use the appropriate language-specific normalizer from `whisper_normalizer.indic_normalizer` (e.g., `MalayalamNormalizer`, `PunjabiNormalizer`) for Indic languages.
affects: All versions
gotchaBetween versions 0.1.0 and 0.1.4, the library significantly changed its number normalization backend for Indic languages by switching to the `AI4Bharat IndicNumtowords` package and removed network calls from `EnglishTextNormalizer`. This could alter previously expected normalization outputs, particularly for numbers, currencies, and certain English text patterns.
fix
Users upgrading from versions prior to 0.1.4 should carefully review normalization outputs in their applications, especially for number-heavy text, to ensure compatibility with the new implementations.
affects: Prior to 0.1.4
gotchaDo not confuse `whisper-normalizer` (this standalone library) with the internal `whisper.normalizers` submodule found within OpenAI's main `openai-whisper` package. This library is designed for standalone text normalization, while `openai-whisper`'s normalizers are integrated directly into its ASR model pipeline and have a different import path (e.g., `from whisper.normalizers import BasicTextNormalizer`).
fix
For standalone text normalization tasks, ensure you are importing from `whisper_normalizer`. If integrating with the full OpenAI Whisper ASR model, use its internal `whisper.normalizers`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'whisper_normalizer'
The 'whisper-normalizer' package is not installed in the current Python environment.
fix
pip install whisper-normalizer
ImportError: cannot import name 'BasicTextNormalizer' from 'whisper_normalizer'
The 'BasicTextNormalizer' class is located in the 'basic' submodule, not directly under the top-level 'whisper_normalizer' package.
fix
from whisper_normalizer.basic import BasicTextNormalizer
AttributeError: 'int' object has no attribute 'lower'
The `normalize` method expects a string input, but a non-string type (e.g., an integer or NoneType) was provided.
fix
Ensure the input passed to the `normalize()` method is always a string. For example: `normalizer.normalize(str(123))`
ValueError: 'xx' is not a supported language. Supported languages are: ['as', 'bn', 'gu', 'hi', 'kn', 'ml', 'mr', 'or', 'pa', 'ta', 'te']
An unsupported language code (e.g., 'xx') was provided when initializing `IndicTextNormalizer`.
fix
Use one of the supported language codes (e.g., 'hi', 'ta', 'bn') listed in the error message for `IndicTextNormalizer`.
Upgrade
Version history
0.1.12latest on PyPI · released Jun 6, 2025
Audit
Dependencies
indic-numtowordsrequiredUsed for number normalization in Indic languages, replacing a previous implementation.
indic-nlp-libraryrequiredProvides core normalization logic for Indic languages.
Agent activity
44 hits · last 30 days
node
40
OpenAI (training)
1
Resources
whisper-normalizer — pip install whisper-normalizer · libregistry