Downloads · 30 days
997
41% of all-time downloads
KiaBush/persian-text-to-ipa-byt5
persian-text-to-ipa-byt5 is a text generation model from KiaBush. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This is a fine-tuned Transformers-compatible sequence-to-sequence model for converting Persian (Farsi) text into phoneme sequences based on the International Phonetic Alphabet (IPA; in Persian: الفبای آوانگاری بینالم…
Downloads · 30 days
997
41% of all-time downloads
All-time downloads
2.4K
Public
Parameters
300M
1.2 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors1.2 GB · 100%
From the Hugging Face model README
This is a fine-tuned Transformers-compatible sequence-to-sequence model for converting
Persian (Farsi) text into phoneme sequences based on the International
Phonetic Alphabet (IPA; in Persian: الفبای آوانگاری بینالمللی). It uses a
ByT5 tokenizer and T5ForConditionalGeneration architecture.
Inference and metadata-processing code is available on GitHub: KiaBush/persian-text-to-ipa-byt5.
The model is intended as a Persian grapheme-to-phoneme component for speech processing and text-to-speech pipelines. Punctuation handling and text normalization may need to be adapted to the downstream system.
import torch
from transformers import ByT5Tokenizer, T5ForConditionalGeneration
model_id = "KiaBush/persian-text-to-ipa-byt5"
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# The explicit mapping keeps checkpoints saved with older tokenizer configs
# compatible with Transformers versions where extra_special_tokens is a map.
tokenizer = ByT5Tokenizer.from_pretrained(
model_id,
extra_special_tokens={},
)
model = T5ForConditionalGeneration.from_pretrained(model_id).to(device)
model.eval()
text = "گل رز واقعا زیباست."
inputs = tokenizer(text, return_tensors="pt").to(device)
with torch.inference_mode():
output_ids = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
# ɡole ɾoz vɒːɣeʔæn ziːbɒːst.
For long inputs, split text into chunks no longer than 256 input tokens and preserve punctuation outside the generated phoneme spans.
One of the main challenges in Persian pronunciation is that written text often does not uniquely determine pronunciation. Short vowels are generally omitted in Persian orthography, and many words are heteronyms: they have exactly the same written form but different pronunciations depending on their meaning and context.
For example, the Persian word «گل» can mean “flower,” pronounced /ɡol/, or “mud,” pronounced /ɡel/. Correct pronunciation therefore requires more than simple character-to-character transliteration; it requires contextual and semantic disambiguation.
This model was specifically designed to produce IPA representations while taking such contextual ambiguities into account.
| Persian input | IPA output |
|---|---|
| <div dir="rtl">گل رز واقعا زیباست.</div> | ɡole ɾoz vɒːɣeʔæn ziːbɒːst. |
| <div dir="rtl">ساعت نه و سی و دو دقیقه است.</div> | sɒːʔæt noh væ siː ʔo do dæɣiːɣe ʔæst. |
| <div dir="rtl">امروز به او، نه خواهم گفت.</div> | ʔemɾuːz be ʔuː, næ xɒːhæm ɡoft. |
| <div dir="rtl">مرسی آقای رونالدو، بابت تمام سالهایی که از حضور شما لذت بردیم؛ و سرانجام اشکهاش جاری خواهند شد.</div> | mersi: ʔɒːɣɒːje ɾonɒːldo, bɒːbæte tæmɒːme sɒːlhɒːjiː ke ʔæz hozuːɾe ʃomɒː lezzæt boɾdiːm; væ sæɾɒːndʒɒːm, ʔæʃkhɒːʃ: dʒɒːɾiː xɒːhænd ʃod. |
google/byt5-smallT5ForConditionalGeneration)ByT5Tokenizerfa)The fine-tuning dataset is not included in this repository and cannot be redistributed because it does not have official permission for public release. Detailed dataset provenance, preprocessing, and split definitions are not published. Users should take this into account when assessing suitability, bias, licensing, and expected generalization.
No official evaluation results or public benchmark metrics are included in this release.
The model artifacts in this repository are released under the Apache License 2.0. The fine-tuning dataset is not distributed under this license and is not included in the repository.