Repository navigation
Releases
Sokhan v1.5.0
Security
POST /auth/telegramcould be used to take over any Telegram user's
account. It minted a fresh API token for whatevertelegram_idthe
caller sent, with no proof the caller was the bot. It now requires the
X-Bot-Secretheader to match the newBOT_API_SECRET(constant-time
compare; 403 on mismatch, 503 while unset). Breaking for deployments
with the bot: set the sameBOT_API_SECRETon the API and the bot; the
bot refuses to start without it.- Request bodies above
MAX_UPLOAD_MB(plus 1 MiB multipart allowance) are
now refused with 413 by a middleware, up front fromContent-Lengthor
mid-stream for chunked uploads. Before, the size check ran only after the
whole body had been spooled to disk and read into memory, so one
multi-gigabyte upload could exhaust the API container's disk or RAM. - Webhook
callback_urls can no longer target internal addresses. Any
user could point the worker at loopback, private, link-local (cloud
metadata) or LAN hosts. Literal private hosts are now rejected at upload
(422), every resolved address is checked again at connect time (defeating
DNS rebinding), redirects are not followed and proxy env vars are ignored.
Breaking for receivers on private addresses: set
WEBHOOK_ALLOW_PRIVATE_TARGETS=trueon trusted single-tenant installs. POST /auth/loginis throttled: afterLOGIN_MAX_FAILURES(10) failures
per client address and email withinLOGIN_FAILURE_WINDOW_SECONDS(900)
it answers 429 withRetry-After; a successful login clears the count.
Fixed
-
Compose: the Whisper model cache now lives on the
sokhan-datavolume
(HF_HOME=/data/huggingface). Previously it sat in the container's own
filesystem, so every recreate (down/up,--build, a new image)
re-downloaded the weights — and transcription failed outright where the
Hugging Face Hub is unreachable. -
Compose: the postgres healthcheck probes the configured
POSTGRES_USERand
POSTGRES_DBinstead of a hardcodedsokhan. -
Quickstart (both READMEs) and
.env.examplenow say to copy the env file to
deploy/.env; the missing-password error names that path too. Copying it to
the repo root leftPOSTGRES_PASSWORDunset for compose. -
An upload the API cannot store (unwritable
DATA_DIR, full disk,
read-only volume) now answers 503 with a short message onPOST /jobs
andPOST /v1/audio/transcriptions, instead of a 500 with a traceback in
the log. The realOSErroris logged server-side, a partially written
file is removed, and the API logs an error at startup whenDATA_DIR
is not writable. -
The punctuation post-pass no longer splits numbers written with a
thousands separator:1,000stayed1، 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. -
Job progress now moves while a chunk is being transcribed, not only
between 30-second chunks. A clip shorter than 30 s is a single chunk, so
its progress sat at 0% for the whole job and then jumped to 100%. The
Whisper engine reports how far into the chunk it is as each segment is
decoded; the worker saves that at most once a second. -
The archive page refreshes itself while any job is queued or processing;
its progress bars never moved before. A job with no progress reported yet
shows a moving bar and "Getting ready" instead of an empty, stuck-looking
bar at 0%, and the job page shows the percentage with the right sign in
English. -
The Telegram bot recovers when the API revokes the token it cached for a
chat (a newer sign-in or a logout of the same account). Every request
used to fail from then on; the bot now drops the token, re-registers
once and retries, and/startonly shows a connect code that works. -
Sign-in through the dashboard flows (register, login, connect code) now
also sets the token as anHttpOnly; SameSite=laxsession cookie
(Securewhenever the browser uses HTTPS), and the API accepts it in place of a bearer header. Every
cookie-authenticated write must send the session's CSRF token in
X-CSRF-Token(403 otherwise); the token is an HMAC of the session
token, so nothing extra is stored.GET /auth/sessionreturns the
signed-in account and its CSRF token, and logout clears the cookie.
Bearer auth (bot, API scripts, OpenAI-compatible clients) is unchanged
and needs no CSRF token. New settings:AUTH_COOKIE_SECURE
(auto/true/false),AUTH_COOKIE_SAMESITE,
AUTH_COOKIE_MAX_AGE_DAYS. CORS now allows credentials for the
configuredSOKHAN_CORS_ORIGINS(#33). -
The dashboard no longer keeps the API token in
localStorage, where an
XSS could read it (CodeQLjs/clear-text-storage-of-sensitive-data). It
relies on the httpOnly session cookie, sends the CSRF token on writes,
learns who is signed in fromGET /auth/session, and wipes the token
earlier versions left inlocalStorage. The dashboard reaches the API
through its own/apipath, proxied by the web server to
API_PROXY_TARGET, so the cookie is first-party on localhost, 127.0.0.1,
a LAN address or a domain alike;NEXT_PUBLIC_API_BASEnow defaults to
empty and is only for an API on its own host (#33).
Added
-
Persian accuracy stack (v2) — measured on the 12-clip Common Voice
fa fixture, every number reproducible:- New
sokhan.core.fa_polishmodule: orthographic-only Persian ASR
repair (ZWNJ prefix/suffix fusion, split-imperative repair like
"بی پوش" → "بپوش", Arabic look-alike code points, Latin→Persian
digits, punctuation spacing). Wired into the pipeline behind
FA_POLISH=trueand ported verbatim to the browser demo
(16-case parity test with the Python implementation). Measured
−3.6 WER points; never rewords colloquial speech. - New default
whisper_initial_prompt: a ZWNJ-correct Persian
orthography prompt. whisper copies prompt script style — measured
−1.3 WER points onsmall, −4.8 on the fine-tuned checkpoint. - Default engine is now
medium: 56.2% WER vs 75.0% forsmall
under the v2 harness — a −24.3-point jump at ~1.1x realtime on 2 CPU
cores (int8, ~800 MB download).WHISPER_MODEL_SIZE=smallremains
the documented speed-first profile. - Browser demo: default model switched base → small (fixture 90.2% →
75.0% under v2), output now passes through the same polish pass as
the server, and the honesty note was updated. benchmarks/tune_decode.py: the decode sweep harness the decisions
above came from (prompt variants × beam × VAD ×
condition_on_previous_text).training/export_web_onnx.py: merge-LoRA → ONNX → int8 → HF Hub
pipeline that produces a transformers.js-compatible repo of any
Sokhan fine-tune, so the browser demo can run the project's own
engine once the export runs on Colab.baseline.jsonregenerated under the v2 harness (small 0.75 /
fine-tuned 0.75 / medium 0.5625); the weekly benchmark workflow now
guardssmallandmedium; regression-gate test updated to the
committed baseline.
- New
-
Dashboard dark mode: a sun/moon toggle in the header, defaulting to the OS
preference until the user picks one (saved in localStorage, applied before
first paint so there is no flash). Implemented by remapping the Tailwind
palette underhtml.darkinglobals.css, so existing pages needed no
per-class changes. -
Brand refresh: a hero banner in both READMEs (
docs/assets/banner.png),
a redesigned 1280x640 social preview (docs/assets/social-preview.png—
upload it once in Settings → General → Social preview) and a 512px app
icon (docs/assets/icon-512.png) usable as the HF Space avatar. The
landing site og:image was regenerated in the same style. -
Browser demo speed & UX overhaul (space/): WebGPU fast path (fp32
encoder + q4 decoder) with automatic WASM/q8 fallback, per-window
transcription progress with an ETA and elapsed timer, a real cancel
button (terminates the worker; the model stays in browser cache), a
timestamped line-by-line transcript toggle, a copy button and stage
pills. The windowing (30 s window / 5 s overlap) now lives in the
worker with timestamp-midpoint trimming, enabling the progress stream
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. -
A show/hide toggle (eye icon) on the login page's password field.
-
CONTRIBUTING.fa.md: a Persian translation of the contribution guide,
with a language switcher in both files like the READMEs (#31). -
POST /auth/logoutrevokes the caller's token (204). An account has a
single active token, so it signs out every client holding it. -
The dashboard header shows the sign-in state: a Sign in button when
signed out, the account email and Sign out when signed in. Sign out
revokes the token on the server and works even when the API is
unreachable. The landing page's sign-in button is hidden and the login
page redirects to the upload page for a signed-in user.
Changed
-
Demo hang fix: audio was decoded inside an
AudioContextforced to
16 kHz; Chromium can hang forever on opus/webm (Telegram voice,
MediaRecorder) in that configuration — the demo sat at "در حال
آمادهسازی صدا" indefinitely. Decoding now happens at the context's
natural rate and is resampled offline to 16 kHz, with a 45 s decode
watchdog and clear format-error messages (e.g. OGG on Safari). The
worker's origin guard also now accepts the EMPTYevent.origin
Chromium 158+ posts for same-origin dedicated-worker messages — the
strict comparison silently rejected every command and left the demo
at "در حال پردازش" forever. -
*...
Sokhan v1.4.1
Security
- First CodeQL run surfaced five findings; all triaged with a written
policy (see SECURITY.md, "Code scanning policy"):- Fixed
py/polynomial-redos— the email validation regex
^[^@\s]+@[^@\s]+\.[^@\s]+$backtracked polynomially on long
dot-less inputs (a 200k-char request could burn minutes of CPU per
attempt). Replaced with an unambiguous pattern plus an RFC-5321
length cap (254); a pathological 200k-char address now matches in
~8 ms. All 10 auth tests pass unchanged. - Fixed
js/missing-origin-check— the demo worker now drops
postMessagecommands whose origin is not the page that created it
(defense in depth; cache-bust bumped to?v=3). - Dismissed with justification
py/weak-sensitive-data-hashing
(API tokens are high-entropy; SHA-256 token hashing is the standard
storage, passwords use scrypt),js/clear-text-storage-of-sensitive-data
(SPA localStorage trade-off; httpOnly-cookie migration is tracked as
roadmap work), andpy/path-injectionin the Gradio demo (the path
is produced by Gradio's upload pipeline, not raw client input).
- Fixed
Added
- Release automation: pushing a
v*tag extracts the matching
CHANGELOG section (scripts/extract_release_notes.py) and creates or
updates the GitHub Release — the changelog stays the single source of
truth; this release is the first cut by that pipeline - OpenSSF Scorecard workflow (weekly + per-push,
publish_results)
grading the supply-chain posture, with the public badge in both READMEs - SBOM + max-mode provenance attestations on every GHCR image push —
verifiable withdocker buildx imagetools inspect - Compose integration smoke test in CI: builds the API image, boots
the real postgres + redis + api stack, polls/healthz, asserts
/plansexposes both tiers and/docsrenders — deployment wiring is
now tested, not assumed - A PR title check enforcing Conventional Commits on pull requests
- "Data and privacy" sections in README.md and README.fa.md: self-hosted
audio stays on the operator's machine (verified:delete_jobunlinks
the stored file), the browser demo uploads nothing, zero telemetry CODE_OF_CONDUCT.md(Contributor Covenant 2.1, Persian-and-English
friendly) and aCODEOWNERSfile — the GitHub community profile now
lists every recommended community health file (85% → 100%)- A
CodeQLworkflow: weekly + per-push static security analysis of the
Python packages (security-extended queries) and the web dashboard WEBHOOK_TIMEOUT_SECONDSandWEBHOOK_ATTEMPTSdocumented in
.env.example(the Settings existed; the example file did not list
them)
Changed
- Branch protection on
main: the CI (python/web/compose) and
CodeQL (Analyze *) checks are required before a pull request merges;
force pushes and deletions are blocked, history stays linear - Every workflow got explicit
timeout-minutes, a concurrency group
where stale runs would only burn quota, and an explicit least-privilege
permissionsblock (the Scorecard Token-Permissions check drove it) - All GitHub Actions pinned to full commit SHAs (tag-retargeting surface
removed) and then bumped to the latest majors — CodeQL Action v4 ahead
of the December 2026 v3 deprecation, Node-24 actions throughout - The Pages deploy is self-healing: stale
github-pagesartifacts are
cleared before upload, the artifact is awaited until visible, and the
deploy retries once past a 20 s settle gap — the transient
"multiple artifacts / no artifacts found" failure class is gone docs/ROADMAP.mdwas two versions stale: v1.3 was still labelled
"current work" and the plans feature was absent. Sections are now
marked shipped with their versions, plans/quota are documented as a
shipped item, and a "next — current work" section ties the open good
first issues and the scaled fine-tune to real issue numbersdocs/architecture.md: the Quota section only described the v1.3
monthly allowance; it now documents the full plans system (free/pro
table, both HTTP 402 codes, expiry downgrade, stacked renewals, the
admin endpoint, and the deliberate no-payment-gateway design)- The landing page feature grid now includes the transparent-quota card
(free/pro limits and the honest 402 responses) — the headline feature
of v1.4.0 was missing from the public product face CITATION.cffso the project can be cited in academic work; version
and release date track this release- FastAPI app metadata: MIT license info is now rendered on
/docs - Backend and bot package versions are dynamic now — they track
__version__(single source of truth, 1.4.1 with this release)
instead of the stale hardcoded0.1.0— and both carry full PEP 621
metadata: authors, MIT license, keywords, classifiers and project URLs sokhan_bot.__version__tracks the release again (was stuck at 1.1.0)- The web
package.jsonmatches the release version and declares
description, license, repository and bugs URLs deploy/docker-compose.ymlpasses the plan/admin variables through to
the containers (PLAN_FREE_MAX_FILE_MINUTES,
PLAN_PRO_MAX_FILE_MINUTES,PLAN_PRO_MONTHLY_MINUTES,
ADMIN_API_KEY) — before this, plan caps were not tunable and the
admin surface answered 503 in every compose deployment- The issue-template chooser links to Discussions for questions and
ideas; the landing page footer does the same
v1.4.0 — free/pro plans with honest quotas, Persian landing page, coverage in CI
v1.4.0 — free/pro plans with honest quotas, a Persian landing page, coverage in CI
Added
- Plans and subscriptions (free vs pro): every account starts on the free plan — at most a 10-minute file and 30 minutes/month — while a time-boxed pro subscription raises both caps to 180-minute files and 1,200 minutes/month. Pro is granted by the operator, not a payment processor:
POST /admin/users/{email}/planwithX-Admin-Key, renewals stack on the remaining time. Both upload paths (POST /jobsafter the duration probe,POST /v1/audio/transcriptionsafter the inline decode) reject over-limit work with HTTP 402 and a machine-readabledetail.code—file_too_longorquota_exceeded— so every client can show a targeted upgrade message; rejected uploads are deleted so no storage leaks. Expired subscribers silently fall back to free limits. - Operator grant API:
POST /admin/users/{email}/planandGET /admin/users/{email}behind a constant-timeX-Admin-Keycheck; the whole admin surface answers 503 unlessADMIN_API_KEYis set, so it can never ship accidentally open. GET /plans— public plan catalogue (code, Persian/English titles, caps);GET /quotanow reportsplan,plan_expires_atandmax_file_minutes.- Telegram bot:
/upgrade(plan catalogue in Persian), a plan-aware/quota, a pre-flight duration guard that refuses over-cap voices before downloading them, and a distinctfile_too_longmessage. - Web dashboard understands the 402 codes: the upload screen shows the active plan, remaining minutes and the per-file cap; a long file produces the targeted "file longer than your plan allows" message (fa/en).
- Alembic migration
0004addsusers.plan(+plan_expires_at). - GitHub Pages landing page (site/, live at abolfazlrwm.github.io/sokhan): a Persian-first, RTL, dark one-pager with the measured numbers, the benchmark table, screenshots, the quickstart and the architecture chain — auto-deployed from
mainby the newpages.ymlworkflow. Ships a 1200×630og-image.pngwith native raqm shaping for the Persian text. - Coverage measurement in CI: the test job runs under
pytest-covwith branch coverage oversokhan+sokhan_bot(78.2% lines / 264 of 396 branches on the non-GPU suite at release time) and appends a per-file markdown table to the job summary viascripts/coverage_summary.py. - A
dependabot.ymlkeeping pip (backend, bot), npm (web), github-actions and docker dependencies on weekly grouped minor/patch PRs; majors onnext,typescript, the python/node base images andav(its<14pin protects faster-whisper) are ignored on purpose — majors land as deliberate, measured upgrades.
Fixed
- The README's "honest limits" and roadmap sections still described streaming decode and signed webhooks as open roadmap items after they had shipped in v1.3.0; they now state the shipped facts.
sokhan.__version__was still1.1.0although v1.2.0 and v1.3.0 had been tagged; it now tracks the release.
Also in this repo since v1.3.0
README.fa.md— the README is now bilingual (English | فارسی) so the Persian-speaking community reads it in its own language.- The social preview image and landing page branding are in sync with this release (v1.4.0 pill, absolute OG image URLs for Telegram/X unfurls).
Full changelog: https://github.com/Abolfazlrwm/sokhan/blob/main/CHANGELOG.md
v1.3.0 — streaming engine, signed webhooks, measured RAM
The product release: the demo a visitor can click, the numbers behind it, and the integrations a reviewer asks for — every claim carries its measurement.
Engine
- Streaming decode (roadmap v1.4): the worker streams PyAV blocks and chunks while transcribing instead of loading whole files. Measured whole-process peak RSS on identical mono 16 kHz WAVs: 86.4 MB for a 30-minute file vs 355.6 MB fully decoded (4.1x lower), 84.9 MB vs 169.6 MB at 10 minutes — streaming stays flat while the full decode grows linearly.
test_streaming.pyproves both paths emit identical chunks. - Persian punctuation restoration (roadmap v1.4): deterministic rule-based post-pass — Persian
؟on questions, sentence periods, Latin marks mapped to ،/؛/؟, spacing fixed, decimals and clock times preserved. The WER benchmark path is untouched, so measured numbers stay comparable; the browser demo ports the same rules. - Decoding knobs:
WHISPER_BEAM_SIZE(default 5, matching the benchmark) andWHISPER_INITIAL_PROMPTfor a domain lexicon.
Product surface
- Signed job-completion webhooks (roadmap v1.5):
POST /jobsaccepts acallback_url; the worker POSTsjob.completed/job.failedevents signed Stripe-style (X-Sokhan-Signature: t=<unix>,v1=<hex hmac-sha256(secret, "<ts>.<body>")>, 5-minute replay window). Best-effort delivery never flips the job status. - Confidence-aware review flags (roadmap v1.5): per-segment
exp(avg_logprob)confidence,⚠markers in SRT/VTT/DOCX belowLOW_CONFIDENCE_THRESHOLD, "needs review" badges in the dashboard. - Segments timeline in the API and dashboard, VTT + structured JSON exports (completing the OpenAI-compatible
response_formatset), copy-to-clipboard and delete actions in the UI. - Telegram bot keeps its promise: completion notifications push the transcript (or a failure notice) the moment a job finishes; stuck jobs are released after six hours.
- Prebuilt images on GHCR:
ghcr.io/abolfazlrwm/sokhan-apiandsokhan-webon every push tomainand version tags — self-hosting skips the build.
Operations & community
- CORS allowlist instead of a wildcard, required DB password, non-root containers.
- Weekly WER regression gate: the fixture runs every Monday against
benchmarks/results/baseline.jsonand fails CI if thesmallengine loses more than one WER point. - Auto-synced demo Space (pushes to
space/publish live), CONTRIBUTING.md, issue templates, pre-commit. - Demo: https://huggingface.co/spaces/Abol0pati/sokhan-fa-demo — Whisper runs in the visitor's browser, nothing uploaded.
Full details in CHANGELOG.md; remaining roadmap in docs/ROADMAP.md.
v1.2.0 — first GPU-scale fine-tune, measured
Sokhan v1.2.0 — first GPU-scale fine-tune, measured
The month-two roadmap item lands: a Persian Whisper fine-tune trained on a free Colab T4, benchmarked on the same public 12-clip Common Voice (fa) fixture as the baselines.
Measured (CPU int8, one session, 2026-11-18)
| Model | Params | WER | CER |
|---|---|---|---|
| tiny | 39 M | 92.7% | 44.3% |
| base | 74 M | 90.2% | 37.6% |
| small | 244 M | 80.5% | 26.7% |
| whisper-tiny-fa-sokhan (CPU run) | 39 M | 103.7% | 47.4% |
| whisper-small-fa-sokhan (this release) | 244 M | 79.3% | 24.9% |
First fine-tune to beat its own baseline: WER −1.2 points, CER −1.8 points, direction consistent with the in-training eval WER (85.1% → 81.6%). Model: Abol0pati/whisper-small-fa-sokhan — training: LoRA, 500 clips (≈45 min of speech), 3 epochs, ~7 minutes on the T4.
Highlights
- Fine-tuning notebook hardened for real sessions:
torchaoconflict fix, loudtraining deps OKverification, readable errors instead of cryptic converter failures, CPU-int8 fallback when a Colab VM ships incomplete CUDA 12 libs, Kaggle-safe save cell docs/free-gpu.mdnow explains the "Failed to assign a backend — restriction in your location" error (sanctioned-region IPs) with the VPN-reload and Kaggle-import paths- Benchmark table carries all five models measured back to back; earlier sessions archived under
benchmarks/results/so every published number stays reproducible
Next
Same notebook, MAX_SAMPLES = 0 (full 10-hour manifest, ~1.5–2 h on a free T4) — measured row will replace this one when it lands. Measured numbers only, never promised ones.
v1.1.0 — diarization, measured benchmark, fine-tune pipeline
Sokhan v1.1.0 — the month-two roadmap starts: speaker diarization, the first measured accuracy benchmark, a real product demo, and the Persian fine-tuning pipeline.
Highlights
- Speaker diarization behind
DIARIZATION_ENGINE:energy(zero dependencies, heuristic acoustic clustering) andpyannote(neural, gated weights + HF token, graceful fallback). Speaker labels render as[SPK_1]prefixes in SRT/DOCX exports. See ADR 0004. - Measured accuracy — the README no longer says "no benchmark published": 12 real Common Voice (fa) clips with human-verified references, shipped with the repo, measured on CPU int8:
smallWER 80.5% / CER 26.7% (base90.2%,tiny93.9%). Full per-clip results inbenchmarks/results/results.json— honest, reproducible, with methodology and caveats. - Real demo GIF recorded against the actual running stack: upload a Persian voice clip, live progress, real transcript, archive search (
docs/assets/demo.gif). - Persian Whisper fine-tuning pipeline (
training/): Common Voice manifest preparation, LoRA training with Persian-normalized WER eval, CTranslate2 conversion. No trained numbers exist yet — the first run needs a GPU.
Fixed
- Web fonts (Vazirmatn, Inter) are self-hosted now; builds never depend on a Google Fonts fetch again (this bit one CI run on main).
Full changelog: https://github.com/Abolfazlrwm/sokhan/blob/main/CHANGELOG.md
v1.0.0 — self-hostable release
The full product, self-hostable with one command.
- docker compose: api, worker, redis, postgres, web (CPU-only, no GPU needed)
- Telegram bot: send a voice message, get the transcript, summary button,
/quota and /track - Alembic initial migration and runtime DATABASE_URL override
- architecture notes and three ADRs
- README with quickstart, configuration table and an honest status section
62 tests green locally; ruff and mypy clean. Summaries need an
OpenAI-compatible endpoint (SUMMARY_ENABLED=true); everything else works
out of the box.
v0.2.0 — Beta: web dashboard
Sokhan now has a face: a Persian-first web dashboard.
- fa/en locales, RTL-first, Vazirmatn typography
- landing, login/registration, connect-code entry
- upload with drag-and-drop and in-browser recording
- archive with Persian-normalized search and status badges
- job detail with live progress and TXT/SRT/DOCX downloads
Backend additions from this cycle: job pipeline on Celery (or inline
threads), /quota, /search, connect-code auth, LLM summaries behind a flag.
The tag includes a package-lock regeneration so npm ci installs
cleanly. 57 tests green locally.
v0.1.0 — Alpha: transcription engine
First usable slice of Sokhan: the transcription engine and the API.
- 30-second chunking with a 1-second overlap for long recordings
- faster-whisper on CPU (int8), model loaded once per process
- boundary de-duplication and timestamp clamping in the merge step
- TXT, SRT and DOCX exports
- OpenAI-compatible POST /v1/audio/transcriptions
- monthly usage tracking with quota enforcement (HTTP 402)
- diarization interface with a stub (real model lands later)
Known limits: no web dashboard yet, no bot yet, summaries and real
diarization still behind interfaces. 26 tests green locally (fake engine,
no model download needed).