165 lines
6.7 KiB
Bash
165 lines
6.7 KiB
Bash
# Sokhan configuration
|
|
# Copy this file to .env and adjust the values.
|
|
# For docker compose, copy it to deploy/.env instead.
|
|
# Every variable below has a working default for local development.
|
|
|
|
# --- Core ---
|
|
# PostgreSQL connection used by the API, the worker and Alembic.
|
|
DATABASE_URL=postgresql+psycopg://sokhan:sokhan@localhost:5432/sokhan
|
|
|
|
# Redis is used as the Celery broker and result backend.
|
|
REDIS_URL=redis://localhost:6379/0
|
|
|
|
# Set to "false" to run transcription inline (no Redis/worker required).
|
|
# Handy for development and tiny deployments; real deployments should use the worker.
|
|
CELERY_ENABLED=true
|
|
|
|
# Directory where uploaded audio files and generated exports are stored.
|
|
DATA_DIR=./data
|
|
|
|
# --- Whisper ---
|
|
# Model size: tiny / base / small / medium / large-v3
|
|
# Default "medium": measured 56.2% WER on the Persian fixture vs 75.0%
|
|
# for small (~1.1x realtime on 2 CPU cores, ~800 MB download).
|
|
# Set to "small" for the speed-first profile (~3x faster, less RAM).
|
|
WHISPER_MODEL_SIZE=medium
|
|
|
|
# cpu or cuda
|
|
WHISPER_DEVICE=cpu
|
|
|
|
# int8 is recommended on CPU, float16 on GPU.
|
|
WHISPER_COMPUTE_TYPE=int8
|
|
|
|
# Decoder beam width. 5 matches the benchmark and Gradio demo config.
|
|
WHISPER_BEAM_SIZE=5
|
|
|
|
# Initial prompt for the decoder. The default (empty here = code default)
|
|
# nudges the decoder towards standard written Persian orthography with
|
|
# ZWNJ; measured -1.3 WER points on small, -4.8 on the fine-tuned model.
|
|
# Replace with your own domain lexicon (project names, technical terms) to
|
|
# make those survive transcription (v1.4 roadmap).
|
|
WHISPER_INITIAL_PROMPT=
|
|
|
|
# Orthographic Persian polish (ZWNJ repair, split imperatives like
|
|
# "بی پوش" -> "بپوش", Arabic look-alikes, digits) applied to every finished
|
|
# transcript. Measured -3.6 WER points on the fixture; never rewords.
|
|
# Set to "false" for the raw model text.
|
|
FA_POLISH=true
|
|
|
|
# Rule-based Persian punctuation restoration applied to every finished
|
|
# transcript (question marks, commas, sentence periods, spacing). Set to
|
|
# "false" for the raw Whisper word stream.
|
|
PUNCTUATION_ENABLED=true
|
|
|
|
# Segments whose model confidence (exp(avg_logprob), 0..1) falls below this
|
|
# are flagged with a review marker in the SRT/VTT/DOCX exports and in the
|
|
# dashboard timeline. Set to 0 to disable flagging.
|
|
LOW_CONFIDENCE_THRESHOLD=0.5
|
|
|
|
# Decode audio block-by-block while transcribing: the worker holds one
|
|
# 30-second window in memory instead of the whole recording (measured on
|
|
# identical WAVs: a 30-minute file peaks at 86 MB streamed vs 356 MB fully
|
|
# decoded). Diarization engines other than "stub" need the whole signal and
|
|
# fall back to the full decode automatically. Set "false" to restore the
|
|
# pre-streaming behaviour.
|
|
STREAMING_DECODE=true
|
|
|
|
# --- Speaker diarization (optional) ---
|
|
# stub = no speaker labels (default, exactly the v1 behaviour)
|
|
# energy = dependency-free heuristic: voiced regions split into at most two
|
|
# acoustic clusters (numpy only; labels are similarity, not identity)
|
|
# pyannote= real neural diarization; needs `pip install "backend[diarize]"`,
|
|
# a Hugging Face token for the gated weights, and enough RAM for torch.
|
|
# If the selected engine cannot start, jobs still run — without speaker labels.
|
|
DIARIZATION_ENGINE=stub
|
|
PYANNOTE_HF_TOKEN=
|
|
PYANNOTE_MODEL=pyannote/speaker-diarization-3.1
|
|
|
|
# --- Quota & plans ---
|
|
# Free transcription minutes per user per month. Usage is tracked per user in the database.
|
|
FREE_MINUTES_PER_USER_PER_MONTH=30
|
|
# Per-file duration cap of the free plan, in minutes (longer files are
|
|
# rejected with HTTP 402 code=file_too_long).
|
|
PLAN_FREE_MAX_FILE_MINUTES=10
|
|
# The pro (subscription) plan: granted per user and per N days by the
|
|
# operator via POST /admin/users/{email}/plan. Limits apply only while the
|
|
# subscription is unexpired.
|
|
PLAN_PRO_MAX_FILE_MINUTES=180
|
|
PLAN_PRO_MONTHLY_MINUTES=1200
|
|
|
|
# Maximum accepted upload size in megabytes.
|
|
MAX_UPLOAD_MB=200
|
|
|
|
# --- Admin API ---
|
|
# Shared secret sent as the X-Admin-Key header for plan-grant endpoints
|
|
# (POST /admin/users/{email}/plan). Leave empty to disable the admin surface.
|
|
ADMIN_API_KEY=
|
|
|
|
# --- Dashboard session cookie ---
|
|
# The web dashboard signs in with an httpOnly cookie instead of keeping the
|
|
# API token in localStorage. It reaches the API through its own /api path,
|
|
# so the cookie is first-party on any host. AUTH_COOKIE_SECURE=auto marks it
|
|
# Secure whenever the browser uses HTTPS (directly or via a proxy setting
|
|
# X-Forwarded-Proto); true/false force it. SameSite=none (with HTTPS) is only
|
|
# needed when NEXT_PUBLIC_API_BASE points at an API on a different site.
|
|
AUTH_COOKIE_SECURE=auto
|
|
AUTH_COOKIE_SAMESITE=lax
|
|
AUTH_COOKIE_MAX_AGE_DAYS=30
|
|
|
|
# --- LLM summaries (optional) ---
|
|
# Any OpenAI-compatible chat-completions endpoint works.
|
|
# Set SUMMARY_ENABLED=true and provide a key to turn summaries on.
|
|
# Without a key the rest of the product keeps working; summaries are simply unavailable.
|
|
SUMMARY_ENABLED=false
|
|
LLM_API_BASE=
|
|
LLM_API_KEY=
|
|
LLM_MODEL=
|
|
|
|
# --- Telegram bot (optional) ---
|
|
TELEGRAM_BOT_TOKEN=
|
|
|
|
# Shared secret between the bot and the API; set the same value on both.
|
|
BOT_API_SECRET=
|
|
|
|
# URL the bot puts in messages so users can open their archive in the browser.
|
|
WEB_BASE_URL=http://localhost:3000
|
|
|
|
# Backend address the bot process talks to.
|
|
API_BASE_URL=http://localhost:8000
|
|
|
|
# --- Web ---
|
|
# Browser-facing API base URL, baked into the web build. Leave empty: the
|
|
# dashboard then calls /api on its own origin, which the web server proxies
|
|
# to API_PROXY_TARGET. Set it only when the API is served from its own host
|
|
# (that also needs SOKHAN_CORS_ORIGINS and AUTH_COOKIE_SAMESITE=none).
|
|
NEXT_PUBLIC_API_BASE=
|
|
API_PROXY_TARGET=http://api:8000
|
|
|
|
# --- Job-completion webhooks (optional) ---
|
|
# Jobs uploaded with a callback_url get a POST when they finish. The payload
|
|
# is JSON (event, job_id, status, text excerpt, transcript_url) and, when a
|
|
# secret is set, signed in `X-Sokhan-Signature: t=<unix>,v1=<hex>
|
|
# hmac-sha256(secret, "<ts>.<body>")` — receivers verify and drop anything
|
|
# older than five minutes. Leave empty to deliver callbacks unsigned.
|
|
WEBHOOK_SIGNING_SECRET=
|
|
|
|
# Webhook delivery tuning: seconds per delivery attempt and how many
|
|
# attempts are made before the callback is dropped (delivery is
|
|
# best-effort and never flips the job status).
|
|
WEBHOOK_TIMEOUT_SECONDS=4.0
|
|
WEBHOOK_ATTEMPTS=2
|
|
# Allow callbacks to private/loopback addresses (trusted installs only).
|
|
WEBHOOK_ALLOW_PRIVATE_TARGETS=false
|
|
|
|
# --- Login brute-force guard ---
|
|
LOGIN_MAX_FAILURES=10
|
|
LOGIN_FAILURE_WINDOW_SECONDS=900
|
|
|
|
# --- Deployment (deploy/docker-compose.yml) ---
|
|
# Required: the compose file refuses to start without a real password.
|
|
POSTGRES_PASSWORD=change-me-to-a-long-random-value
|
|
|
|
# Comma-separated public origins allowed to call the API (no wildcard).
|
|
# Example: SOKHAN_CORS_ORIGINS=https://sokhan.example.com
|
|
SOKHAN_CORS_ORIGINS=
|