bgmstress — ударения на български / Bulgarian stress marks

One neural model puts the stress on every Bulgarian word from the whole sentence. No dictionary: the model decides every word, including homographs that only the context separates (ча̀са / часа̀) and words it has never seen. It runs on an ordinary CPU with onnxruntime (about 2 ms per sentence with the small model on a laptop).

Един невронен модел слага ударението на всяка българска дума според цялото изречение, без речник.

Демо в браузъра / Try it in the browser: click a word to see the model's probability for each of its vowels.

Примери / Examples

Вход / Input Изход / Output
Утре сутринта ще пътуваме с влака за Пловдив, а вечерта ще се върнем обратно. У̀тре сутринта̀ ще пъту̀ваме с вла̀ка за Пло̀вдив, а вечерта̀ ще се въ̀рнем обра̀тно.
Министърът на финансите представи проектобюджета пред депутатите в Народното събрание. Минѝстърът на фина̀нсите предста̀ви проектобю̀джета пред депута̀тите в Наро̀дното събра̀ние.
Срещата е в 7 часа. Чакахме два часа. Срѐщата е в сѐдем часа̀. Ча̀кахме два ча̀са.
На 15 март 2027 г. от 10:30 часа в зала 204 ще бъдат наградени 1250 ученици. На петна̀йсти март две хѝляди два̀йсет и сѐдма годѝна от дѐсет и трѝйсет часа̀ в за̀ла двѐста и чѐтири ще бъ̀дат наградѐни хиля̀да двѐста и педесѐт ученѝци.
Б+орис и Бор+ис са различни хора. Бо̀рис и Борѝс са разлѝчни хо̀ра.

Install

pip install "bgmstress @ https://huggingface.co/monydochev/bgmstress/resolve/main/bgmstress-0.2.0-py3-none-any.whl"

The model file is downloaded from this repository on first use and cached.

Use

Command line:

bgmstress "Той ще говори утре."                 # Той ще гово̀ри у̀тре.
bgmstress "Той ще говори утре." --style plus    # Той ще гов+ори +утре.  (one-syllable words get no mark)
bgmstress "Чакахме два часа." --words           # one JSON line per word, with the vowel probabilities
echo "Текст от файл." | bgmstress --size large

Python:

from bgmstress import Stress

s = Stress()                                  # "small" (default), "base" or "large"
print(s.mark("Срещата е в 7 часа."))          # Срѐщата е в сѐдем часа̀.
print(s.mark("Срещата е в 7 часа.", style="acute"))   # stress accent U+0301 instead of U+0300
print(s.mark("Срещата е в 7 часа.", style="plus"))    # '+' before the stressed vowel

for w in s.analyze("Чакахме два часа."):
    print(w)
# {'word': 'Чакахме', 'stressed': 'Ча̀кахме', 'vowel': 0, 'source': 'model', 'probs': [1.0, 0.0, 0.0]}
# {'word': 'часа', 'stressed': 'ча̀са', 'vowel': 0, 'source': 'model', 'probs': [0.9999, 0.0001]}
  • Output text: numbers, dates, times, units and abbreviations are written out as words (the way they are read), then every word of two or more syllables gets a mark after its stressed vowel.
  • Your own marks win: put + before the stressed vowel (муз+ика) or a stress accent after it (му́зика).
  • analyze(): vowel = index of the stressed vowel (0 = first), source = model, yours (your mark) or fixed (a number / month / unit word that the normalizer wrote), probs = the model's probability for each vowel.
  • Offline: download the repository once and pass Stress(model_dir="path/to/folder").

Models

size file
small (default) stress_small.onnx, 18 MB fast, the one in the browser demo and in bgmtts
base stress_base.onnx, 100 MB
large stress_large.onnx, 240 MB the most accurate

On a held-out set of read Bulgarian sentences the model alone puts the stress on the right vowel for 99.2 % of the words (small) and 99.3 % (large).

Как работи / How it works

  1. Normalization. Numbers, dates, times, units and abbreviations are written out as words. The words it writes itself (петна̀йсти, хѝляди, киловатча̀са) have a fixed stress.
  2. The whole sentence goes in. The model reads the sentence at once and also reads every word letter by letter, so the neighbours decide between ча̀са and часа̀.
  3. A probability for every vowel. For each word of two or more syllables the model gives every vowel a probability; the most likely vowel gets the stress. analyze() and the demo show these probabilities.
  4. Your mark wins. A marked word is not changed.

Ограничения / Limitations

  • Rare names and words whose stress depends on something outside the sentence can be wrong; mark them with +.
  • Latin-script words are left without a stress mark.
  • One-syllable words get no mark.

Промени / Changes

  • 2026-11-30, 0.2.0: нормализацията от bgmtts 0.3.0: „и“ пред хиляди и милиони, „1 234,56“, телефонни номера по групи, „+“ вече не дава грешка (пред гласна е знак за ударение, иначе се чете „плюс“), = # @, „Д-р“. / The text normalization of bgmtts 0.3.0 (numbers, phone numbers, + never fails, symbols).
  • 2026-11-30, 0.1.1: думата „хиляда“ вече няма постоянно ударение, решава моделът.

License

MIT (see LICENSE).

Acknowledgements / Благодарности

The model was trained on BRAIN++, the Bulgarian AI Factory — a national and European AI Factory (EuroHPC) that brings together AI compute, expertise, training and support for companies and researchers.

Моделът е обучен на BRAIN++, българската AI фабрика — национална и европейска AI фабрика (EuroHPC), която събира на едно място изчислителна мощ за изкуствен интелект, експертиза, обучение и подкрепа за бизнеса и изследователите.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using monydochev/bgmstress 1