pitput phonemizer

A Hebrew grapheme-to-phoneme model: plain text in, IPA with stress out. 10,083,873 parameters, about 40 MB. It reads a whole sentence at once, so the same letters can be two different words, and it can take the gender of the speaker and of the person being spoken to.

It is the pronunciation front end of pitput, a 5M-parameter Hebrew text-to-speech model. This release is the phonemizer on its own.

A name, a form of address or the story is enough to choose 诇讱, 讗讜转讱, 讗诪专转 and the rest.

Usage

pip install torch
from phonemizer import Phonemizer

g2p = Phonemizer.from_pretrained("useless-ai/pitput-phonemizer")

g2p("砖诇讜诐, 诪讛 砖诇讜诪讱?")
# 蕛al藞om, m藞a 蕛lom蠂藞a?

g2p("讚谞讛, 诪讛 砖诇讜诪讱?")                 # the name is the cue
# d藞ana, m藞a 蕛lom藞e蠂?

g2p("讚谞讛, 诪讛 砖诇讜诪讱?", listener="m")   # an explicit listener wins
# d藞ana, m藞a 蕛lom蠂藞a?

g2p("讗谞讬 讘讜讚拽转 讗转 讝讛", speaker="f")
# 蕯an藞i bod藞eket 蕯藞et z藞e

g2p("讛诪讞讬专 1250 砖拽诇讬诐")               # digits are read as words first
# hame蠂藞i蕘 蕯藞elef mat藞ajim ve蠂ami蕛藞im 蕛kal藞im

From the command line, reading UTF-8 from a file or from the argument:

python phonemizer.py --text "讚谞讛, 诪讛 砖诇讜诪讱?"
python phonemizer.py --text-file story.txt --listener f --speaker f
Argument Meaning
listener Who is being spoken to. Omitted: decide from the sentence. "f" or "m": use that form for 诇讱, 讗讜转讱, 砖诇讱, 讗诪专转, 专讗讬转 and the rest. "m" overrides a feminine name.
speaker Who is speaking. Omitted: unknown. "f" / "m": first-person forms such as 讘讜讚拽转 / 讘讜讚拽.
0 / 1 / 2 The same two arguments as integers: unknown, man, woman.

Niqqud is optional. A pointed letter is followed; an unpointed letter is still predicted from the sentence. Kamatz may be a or o, and shva may be e or silent, because the mark itself allows both. Stress is predicted either way: ordinary niqqud does not write it.

Text longer than 512 characters is split on sentence ends, then on commas, then on spaces.

Model

A character transformer.

  • One id per character (Hebrew letters, punctuation, digits, Latin letters and a few symbols), plus an optional vowel mark and consonant mark on that character, plus a speaker id and a listener id.
  • 8 transformer layers, 320 channels, 5 heads, pre-norm, GELU, feed-forward width 1,280.
  • Three heads on every character: 25 consonants, 6 vowels, stressed or not. Empty is one of the classes, so a letter can be silent (讗, 注, 讛) or vowelless.
  • Decoding picks the best legal consonant and vowel for each letter, and one stressed vowel in the word. A geresh rewrites 爪 讻 讙 as t蕛, 蠂, d蕭. A final 讞 before a pause is a蠂.

Limitations

  • 讘讬谉 and 讘讬转 are read with ej (b藞ejn, b藞ejt).
  • With both inputs unknown, "专讗讬转 讗转 讛住专讟 讛讞讚砖, 诪讬讻诇?" is read as masculine. Set listener or speaker when the sentence does not carry the cue on its own.
  • Foreign words written in Hebrew letters are pronounced as Hebrew. Acronyms are left as written.
  • The number reading is a fixed set of rules, up to thousands, dates, times and a few fractions.
  • This package returns a pronunciation. For audio, use pitput.

License

Apache License 2.0, for the code and the weights.

RenikudPlus is by notmax123, Apache-2.0. The decoding and the number expander shipped here (renikud_onnx.py) are taken from its wrapper; see NOTICE. The transformer and its weights are trained by us.

Files

File Contents
model.safetensors The 10.1M weights
config.json Width, layers, the character inventory, consonant and vowel names
phonemizer.py Phonemizer, including from_pretrained, and the command line
renikud_onnx.py Decoding and number expansion from RenikudPlus
NOTICE, LICENSE Attribution and the Apache license

Acknowledgements

RenikudPlus for the per-letter distributions, the decoder and the number expander, and the text: Hebrew Wikipedia, HeDC4, news archives, HeSum and ivrit.ai.

Downloads last month
78
Safetensors
Model size
10.1M params
Tensor type
F32
路
Inference Providers NEW
This model isn't deployed by any Inference Provider. 馃檵 Ask for provider support