A linguistically accurate Grapheme-to-Phoneme (G2P) converter and Syllabifier for Central Kurdish (Sorani). Optimized for TTS.
Project description
Central Kurdish G2P (Graph2Phon)
A modern, high-performance, and linguistically accurate Grapheme-to-Phoneme (G2P) converter and Syllabifier for Central Kurdish (Sorani).
Designed specifically for training modern Text-to-Speech (TTS) models (VITS, FastSpeech2, Glow-TTS) by providing robust phonetization, stress marking, and syllable boundaries.
(کوردی) دەربارەی پڕۆژە
ئەم پڕۆژەیە ئامرازێکی پێشکەوتووە بۆ گۆڕینی دەقی کوردی (سۆرانی) بۆ فۆنێم و بڕگە. بەتایبەت دیزاین کراوە بۆ سیستەمەکانی دروستکردنی دەنگ و ڕاهێنانی مۆدێلەکانی زیرەکی دەستکرد.
خێراییەکی زۆر بەرزی هەیە و هەموو یاسا دەنگییەکانی زمانی کوردی (وەک پاڵاتەڵایزەیشن، بزرۆکە، و فۆکەس) لەخۆدەگرێت.
🔗 Live Demos
- G2P Playground: ckb-g2p.streamlit.app
- Text Normalizer: ckb-textify.streamlit.app
🌟 Why Graph2Phon?
Generic G2P tools often fail on Kurdish phonology. ckb-g2p (v3) combines architectural speed with linguistic depth to solve these challenges:
| Feature | Problem in Generic Tools | Solution in ckb-g2p |
|---|---|---|
| Palatalization | Treats all 'k' and 'g' the same. | Distinguishes Heavy (Postalveolar t͡ʃ, d͡ʒ) vs Light (Dental t̪͡ʃ̟, d̪͡ʒ̟) based on vowel context (e.g. kwê → chwê). |
| Schwa Insertion | Fails on clusters like "grft". | Automatically inserts Bizroka (/ɪ/) to fix illegal consonant clusters (gɪ.ɾɪft) using Sonority Sequencing Principles. |
| Stress (Prosody) | Ignores stress. | Smartly assigns stress (ˈ). Handles Negative Verb shifts (nachu → ˈna.t̪͡ʃ̟uː) vs Nouns (kurd → kuɾd). |
| Ambiguity | Confuses w (u/w) and y (i/y). |
Uses a generator-evaluator pipeline to pick the most phonotactically valid pronunciation. |
| Dialect Support | Normalizes all sounds. | Preserves emphatic consonants (sˤ, tˤ, zˤ) critical for authentic pronunciation. |
🚀 Installation
From PyPI
pip install ckb-g2p
From Source
git clone [https://github.com/RazwanSiktany/ckb_g2p.git](https://github.com/RazwanSiktany/ckb_g2p.git)
cd ckb_g2p
pip install -e .
💻 Usage
Command Line Interface (CLI)
You can use the tool directly from your terminal:
# Basic usage (Syllabified)
ckb-g2p "سڵاو کوردستان"
# Output: sɪ.ˈɫäw kuɾ.dɪs.ˈtän
# Raw IPA (No stress, no syllable markers)
ckb-g2p "سڵاو" --format ipa --no-stress
# Output: sɪɫäw
# Batch Processing (Great for datasets)
ckb-g2p -i input.txt -o output.txt
Python API
from ckb_g2p.converter import Converter
# Initialize (loads cache by default)
converter = Converter()
# 1. Basic Syllabification
text = "من کوردم"
ipa = converter.convert(text, output_format="syllables")
print(ipa)
# Output: ['mɪn', 'kuɾ.ˈdɪm']
# 2. TTS-Ready Output (with Pauses)
# Note: Punctuation is automatically converted to pauses (| and ||)
text = "سڵاو، ناوت چییە؟"
ipa_list = converter.convert(text, output_format="syllables")
print(" ".join(ipa_list))
# Output: sɪ.ˈɫäw | näwt ˈt͡ʃiː.ja ||
🗣️ Phoneme Inventory
We use a precise IPA set to capture allophonic variations critical for natural speech synthesis.
Consonants (Key Distinctions)
| Grapheme | IPA | Type | Description |
|---|---|---|---|
| چ | t̪͡ʃ̟ |
Light (Dental) | Standard "ch". Tongue tip touches teeth. |
| ک | t͡ʃ |
Heavy (Postalveolar) | Palatalized /k/ before front vowels (i, e, y). Like English "Chair". |
| ج | d̪͡ʒ̟ |
Light (Dental) | Standard "j". Tongue tip touches teeth. |
| گ | d͡ʒ |
Heavy (Postalveolar) | Palatalized /g/ before front vowels. Like English "Jack". |
| ڵ | ɫ |
Velarized | "Dark L", distinct from clear l. |
| ڕ | r |
Trill | Rolled R, distinct from tap ɾ. |
| ص | sˤ |
Emphatic | Emphatic 'S' (Sad), preserved for dialectal accuracy. |
⚡ Performance & Caching
Graph2Phon uses a local SQLite database (lexicon.db) to store processed words.
- First Run: Calculates phonemes (~1-5ms per word).
- Second Run: Fetches from cache (<0.1ms per word).
To disable caching:
converter = Converter(use_cache=False)
🛠️ Configuration & Exceptions
The engine is driven by a YAML configuration file located at src/ckb_g2p/data/phonology.yaml.
Manual Overrides:
If the rule-based engine fails on a specific word (e.g., a foreign name), add it to src/ckb_g2p/resources/exceptions.csv
🤝 Contributing
Contributions are welcome! Please run the test suite before submitting a PR:
pip install pytest
pytest
📜 License
MIT License. See LICENSE for details.
👨💻 Author
Developed by Razwan M. Haji.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ckb_g2p-3.0.0.tar.gz.
File metadata
- Download URL: ckb_g2p-3.0.0.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d25ceb1dcb0123b66a42862d54bb374cb77088075f15728a6647cbe3fedbd339
|
|
| MD5 |
7eb3b60c8498715e93fccbacf406877a
|
|
| BLAKE2b-256 |
e27a9fb93739bf6095dbede2b53ae8552295c477821ccc6ea67bd62d6d906a07
|
File details
Details for the file ckb_g2p-3.0.0-py3-none-any.whl.
File metadata
- Download URL: ckb_g2p-3.0.0-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaf8165c7185e8ddd01846e051b790cc802e13df4b10124970370aec530c39c7
|
|
| MD5 |
a10ac79275773891e9ff8e8a15788d09
|
|
| BLAKE2b-256 |
36e2a19c3cc5fc9bff7fd6be74fffd713c22aba5ac09bcefcd64179937eb3325
|