screencastgen

Inference Server

FastAPI-based GPU inference server for TTS, transcription, alignment, and lip-sync.

Source: screencastgen/inference_server.py Entry point: screencastgen-server


Overview

Runs on a GPU machine and exposes ML capabilities over HTTP. This enables a CPU/GPU split architecture where the CLI or web worker runs on a CPU-only machine and offloads ML work here.

The server loads a TTS backend eagerly at startup, exposes HTTP endpoints for runtime inference, and batches compatible /synthesize requests into a single GPU forward pass.


Endpoints

POST /synthesize

Text-to-speech synthesis.

Accepts either:

Compatible concurrent requests are coalesced by the background batcher when they share:

Response: audio bytes using the backend’s output_format

POST /transcribe

Audio-to-text transcription.

Field Type Description
audio file Audio file to transcribe
language form Language code, default en-US

Used by Celery pipeline workers to generate missing ref_text when a submitted highlight or lip-sync job actually consumes reference audio. Upload requests never call this endpoint.

Response: JSON object with text

POST /align

Word-level audio-text alignment.

Field Type Description
audio file Audio file
text form Transcript
language form Language code
provider form Alignment provider override (optional)

Response: JSON object with words: [{word, start, end}]

POST /lipsync

Submit a lip-sync video generation job.

Field Type Description
audio file Audio file
reference_video file Reference face video
provider form Provider name override
latentsync_preset form LatentSync preset

Response: JSON job handle, e.g. { "lipsync_id": "...", "status": "queued" }

GET /lipsync/{job_id}

Return lip-sync job status and elapsed generation time.

GET /lipsync/{job_id}/result

Download the finished MP4. Returns 409 if the job is not done.

POST /lipsync/{job_id}/cancel

Request cancellation. Queued jobs are marked cancelled immediately; running jobs discard their result after the active generation call exits.

DELETE /lipsync/{job_id}

Discard the server-side job record and output file.

GET /health

Server status and runtime capabilities.

Response shape:

{
  "status": "ok",
  "backend": "qwen",
  "output_format": "wav",
  "max_chunk_bytes": 1500,
  "device": "cuda",
  "aligner": "whisperx",
  "lipsync_provider": "auto",
  "capabilities": ["synthesize", "transcribe", "align", "lipsync"]
}

Runtime Behavior

TTS Batching

Async Lip-Sync Jobs

Transcription Model Reuse

WhisperX GPU Runtime Requirements

Example verification:

export CUDNN_LIB_DIR="$VIRTUAL_ENV/lib/python3.10/site-packages/nvidia/cudnn/lib"
export LD_LIBRARY_PATH="$CUDNN_LIB_DIR:$LD_LIBRARY_PATH"
python -c "import ctypes; ctypes.CDLL('libcudnn_ops_infer.so.8'); print('ok')"

Startup Options

In addition to the normal backend and provider arguments, the server exposes:

Arg Default Description
--max-batch 8 Maximum number of compatible /synthesize requests coalesced into one model call
--batch-window-ms 30 Milliseconds to wait for more compatible requests before dispatching a partial batch

Dependencies

Inference Server
├── FastAPI + uvicorn        (HTTP server)
├── python-multipart         (file uploads)
├── TTS Registry         (create backend)
├── Alignment Registry   (alignment providers)
├── Lipsync Registry     (lip-sync providers)
├── Pipeline Common      (indirect runtime contract via backend limits)
├── Inference Batcher    (request coalescing for /synthesize)
└── Transcription        (WhisperX transcription helper)

Usage

screencastgen-server --backend qwen --device cuda
screencastgen-server --backend qwen --device cuda --max-batch 8 --batch-window-ms 30
screencastgen-server --backend qwen --device cuda --host 0.0.0.0 --port 8100

See Also