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.

Metadata

Release files for bangla-punctuation 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 bangla-punctuation 0.1.0
File Size Uploaded Provenance
bangla_punctuation-0.1.0.tar.gz 7.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bangla-punctuation 0.1.0
File Interpreter ABI Platform
bangla_punctuation-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / bangla_punctuation-0.1.0.tar.gz

Download URL bangla_punctuation-0.1.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5a22c2a084437c07c5654493023d134722f6365fb1e58da130ced4970560acc8
BLAKE2b-256 checksum
How to use checksums
688562db511a683f08df07be4cee287f8befeeb2811beaa31bc5cf295aa212ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

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

Download URL bangla_punctuation-0.1.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d49ca8d181ff68da8c4f0e50d0e6bf5ea8428575a28f99c65f81af74e9bb7cad
BLAKE2b-256 checksum
How to use checksums
811ef65a6aed7030ffe1831b3c93048308efe6267ceb840f92c13a68bd14d1d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for bangla-punctuation 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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