Skip to main content

An intelligent, rule-based phonetic transliterator from English to Bengali.

Project description

Phonetic-Bangla: Bengali Transliteration for Python

PyPI Version Python Versions License: MIT Build Status

Tired of switching keyboards? Need to generate Bengali text programmatically in your Python project? This is the tool for you.

phonetic-bangla is an intelligent, rule-based phonetic transliterator that converts English (Roman) script to Bengali (Bangla). It's designed for developers, data scientists, and anyone who finds it cumbersome to use a traditional Bengali keyboard but needs accurate Bengali text. Just type Bengali words as they sound in English, and this library will handle the rest.

🌟 Why Use Phonetic-Bangla?

  • ⌨️ No Bengali Keyboard Needed: Write Bengali using your standard English keyboard. Perfect for lazy typists and developers in a hurry.
  • 🧠 Intelligent & Context-Aware: It's not just a simple character map. It understands context to correctly handle complex Bengali phonetics, like Juktoborno (conjuncts) and ambiguous sounds.
  • 🐍 Simple Python Integration: A clean, memorable bn() function makes it incredibly easy to use in any Python script.
  • 💻 Powerful Command-Line Tool: Need a quick conversion? Use it directly from your terminal.
  • 🍃 Zero Dependencies: Pure Python, making it lightweight and easy to add to any project.

🚀 Quick Start

1. Installation

Install the package from PyPI with one simple command:

pip install phonetic-bangla

2. Usage in Python

Import the easy-to-use bn function and start converting. It's that simple.

from phoneticbn import bn

# --- Basic Conversation ---
english_text = "amar sOnar bangla, ami tomay bhalobasi."
bengali_text = bn(english_text)

print(bengali_text)
# Output: আমার সোনার বাংলা, আমি তোমায় ভালোবাসি।

# --- Handling Complex Words ---
# The library's real power is in handling tricky cases automatically.
print(bn("sawgotom"))   # -> স্বাগতম
print(bn("dhonyobad"))   # -> ধন্যবাদ
print(bn("kormo"))      # -> কর্ম

3. Usage from the Command Line

You can also use the tool directly from your terminal for quick conversions.

phonetic-bangla "sobar jonyo shubhechha"
# Output: সবার জন্য শুভেচ্ছা

📖 The Complete Phonetic Guide

Master Bengali typing with this comprehensive cheat sheet. The engine is designed to be intuitive, but for perfect accuracy, use these specific rules for complex sounds.

Vowels & Diacritics (Shoroborno & Kar)

Bengali English (Independent) English (Diacritic) Example (Phonetic -> Bengali)
o (implicit) k -> ক
আ/া a, A a, A baba -> বাবা
ই/ি i i din -> দিন
ঈ/ী I, ee I, ee nodi, nodee -> নদী
উ/ু u u putul -> পুতুল
ঊ/ূ U, oo U, oo dUr, door -> দূর
ঋ/ৃ rri RI kRIpoN -> কৃপণ
এ/ে e e desh -> দেশ
ঐ/ৈ OI, E OI, E bOI -> বই
ও/ো O O bhalo -> ভালো
ঔ/ৌ OU OU mOU -> মৌ

Consonants (Banjonborno)

Bengali English Example Bengali English Example
k kaka kh khobor
g gan gh ghum
Ng oNgko c cumu
ch chobi j jol
jh jhoR NG miNGa
T Taka Th Thik
D Dal Dh Dhaka
N horiN t tumi
th thala d dad
dh dhan n nodi
p pata ph phul
b baba bh bhai
m ma z/y zodi/byasto
r rat l lal
sh/S shyamola Sh bhaSha
s sokal h hat
R paR Rh aShaRh
y doya ` hoTa + ` -> হঠাৎ

Juktoborno (Conjuncts) & Folas

This is where phonetic-bangla shines. Type consonants one after another, and the library will automatically create the conjunct.

Desired Output Phonetic Input Example Usage Notes
হৃদয় (Special) hRidoy hRidoy -> হৃদয় The only way to get হৃ.
বিজ্ঞান bijNGan bijNGan -> বিজ্ঞান For জ্ঞ, use jNG.
লক্ষী lokShI lokShmi -> লক্ষী For ক্ষ, use kSh.
কর্ম kormo kormo -> কর্ম Use rf for explicit রেফ (র্).
ব্যস্ত byasto byasto -> ব্যস্ত y after a consonant is য-ফলা.
স্বাগতম swagotom swagotom -> স্বাগতম w after a consonant is ব-ফলা.
শান্ত shanto shanto -> শান্ত n + t -> ন্ত.
অঙ্ক oNgko oNgko -> অঙ্ক Ng + k -> ঙ্ক.

Modifiers

Name Bengali Phonetic Example Usage
Chandrabindu C, nN canNd, caCd -> চাঁদ
Anusvara ng rong -> রং
Bisorgo : or H du:kho, duHkho -> দুঃখ
Hosonto + shanto+ -> শান্ত্

🤝 Contributing

This project is built for the community, and contributions are highly welcome! If you find a word that doesn't transliterate correctly or have an idea for a new rule, please get involved.

  1. Open an Issue: The best way to start is by opening an issue on our GitHub Issues page. Describe the bug or feature request in detail.
    • For bugs: Please provide the input you used and the incorrect output it generated.
  2. Fork & Create a Pull Request: If you'd like to fix the issue yourself, please fork the repository and submit a pull request with your changes. Be sure to add a test case that validates your fix.

📜 License

This project is licensed under the MIT License. See the LICENSE file for full details.

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

phonetic_bangla-1.0.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phonetic_bangla-1.0.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file phonetic_bangla-1.0.0.tar.gz.

File metadata

  • Download URL: phonetic_bangla-1.0.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for phonetic_bangla-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b45ac640158ec5ec37964d0d4f9d44bfdc52dbd2409d05b0c96154f3b793b7ba
MD5 8e163f46ca4556113fe9878ba0954f35
BLAKE2b-256 b7309a7265e625e191535b0c0592d83ad92b3e509f6547cb528862d335e4e419

See more details on using hashes here.

File details

Details for the file phonetic_bangla-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for phonetic_bangla-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cbed2a2cd774127df736b40777151ab24a4da2b34a47ef0de659cca9eb1e341e
MD5 fbd474547920bdeacae29ef882644b7c
BLAKE2b-256 4d9518ad862634a01ae7481fecedaff76c60dca3b86127604734948384ec90f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page