Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1219089a3c
|
No files matched your search
+3
-9
@@ -52,6 +52,9 @@ The format follows [Keep a Changelog](https://keepachangelog.com/) and the proje
|
||||
and duration caps: 30 min on WebGPU, 10 min on WASM, 60 MB per file —
|
||||
no input can wedge the demo at an eternal "processing" state anymore.
|
||||
|
||||
- `CONTRIBUTING.fa.md`: a Persian translation of the contribution guide,
|
||||
with a language switcher in both files like the READMEs (#31).
|
||||
|
||||
### Changed
|
||||
|
||||
- **Demo hang fix**: audio was decoded inside an `AudioContext` forced to
|
||||
@@ -74,15 +77,6 @@ The format follows [Keep a Changelog](https://keepachangelog.com/) and the proje
|
||||
pyproject.toml files, web/package.json, the landing site copy, the demo
|
||||
Space metadata and the fine-tuned model card.
|
||||
|
||||
### Fixed
|
||||
|
||||
- The punctuation post-pass no longer splits numbers written with a
|
||||
thousands separator: `1,000` stayed `1، 000` (Persian comma plus a
|
||||
space). A comma between digits followed by exactly three digits is now
|
||||
kept as is; a comma in a list of numbers (`4090,4080`) still becomes `،`.
|
||||
The edge cases from #30 (slash dates, Latin digits in Persian sentences,
|
||||
abbreviations, ellipses, repeated marks) are pinned by tests.
|
||||
|
||||
## [1.4.1] - 2026-11-26
|
||||
|
||||
### Security
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# مشارکت در سخن
|
||||
|
||||
[English](CONTRIBUTING.md) | **فارسی**
|
||||
|
||||
ممنون که به سخن سر زدید. این مخزن یک کیت گفتار به متنِ فارسی است که
|
||||
میشود سلفهاستش کرد: یک بکاند FastAPI با موتور faster-whisper، یک ورکر
|
||||
Celery، یک داشبورد Next.js (فارسیمحور و راستبهچپ)، یک ربات تلگرام
|
||||
اختیاری، یک پایپلاین فاینتیونِ LoRA با نتایجِ اندازهگیریشده، و یک دموی
|
||||
عمومیِ مرورگری روی Hugging Face.
|
||||
|
||||
## راهاندازی محیط توسعه
|
||||
|
||||
برای بکاند و ربات Python 3.12 و برای داشبورد وب Node 22 لازم است:
|
||||
|
||||
pip install -e "backend[dev]" -e "bot[dev]"
|
||||
cd web && npm ci
|
||||
|
||||
وابستگیهای سنگین (torch / faster-whisper) فقط برای ابزارهای آموزش و
|
||||
بنچمارک لازماند:
|
||||
|
||||
pip install -r training/requirements.txt -r benchmarks/requirements.txt
|
||||
pip install -r space/gradio/requirements.txt # self-hostable Gradio demo
|
||||
|
||||
## تستها، لینت و نظم کامیتها
|
||||
|
||||
CI روی هر push و pull request همین دستورها را اجرا میکند:
|
||||
|
||||
ruff check backend bot training benchmarks space deploy
|
||||
mypy --config-file backend/pyproject.toml backend/sokhan
|
||||
pytest backend/tests bot/tests
|
||||
cd web && npm ci && npm run build
|
||||
|
||||
هوکهای pre-commit (ruff بهعلاوهٔ چند بررسی پایه) را برای هر کلون یک بار
|
||||
فعال کنید:
|
||||
|
||||
pip install pre-commit && pre-commit install
|
||||
|
||||
پیام کامیتها از Conventional Commits پیروی میکنند (`feat:`، `fix:`،
|
||||
`docs:`، ...) و نسخهگذاری پروژه بر اساس Semantic Versioning است؛ هر
|
||||
تغییری که کاربر میبیند یک خط در CHANGELOG.md میگیرد.
|
||||
|
||||
## دموی مرورگری و ورکفلوی sync-space
|
||||
|
||||
`space/` دموی استاتیکی است که Whisper در آن کاملاً سمتِ مرورگر اجرا
|
||||
میشود (transformers.js). ورکفلوی `Sync demo Space` با هر pushای که به
|
||||
`space/` دست بزند، آن را با سکرتِ `HF_TOKEN` در Actions مخزن روی
|
||||
hf.co/spaces/Abol0pati/sokhan-fa-demo منتشر میکند - برای همین دموی
|
||||
عمومی هیچوقت از `main` عقب نمیماند. `space/gradio/` یک اپ جدا و
|
||||
سلفهاستشدنی است که چکپوینتِ فاینتیونشده را با همان تنظیمات موتورِ
|
||||
محیط production سرو میکند؛ این اپ عمداً روی Space عمومی آپلود نمیشود
|
||||
(قیمتگذاری ۲۰۲۶ هاگینگفیس، Spaceهای میزبانیشدهٔ Gradio/Docker را پشت
|
||||
اشتراک PRO قفل کرده است).
|
||||
|
||||
## قاعدهٔ «اول اندازهگیری»
|
||||
|
||||
هر ادعایی دربارهٔ دقت (WER، CER، سرعت) که در README، کارت مدل یا
|
||||
changelog میآید باید از `benchmarks/benchmark_wer.py` (یا ارزیابیِ
|
||||
نوتبوک) آمده باشد و فیکسچر و سختافزارش ذکر شده باشد. هیچ عددِ ساختگی
|
||||
پذیرفته نیست.
|
||||
|
||||
## امنیت
|
||||
|
||||
گزارشهای امنیتی را بهصورت issue عمومی باز نکنید - برای افشای خصوصی
|
||||
SECURITY.md را ببینید.
|
||||
@@ -1,5 +1,7 @@
|
||||
# Contributing to Sokhan
|
||||
|
||||
**English** | [فارسی](CONTRIBUTING.fa.md)
|
||||
|
||||
Thanks for looking into Sokhan. This repo is a self-hostable Persian
|
||||
speech-to-text kit: a FastAPI backend with a faster-whisper engine, a
|
||||
Celery worker, a Next.js (Persian-first, RTL) dashboard, an optional
|
||||
|
||||
@@ -5,8 +5,7 @@ puts the transcript back into publishable shape with three conservative,
|
||||
deterministic rule families — no model call, no LLM dependency:
|
||||
|
||||
1. Script fix: the Latin comma, question mark and semicolon become their
|
||||
Persian counterparts (، ؟ ؛). A comma that groups digits ("1,000",
|
||||
"12,500,000") is a thousands separator, not punctuation, and is kept.
|
||||
Persian counterparts (، ؟ ؛).
|
||||
2. Spacing: no space *before* punctuation, exactly one space *after* clause
|
||||
and sentence punctuation. `.` and `:` are deliberately left alone so
|
||||
decimals ("3.5") and clock times ("12:30") survive.
|
||||
@@ -27,12 +26,6 @@ import re
|
||||
# Latin forms that should not survive in a Persian transcript.
|
||||
_LATIN_TO_PERSIAN = str.maketrans({",": "،", "?": "؟", ";": "؛"})
|
||||
|
||||
# A comma between a digit and exactly three more digits groups a number.
|
||||
# \d matches Persian digits too, so "۱,۲۰۰" is covered.
|
||||
_THOUSANDS_COMMA = re.compile(r"(?<=\d),(?=\d{3}(?!\d))")
|
||||
# Stands in for a thousands comma while the Latin marks are translated.
|
||||
_KEPT_COMMA = "\x00"
|
||||
|
||||
_CLAUSE = "،؛"
|
||||
_SENTENCE_END = "؟!…."
|
||||
_PUNCT_CHARS = _CLAUSE + _SENTENCE_END + ":."
|
||||
@@ -80,8 +73,7 @@ def _has_terminal(text: str) -> bool:
|
||||
|
||||
def restore_punctuation(text: str) -> str:
|
||||
"""Return `text` with Persian punctuation restored; safe to re-apply."""
|
||||
cleaned = _THOUSANDS_COMMA.sub(_KEPT_COMMA, text)
|
||||
cleaned = cleaned.translate(_LATIN_TO_PERSIAN).replace(_KEPT_COMMA, ",").strip()
|
||||
cleaned = text.translate(_LATIN_TO_PERSIAN).strip()
|
||||
cleaned = _SPACE_BEFORE.sub(r"\1", cleaned)
|
||||
cleaned = _SPACE_AFTER.sub(r"\1 ", cleaned)
|
||||
cleaned = _WS_RUNS.sub(" ", cleaned).strip()
|
||||
|
||||
@@ -51,60 +51,3 @@ def test_empty_and_whitespace_input_stay_empty():
|
||||
def test_statement_with_colon_gets_no_double_mark():
|
||||
assert restore_punctuation("این است") == "این است."
|
||||
assert restore_punctuation("این است:") == "این است:"
|
||||
|
||||
|
||||
# Edge cases from #30. Each test pins the behavior on real-world input; the
|
||||
# comments say why that behavior is the right one for a transcript.
|
||||
|
||||
|
||||
def test_slash_dates_are_left_intact():
|
||||
# `/` is not punctuation to this pass, so date groups never get spaced
|
||||
# or split, in Persian and in Latin digits alike.
|
||||
assert restore_punctuation("تاریخ ۱۴۰۴/۰۹/۰۲ است") == "تاریخ ۱۴۰۴/۰۹/۰۲ است."
|
||||
assert restore_punctuation("جلسه 2026/11/23 برگزار شد") == "جلسه 2026/11/23 برگزار شد."
|
||||
assert restore_punctuation("نسبت ۱/۲ است") == "نسبت ۱/۲ است."
|
||||
|
||||
|
||||
def test_latin_digits_and_words_inside_persian_sentences():
|
||||
assert restore_punctuation("۳ دستگاه RTX 4090 خریدیم") == "۳ دستگاه RTX 4090 خریدیم."
|
||||
assert restore_punctuation("قیمت ۳.۵ میلیون شد") == "قیمت ۳.۵ میلیون شد."
|
||||
assert restore_punctuation("نسخه 1.4.1 منتشر شد") == "نسخه 1.4.1 منتشر شد."
|
||||
assert restore_punctuation("ساعت ۱۲:۳۰ بیا") == "ساعت ۱۲:۳۰ بیا."
|
||||
|
||||
|
||||
def test_thousands_separators_are_not_turned_into_persian_commas():
|
||||
# A Latin comma followed by exactly three digits groups a number; turning
|
||||
# it into ، and spacing it ("1، 000") would split one number into two.
|
||||
assert restore_punctuation("قیمت 1,000 دلار شد") == "قیمت 1,000 دلار شد."
|
||||
assert restore_punctuation("جمعیت 12,500,000 نفر") == "جمعیت 12,500,000 نفر."
|
||||
assert restore_punctuation("مبلغ ۱,۲۰۰ تومان") == "مبلغ ۱,۲۰۰ تومان."
|
||||
|
||||
|
||||
def test_comma_between_numbers_that_is_not_grouping_stays_a_list_separator():
|
||||
assert restore_punctuation("RTX 4090,4080 و 3090") == "RTX 4090، 4080 و 3090."
|
||||
assert restore_punctuation("اعداد 1,2 و 3") == "اعداد 1، 2 و 3."
|
||||
|
||||
|
||||
def test_abbreviation_dots_are_kept_and_end_the_segment():
|
||||
# A trailing dot already counts as terminal punctuation, so nothing is
|
||||
# appended; a dot in the middle is left alone like a decimal point.
|
||||
assert restore_punctuation("Dr.") == "Dr."
|
||||
assert restore_punctuation("با Dr. Smith صحبت کردم") == "با Dr. Smith صحبت کردم."
|
||||
assert restore_punctuation("با دکتر. احمدی") == "با دکتر. احمدی."
|
||||
|
||||
|
||||
def test_ellipsis_forms_are_terminal_and_tightened():
|
||||
assert restore_punctuation("صبر کن…") == "صبر کن…"
|
||||
assert restore_punctuation("نمیدونم...") == "نمیدونم..."
|
||||
assert restore_punctuation("صبر کن ... بعد") == "صبر کن... بعد."
|
||||
# A trailing-off question keeps its ellipsis instead of gaining a ؟.
|
||||
assert restore_punctuation("کی میای...") == "کی میای..."
|
||||
|
||||
|
||||
def test_repeated_and_mixed_marks_are_preserved():
|
||||
# Repetition carries the speaker's emphasis; the pass only converts the
|
||||
# script of Latin marks and never collapses them.
|
||||
assert restore_punctuation("وای!!!") == "وای!!!"
|
||||
assert restore_punctuation("چرا!!!") == "چرا!!!"
|
||||
assert restore_punctuation("چی؟؟") == "چی؟؟"
|
||||
assert restore_punctuation("واقعا?!") == "واقعا؟!"
|
||||
Reference in new issue
Block a user