Bulgarian Text Normalizer for TTS
A comprehensive text normalization package that converts written Bulgarian text into its spoken form, designed as a preprocessing step for Text-to-Speech (TTS) systems.
Features
| Category | Examples |
|---|---|
| Numbers | 1500 → хиляда и петстотин, 2026 → две хиляди двадесет и шест, 1.000.000 → един милион, up to trillions |
| Dates | 15.02.2026 г. → петнадесети февруари две хиляди двадесет и шеста година |
| Time | 14:30 ч. → четиринадесет и тридесет часа, 18.30 ч. likewise, 9:00 - 18:00 → девет до осемнадесет, 2:03:59 → два часа три минути и петдесет и девет секунди |
| Currency | 99.99 лв. → деветдесет и девет лева и деветдесет и девет стотинки, 12.50 € → дванадесет евро и петдесет евроцента |
| Scale words | 1,5 млн. → един и половина милиона, 5 хил. → пет хиляди |
| Units | 1 км → един километър, -5°C → минус пет градуса, 60 км/ч → шестдесет километра в час, 420 ppm → четиристотин и двадесет части на милион, 16 GB, 3.2 GHz, 5000 mAh, 220 V, 150 к.с., 1 ч.л., 800 евро/месец → осемстотин евро на месец |
| Versions and hex | v1.29.0 → версия едно точка двадесет и девет точка нула, Python 3.12 → Python три точка дванадесет, т. 3.2 → точка три точка две, 0x53 → нула екс пет три |
| Digits in names | GP4 → джи пи четири, ESP32 платка → и ес пи тридесет и две платка |
| Fractions | 3/4 → три четвърти, ½ чаша → половин чаша, 24/7 → двадесет и четири на седем, 1/4 финал → четвъртфинал |
| Ranges | 5-10 км → пет до десет километра, 2025/2026 г. → две хиляди двадесет и пета, двадесет и шеста година |
| Percentages | 15.5% → петнадесет цяло и пет десети процента, -15% → минус петнадесет процента |
| Math and ratios | 2 + 2 = 4 → две плюс две равно на четири, 3:1 → три на едно, 30x20 см → тридесет на двадесет сантиметра, ±5, ≈ 50, § 5 |
| Ordinals | 21-ви → двадесет и първи, 5-ия → петия, 90-те → деветдесетте, 3-ма → трима, 100-годишен → стогодишен, 35-метров → тридесет и пет метров, 19 в. → деветнадесети век |
| Abbreviations | бул. Витоша, гр. София → булевард Витоша, град София, ЕС реши → Европейският съюз реши, на ЕС → на европейския съюз (acronyms only in capitals, so spelled-out ю ес би is left alone), ДДС-то → Данъкът добавена стойност, мин. температура → минимална температура, пн.–пт. → от понеделник до петък |
| Acronyms | Unpronounceable ones are spelled: БСП → Бе се пе, НСИ → Не се и. Words stay: ГЕРБ, НАТО, САЩ |
| Identifiers | ЕГН 8001011234, IBANs and codes with a leading zero (0042) digit by digit, ivan@abv.bg → ivan кльомба а бе ве точка бе ге |
| Phone numbers | 0888 123 456 → нула осем осем осем едно две три четири пет шест |
| Roman numerals | век XXI → век двадесет и първи, ХХ в. (Cyrillic Х) → двадесети век, Цар Симеон II → Цар Симеон втори |
| Symbols | №10 → номер десет, No 15 → номер петнадесет |
Grammatical Correctness
- Gender agreement: Handles masculine/feminine/neuter (
един/една/едно,два/две), past a plural adjective (2 нови книги→две нови книги). A number with no noun after it, or after a label noun, takes the counting form:стая 2→стая две,ал. 2 от закона→алинея две от закона - Men and mixed groups: 2 to 6 before a plural naming people take the personal form:
2 граждани→двама граждани,5 заместници→петима заместници - Prepositions:
в 2-ри клас→във втори клас,с 7 души→със седем души - Ordinal forms: Full gender-aware ordinals (
първи/първа/първо) - Year reading: Ordinal feminine form matching "година" (
две хиляди двадесет и шеста) - Space-separated thousands:
7 000 000→седем милиона
Usage
Quick usage
from bg_text_normalizer import normalize_text
result = normalize_text("На 15.02.2026 г. в 14:30 ч. цената е 1500.50 лв.")
# "На петнадесети февруари две хиляди двадесет и шеста година в четиринадесет
# и тридесет часа цената е хиляда и петстотин лева и петдесет стотинки."
Class-based usage
from bg_text_normalizer import BulgarianTextNormalizer
normalizer = BulgarianTextNormalizer(expand_abbrevs=True, verbose=False)
result = normalizer.normalize("бул. Витоша №10, гр. София")
# "булевард Витоша номер десет, град София"
A Roman numeral made of I, V and X after a capitalized Cyrillic name is read
as an ordinal: Борис III управлява. → Борис трети управлява. A lone I,
V or X counts only after a known ruler's name or a title (Петър I,
цар Иван Асен II), so Модел X stays. Turn this off where names carry
product numbers:
BulgarianTextNormalizer(roman_numerals=False).normalize("Карл V")
# "Карл V"
Conventions
- A dot groups thousands only in groups of exactly three digits:
1.000.000, or1.500before a currency. Otherwise a dot or comma is a decimal point:1.5,3,14. - Latin acronyms are read with English letter names in Cyrillic (
USB→ю ес би,GP4→джи пи четири), acronyms said as a word get that word (RAM→рам), and a Roman numeral after a Latin name is a model number (Pentium II→Pentium две). Mixed-case names stay as written (iPhone,Python).spell_latin=Falsekeeps Latin letters for a TTS model that reads them. Digits in a name are read in the neuter label form. - Initials before a surname are read as letter names:
П. К. Яворов→Пе Ка Яворов. A capital letter after a label (вход Б.) is left alone. - An expanded acronym that opens a sentence is capitalized (
БСП→Бе се пе), so sentence splitting still sees the boundary. A lowercase Cyrillic word after a unit's period continues the sentence:5 лв. на човек→пет лева на човек. - The normalizer never deletes characters it doesn't know. The
|of aSPEAKER|textscript line passes through.
Individual modules
from bg_text_normalizer.bg_numbers import number_to_words_cardinal, number_to_words_ordinal
from bg_text_normalizer.bg_dates import normalize_date
from bg_text_normalizer.bg_currency import normalize_currency
number_to_words_cardinal(2500, gender='m') # "две хиляди и петстотин"
number_to_words_ordinal(15, gender='m') # "петнадесети"
normalize_date(15, 2, 2026) # "петнадесети февруари две хиляди двадесет и шеста"
normalize_currency("99.99", "BGN") # "деветдесет и девет лева и деветдесет и девет стотинки"
Integration with TTS Training (Qwen3-TTS)
Use this normalizer as a preprocessing step when preparing your training data:
import json
from bg_text_normalizer import normalize_text
# Process your JSONL training data
with open('raw_data.jsonl', 'r') as f_in, open('normalized_data.jsonl', 'w') as f_out:
for line in f_in:
entry = json.loads(line)
entry['text'] = normalize_text(entry['text'])
f_out.write(json.dumps(entry, ensure_ascii=False) + '\n')
For inference (runtime TTS), add normalization before synthesis:
from bg_text_normalizer import normalize_text
def synthesize(text: str):
normalized = normalize_text(text)
# ... pass normalized text to TTS model
File Structure
bg-text-normalizer/
├── src/
│ └── bg_text_normalizer/
│ ├── __init__.py # Package entry point
│ ├── bg_normalizer.py # Main orchestrator
│ ├── bg_numbers.py # Cardinal, ordinal, decimal numbers
│ ├── bg_dates.py # Date normalization
│ ├── bg_time.py # Time normalization
│ ├── bg_currency.py # Currency (BGN, EUR, USD, GBP)
│ ├── bg_scales.py # хил., млн., млрд.
│ ├── bg_units.py # Measurement units with count forms
│ ├── bg_punctuation.py # Keeps an abbreviation's period only at sentence end
│ ├── bg_abbreviations.py # 100+ Bulgarian abbreviations
│ ├── bg_phone.py # Phone number reading
│ └── bg_roman.py # Roman numeral conversion
├── test_normalizer.py # Test suite
├── pyproject.toml
└── README.md
Adding Custom Abbreviations
Edit src/bg_text_normalizer/bg_abbreviations.py and add entries to the appropriate dictionary:
# In ADDRESS_ABBREVS, TITLE_ABBREVS, etc.
CUSTOM_ABBREVS = {
'your_abbrev.': 'пълна форма',
}
Dependencies
None — pure Python, no external dependencies required.
Metadata
Release files for bg-text-normalizer 1.5.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 |
|---|---|---|---|---|
| bg_text_normalizer-1.5.0.tar.gz | 100.1 kB | With provenance | Details for bg_text_normalizer-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bg_text_normalizer-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for bg_text_normalizer-1.5.0-py3-none-any.whl |
Total release size: 202.6 kB
Release files / bg_text_normalizer-1.5.0.tar.gz
| Download URL | bg_text_normalizer-1.5.0.tar.gz |
|---|---|
| Size | 100.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e36eda2b20ddb9d506c597d4558625f2b27484987f92bd3914f77ecc3548c77a
|
|
BLAKE2b-256 checksum How to use checksums |
7b48addc1f8d4729841a6af1621df0aff89cf25db379e3f84316d2e61edb14ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / bg_text_normalizer-1.5.0-py3-none-any.whl
| Download URL | bg_text_normalizer-1.5.0-py3-none-any.whl |
|---|---|
| Size | 102.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
222998243bd12275733bb0e14ed401e6f8b596d5fa734e599c0ca247c9fbf54b
|
|
BLAKE2b-256 checksum How to use checksums |
3492fb3de3a16c77dcec843de5aaea2a98cf279d5bdb0c25268209119d7c670c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for bg-text-normalizer 1.5.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for bg_text_normalizer-1.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA 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.