Back to Projects

Speech-to-Text Platform

GPU Transcription with WhisperX and Speaker Diarization

Overview

Role: Side project, built end to end: the Next.js app and marketing site, the Express + BullMQ backend, the Python WhisperX GPU service, and the deployment: the web app on a Cloudflare Worker, the API, queue, databases and GPU service in Docker on a self-hosted GPU machine.

What it is. A transcription app for audio, video and links (YouTube and other sites through yt-dlp). WhisperX (large-v3 by default) runs on an NVIDIA GPU with word-level alignment and pyannote speaker diarization, so the transcript comes back split by speaker. On top of the transcript, an LLM layer writes summaries, action items and key points, and lets you chat with a recording.

Four services. A Next.js 14 web app, an Express + TypeORM API with a BullMQ job queue on Redis and Postgres, a FastAPI service that wraps the WhisperX CLI on CUDA, and a separate Next.js 16 marketing site. Only the web app runs in the cloud: a static export served by a Cloudflare Worker at stt.yusypenko.com, which proxies /api through a Workers VPC service and a Cloudflare Tunnel. The API and queue worker, Postgres, Redis, the GPU service and the LLM run as Docker containers on one self-hosted machine with an NVIDIA GPU — no cloud GPU bill and no managed backend.

Built for a GPU service that restarts. Every transcription is a BullMQ job. When the whisper service is unreachable — restarting, loading a model, or down with the server — the job moves to waiting_retry and is retried every 10 s, then every 10 min, until the service is back; any other error fails it at once. Long jobs never hold an HTTP request open: the API submits the file, gets a 202, and polls the whisper service's status endpoint, while the service runs WhisperX in a worker thread so status checks stay responsive.

Large files. Uploads over 80 MB are split into 50 MB chunks on both hops (browser → API, API → GPU service) and reassembled on the other side, up to 500 MB per file.

Architecture

Four services, one edge Worker and one GPU server: how an audio file becomes a speaker-labelled transcript, and how the system copes when the GPU is offline.

Deployment topology

Only the web app runs in the cloud, on a Cloudflare Worker. Everything else runs in Docker on one self-hosted server with an NVIDIA GPU — no cloud GPU bill, no managed backend.

Browseruser
User

Uploads a file (chunked above 80 MB) or pastes a link; polls job status every 3–5 s.

Google sign-inJWT
HTTPS
Cloudflareedge
Web app on a Worker

A static export of the Next.js app served from the edge at stt.yusypenko.com; /api/* is proxied through a Workers VPC service and a Cloudflare Tunnel to the backend.

Cloudflare WorkersWorkers VPCNext.js 14
/api · VPC + tunnel
Self-hosted GPU serverDocker + NVIDIA
API + queue worker

Auth, uploads, jobs, exports, AI tools. A BullMQ worker (concurrency 1) feeds the GPU.

ExpressTypeORMBullMQ
Whisper service

202 Accepted + job id, WhisperX CLI in a worker thread, in-memory job store, status endpoint.

FastAPIWhisperXCUDA 12yt-dlp
Postgres + Redis

Jobs, users, transcripts, chats, prompts, notifications; Redis backs the BullMQ queues.

PostgreSQLRedis
LLM

Self-hosted gemma4 on Ollama for summaries and chat, thinking switched off; OpenAI is the fallback.

Ollamagemma4

Life of a transcription

From the upload button to a speaker-labelled transcript — seven steps across three machines.

1

Upload or link

Web app → API

Files go up in one request, or in 50 MB chunks (init / chunk / complete) above 80 MB, up to 500 MB. MIME type and extension are checked against an allowlist; a link skips the upload.

Multerchunked uploadrate limit: 10 uploads / 15 min
2

Persist + enqueue

API

A Job row is written as pending (file path, model, language, diarization options) and a transcribe or transcribe-url job is added to the BullMQ transcription queue.

TypeORMPostgreSQLBullMQRedis
3

Worker picks it up

Queue worker

One job at a time (concurrency 1) so the GPU never runs two models at once. The job moves to processing.

BullMQ Worker
4

Hand-off to the GPU

API → Whisper service (Docker network)

The file is POSTed (re-chunked above 80 MB) or the URL is sent. The service answers 202 with a job id and starts WhisperX in a worker thread; for links it first downloads best audio with yt-dlp.

202 Acceptedasyncio.to_threadyt-dlp
5

Poll until done

API ↔ Whisper service

The worker polls GET /status/{id} every 5 s, capped at 1 hour (the CLI has its own 1-hour timeout). No connection stays open for the length of a transcription.

polling1 h cap
6

Save + clean up

API

The speaker-labelled text (and, for links, title and duration) is saved to Postgres; the source file and WhisperX output folder are deleted; the user gets an in-app notification and an optional email.

Resendnotifications
7

Read, export, ask

Web app

The detail page polls until completed, then shows the transcript with speaker renaming, exports (TXT / DOCX / PDF / JSON) and LLM summaries, action items, key points and chat.

export queueOllama (gemma4)OpenAI fallback

Job states and the retry policy

The GPU service can restart, reload a model or go down with the server. The queue tells “service unreachable” apart from “this file is broken” and treats them differently.

pendingprocessingcompleted
waiting_retry↺ back to processing

Service unreachable — connection refused, DNS failure or timeout. Custom backoff: every 10 s for the first 3 attempts, then every 10 min, up to 1,000 attempts. The job resumes as soon as the whisper service is back.

failedterminal

Anything else — a bad file, a WhisperX error. Thrown as BullMQ's UnrecoverableError, so it fails at once with the message saved for the user instead of looping.

Inside the GPU service

The FastAPI service wraps the WhisperX CLI. Model, language, alignment, diarization and compute type are per-job options.

  1. 1
    Audio in
    file or yt-dlp best audio → MP3
  2. 2
    VAD
    speech regions, silence skipped
  3. 3
    Transcribe
    faster-whisper, large-v3 default, batch 8, float16 on CUDA
  4. 4
    Align
    wav2vec2 word-level timestamps
  5. 5
    Diarize
    pyannote, min / max speaker hints
  6. 6
    Text out
    JSON segments → [SPEAKER_XX]: lines
Pinned on purpose: CUDA 12.2 + cuDNN 8 base image (pyannote VAD needs cuDNN 8) · torch < 2.6 · transformers < 4.52 · huggingface-hub < 1.0 · models cached in a Docker volume so a restart doesn't re-download them.
Cross-cutting concerns

Auth

JWT access (15 min) + refresh (7 days) tokens stored hashed and revocable, email verification and reset, Google ID-token sign-in, admin role, per-IP rate limits.

LLM tools

Summary, action items, key points, saved prompts and streamed chat over a transcript. OpenAI-compatible client: self-hosted gemma4 on Ollama first, OpenAI (gpt-4o-mini) as fallback.

Exports

A second BullMQ queue (concurrency 2, 3 attempts, exponential backoff) renders TXT, DOCX, PDF and JSON; files expire after 24 h.

Notifications

In-app notifications on completion or failure, plus an optional email through Resend per user setting.

Cleanup

Uploaded sources and WhisperX output folders are deleted after each job; finished BullMQ jobs are trimmed (keep 10 completed, 5 failed).

Key Features

  • Transcribe uploaded audio/video or a link (YouTube and other sites via yt-dlp, audio only, converted to MP3)
  • WhisperX on CUDA: model choice from tiny to large-v3, float16 compute, batched inference, VAD and automatic language detection
  • Word-level alignment (wav2vec2) and pyannote speaker diarization with min/max speaker hints — transcripts labelled by speaker, with speaker renaming
  • BullMQ job queue with two failure classes: long backoff while the whisper service is down (waiting_retry), immediate failure for bad input
  • Asynchronous GPU calls: 202 Accepted + status polling, WhisperX run in a worker thread so the service stays responsive
  • Chunked uploads (50 MB chunks above 80 MB) on both hops, up to 500 MB per file
  • LLM tools over a transcript: summary, action items, key points, custom saved prompts and streamed chat (self-hosted gemma4 on Ollama first, OpenAI fallback)
  • Exports to TXT, DOCX, PDF and JSON through a separate queue, expiring after 24 h
  • Accounts: email + password with verification and reset, Google sign-in, JWT access/refresh rotation, admin dashboard for users and jobs
  • In-app notifications plus optional email (Resend) when a transcription finishes or fails
  • Separate Next.js 16 + next-intl marketing site with JSON-LD (SoftwareApplication, FAQ, Breadcrumb), sitemap and programmatic feature / use-case pages (built, not deployed yet)

Tech Stack

AI / Speech

WhisperXfaster-whisperpyannotewav2vec2 alignmentPyTorchCUDAyt-dlpOllamagemma4OpenAI API

GPU Service

PythonFastAPIasyncioDocker (nvidia/cuda)

Backend

Node.jsExpressTypeScriptTypeORMPostgreSQLBullMQRedisJWTGoogle OAuthResend

Frontend

Next.js 14React 18Next.js 16next-intlTailwind CSS

Infra

Cloudflare WorkersWorkers VPCCloudflare TunnelDocker ComposeSelf-hosted GPU server

Challenges & Solutions

A GPU Server Instead of a GPU Cloud

Problem

Renting a cloud GPU around the clock for a side project costs more than it earns, and a managed backend next to it is another monthly bill.

Solution

Only the web app runs in the cloud, on a Cloudflare Worker. The API, queue, databases and GPU service run in Docker on one self-hosted server with an NVIDIA GPU. The trade-off is that the GPU service can restart, reload a model or go down with the server, so the queue treats "service unreachable" as a normal state: the job goes to waiting_retry, is retried every 10 s, then every 10 min, and picks up as soon as the service is back. Nothing is lost while the GPU is unavailable.

Retrying the Right Failures

Problem

A retry policy that retries everything loops forever on a corrupt file; one that retries nothing drops every job during a GPU restart.

Solution

Errors are split into two classes. Connection refused, DNS failure and timeouts are retried with a custom backoff (up to 1,000 attempts); every other error throws BullMQ's UnrecoverableError, so the job fails at once with its message saved for the user.

Hour-Long Jobs Without Hour-Long Requests

Problem

A long recording takes many minutes on the GPU; a synchronous HTTP call would hold a connection open for the whole run and hit timeouts long before it finished.

Solution

The GPU service accepts the file with 202 and a job id, then runs the WhisperX CLI in asyncio.to_thread so its status endpoint stays responsive. The API polls every 5 s with a 1-hour cap, and the web app polls the API — no connection is held open for the length of a transcription.

Large Files on Two Hops

Problem

Video files of hundreds of megabytes have to cross two hops — browser to the API through Cloudflare, API to the GPU service — and a single request that size fails on body limits (Cloudflare caps a request body at 100 MB) and timeouts.

Solution

Files above 80 MB are split into 50 MB chunks on both hops, with init / chunk / complete endpoints on each side and a per-chunk timeout, then reassembled before processing. Source files and WhisperX output folders are deleted once the transcript is saved.

Pinning a Fragile ML Stack

Problem

WhisperX sits on torch, transformers, pyannote and huggingface-hub, and newer releases of each break it in a different way.

Solution

Each is pinned below the breaking release (torch < 2.6 for weights-only loading, transformers < 4.52 whose security gate blocks the alignment models, huggingface-hub < 1.0 for pyannote's auth argument) on a CUDA 12.2 + cuDNN 8 base image, and models are cached in a Docker volume so restarts don't re-download them.

Key Achievements

4 Services
Next.js app, Express API, WhisperX GPU service, marketing site
large-v3 + Diarization
WhisperX with word alignment and pyannote speakers
Offline-Tolerant Queue
Jobs wait out GPU-service downtime instead of failing
500 MB Uploads
50 MB chunks on both hops