Skip to main content

bangla-punctuation

Python inference library for restoring punctuation in unpunctuated Bengali text and automatic speech recognition (ASR) transcripts.

The package provides two checkpoints:

Selection Hugging Face model Labels Status
base HasinManjare/bangla-punctuation-v2 8 Stable/default
extended HasinManjare/bangla-punctuation-extended-v3 10 Experimental

The extended model adds hyphen (-) and Bengali visarga (). Its rare-class scores remain uneven, so it is not necessarily better than v2 for every input.

Installation

pip install bangla-punctuation

For an NVIDIA GPU, install the PyTorch build appropriate for your CUDA setup as described at https://pytorch.org/get-started/locally/.

Python usage

from bangla_punctuation import BanglaPunctuator

punctuator = BanglaPunctuator(model="base", device="auto")
result = punctuator.restore("আজ আকাশ খুব সুন্দর তুমি কি বাইরে যাবে")
print(result)

Select the experimental model:

punctuator = BanglaPunctuator(model="extended")

Process multiple ASR results without reloading the model:

raw_transcripts = [
    "আজ আকাশ খুব সুন্দর",
    "তুমি কি বাইরে যাবে",
]
restored = punctuator.restore_batch(raw_transcripts)

Get metadata alongside the restored text:

details = punctuator.restore_with_details("আমি এখন ঢাকায় যাব তুমি যাবে")
print(details.text)
print(details.counts)
print(details.device)

A local model directory or another compatible Hub repository can also be used:

punctuator = BanglaPunctuator(model="./bangla-bert-punctuation-v2")

Command line

bangla-punctuate --model base "আজ আকাশ খুব সুন্দর তুমি কি বাইরে যাবে"

Or pipe ASR text through standard input:

printf '%s' 'আজ আকাশ খুব সুন্দর' | bangla-punctuate --model extended

Models and training data

Both models use the ELECTRA-based csebuetnlp/banglabert encoder. They are not derived from sagorsarker/bangla-bert-base.

The stable v2 model was fine-tuned for eight token-level classes using the project's original Bengali punctuation corpus. The published held-out result was approximately 0.570 punctuation macro F1 and 0.623 overall macro F1.

The extended v3 model starts from v2 and uses:

Independent macro-F1 results reported after extended training were 0.447 on Munem, 0.396 on BanglaPRCorpus, and 0.473 on the original test set. Refer to the individual Hugging Face model cards for per-class results and limitations.

ASR integration

Use punctuation restoration as a post-processing stage:

raw_text = asr.transcribe(audio)["text"]
final_text = punctuator.restore(raw_text)

For long-running services, create one BanglaPunctuator instance at startup and reuse it. Constructing it downloads/loads a checkpoint and is expensive.

Important limitations

  • The input parser currently keeps Bengali-block tokens and normalizes spacing; mixed English/Bengali text is not preserved exactly.
  • Punctuation is predicted after each input word. The model does not rewrite or spell-correct ASR text.
  • Rare punctuation such as exclamation, semicolon, ellipsis, and the extended labels is substantially less accurate than common labels.
  • Validate on transcripts from the intended ASR engine and acoustic domain.

Licensing

The Python wrapper code is MIT licensed. Model checkpoints and datasets retain their own terms. The upstream csebuetnlp/banglabert release does not currently state an explicit license, so the model repositories are marked license: other. Confirm upstream permission before commercial redistribution or use.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bangla_punctuation-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

bangla_punctuation-0.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file bangla_punctuation-0.1.0.tar.gz.

File metadata

  • Download URL: bangla_punctuation-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for bangla_punctuation-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5a22c2a084437c07c5654493023d134722f6365fb1e58da130ced4970560acc8
MD5 e9df3b88710628b63da72352cca9b27b
BLAKE2b-256 688562db511a683f08df07be4cee287f8befeeb2811beaa31bc5cf295aa212ff

See more details on using hashes here.

File details

Details for the file bangla_punctuation-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bangla_punctuation-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d49ca8d181ff68da8c4f0e50d0e6bf5ea8428575a28f99c65f81af74e9bb7cad
MD5 0b017f243407226d416af7537d926a63
BLAKE2b-256 811ef65a6aed7030ffe1831b3c93048308efe6267ceb840f92c13a68bd14d1d5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

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