Skip to main content

Khmer Pronunciation (G2P)

A small Transformer (7.5M parameters) that converts Khmer words to their NCKL Khmer-script respelling, with - between syllables:

ក្របី → ក្រ-បី

Training data: phonsobon/khmer-G2P. Trained model: phonsobon/khmer-g2p (83.2% word accuracy, 4.2% character error rate on the test split).

Install

pip install khmer-g2p
khmer-g2p ក្របី កម្ពុជា          # ក្របី  ក្រ-បី / កម្ពុជា  កាំ-ពុ-ជា
from khmer_g2p import KhmerG2P
g2p = KhmerG2P()                 # downloads the model from the Hub on first use
g2p("ក្របី")                     # 'ក្រ-បី'
g2p(["សម្ដេច", "កម្ពុជា"])        # list in, list out

Train on Google Colab

Open In Colab

Choose Runtime → Change runtime type → GPU, then run the cells in order.

Train locally

pip install -r requirements.txt
python g2p/prepare_data.py               # writes g2p/data/{train,validation,test}.tsv
python g2p/train.py --epochs 100         # best model -> g2p/checkpoints/best.pt

Options: --batch 256, --lr 5e-4, --eval-every 5, --patience 4 (stop after this many validation checks without improvement).

Use the training checkpoint directly

python g2p/predict.py ក្របី កម្ពុជា
from predict import KhmerG2P   # run from inside g2p/
g2p = KhmerG2P()
g2p("ក្របី")                  # 'ក្រ-បី'
g2p(["សម្ដេច", "កម្ពុជា"])     # list in, list out

Release

pip install -e ".[dev]"
python scripts/push_to_hub.py            # g2p/model/best.pt -> safetensors -> phonsobon/khmer-g2p
python -m pytest tests                   # tests the model on the Hub
python scripts/evaluate.py               # word accuracy on the test split
python -m build && twine upload dist/*   # publish to PyPI (bump __version__ first)

Metadata

Release files for khmer-g2p 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for khmer-g2p 0.1.0
File Size Uploaded Provenance
khmer_g2p-0.1.0.tar.gz 15.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for khmer-g2p 0.1.0
File Interpreter ABI Platform
khmer_g2p-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / khmer_g2p-0.1.0.tar.gz

Download URL khmer_g2p-0.1.0.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b919defcb7d4b12bce485b44142da3e4dd7bbae9e9381884bc4aa7cf7694fe04
BLAKE2b-256 checksum
How to use checksums
ad00f351b7920280f14467d7ea1190b55cfabb7dc79ecec7191e56116894a50d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / khmer_g2p-0.1.0-py3-none-any.whl

Download URL khmer_g2p-0.1.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d8f3f4bf1544714167c67e3b5a69934773a55b0e345c4d55a76acfa64cdc6a5
BLAKE2b-256 checksum
How to use checksums
945928c3c9ba6170d608442d8cbc372f6ead7b2ddc753a3c5b753cf590591072
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Security for khmer-g2p 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page