Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 7 min read How-to mediumAdept

Powerful ASR + diarization + speculative decoding with Hugging Face Inference Endpoints

A custom inference handler on Hugging Face Inference Endpoints serves Whisper ASR, Pyannote speaker diarization and speculative decoding behind a single API endpoint. The handler is split into model settings, inference config and diarization utilities, with models chosen via Pydantic environment variables. Creating the endpoint through the API is needed to pass the HF token that diarization requires. A k6 benchmark on an A10 GPU shows distil-large-v3 as assistant model cutting latency on 8s audio from ~784ms to ~327ms but slowing 60s audio (3.48s to 4.15s). Speculative decoding requires batch size 1, so batching wins for long, chunked inputs.

Assumes: PythonHugging Face transformers pipelinesspeculative decoding basics

Related posts

  • Speculative Decoding for 2x Faster Whisper Inference

    Hugging Face mediumAdept

    Speculative decoding speeds up Whisper transcription by about 2x while producing mathematically identical outputs. A fast assistant model drafts candidate tokens and the main model verifies them in a single forward pass. With Distil-Whisper (full encoder, 2 decoder layers) as assistant to Whisper large-v2, a 73-sample LibriSpeech benchmark dropped from 73s to 33s at the same 3.5% WER, with only about 8% extra VRAM from sharing the encoder. For multilingual use, a multilingual checkpoint such as Whisper tiny can serve as assistant, since the only hard constraint is an identical tokenizer. Note that large-v3's expanded vocabulary makes it incompatible with older checkpoints.

  • Blazingly fast whisper transcriptions with Inference Endpoints

    Hugging Face easyNovice

    Hugging Face Inference Endpoints now offers a Whisper deployment built on vLLM that delivers up to roughly 8x higher real-time factor (RTFx) than the Transformers implementation, with comparable word error rate. It targets NVIDIA Ada Lovelace GPUs (L4, L40s) and gets its speedup from torch.compile JIT kernels, CUDA graphs that batch GPU kernel launches, and a float8 KV cache that halves cache memory versus bfloat16. Whisper Large V3, V3-Turbo and Distil-Whisper V3.5 were benchmarked for WER on 8 Open ASR Leaderboard datasets and for RTFx on 45+ minute rev16 audio using a single L4. Deployment is one click, and the endpoint is called through an OpenAI-style /audio/transcriptions HTTP API; a FastRTC demo shows real-time transcription.

  • Deploying Speech-to-Speech on Hugging Face

    Hugging Face mediumAdept

    Hugging Face's Speech-to-Speech pipeline (VAD, speech-to-text, LLM, text-to-speech) can be deployed to Inference Endpoints by forking the huggingface-inference-toolkit into a custom Docker image. Code and data ship as git submodules and requirements are installed at build time, which cuts endpoint startup time. The endpoint runs on an AWS L4 GPU at about $0.80/hour and is configured through either the GUI or the huggingface_hub API, with container port 80 and an HF_TOKEN secret for gated models. A small Starlette WebSocket webservice keeps latency low, and a Python client records audio, streams it to the server and plays back the queued responses.

  • Fine-Tune Whisper For Multilingual ASR with 🤗 Transformers

    Hugging Face mediumAdept

    Whisper, OpenAI's encoder-decoder ASR model pre-trained on 680,000 hours of labelled audio, can be fine-tuned for a low-resource language with Hugging Face Transformers using only about 8 hours of data. The walkthrough fine-tunes the multilingual small checkpoint (244M params) on Hindi from Common Voice 11. It covers loading and trimming the dataset, then preparing data with WhisperFeatureExtractor, which resamples to 16kHz, pads or truncates to 30s and converts audio to log-Mel spectrograms, plus WhisperTokenizer. It then moves through training and WER evaluation and ends with a Gradio demo. Along the way it explains why supervised pre-training needs less fine-tuning than Wav2Vec 2.0 and why Whisper needs no attention mask.

  • Achieve state-of-the-art inference latencies with speculative decoding

    Modal hardMaster

    Speculative decoding is the dominant lever for low-latency LLM serving because decode steps dominate latency and speculation yields multiplicative speedups roughly linear in acceptance length. Working with Decagon's voice agents, Modal combined regional serving, SGLang host-overhead fixes, and open-source kernels with DFlash draft models that reuse target-model KV projections and draft tokens in parallel. Fine-tuning ("mid-training") the speculator on synthetic data generated by the target model from public prompts in the task's output grammar avoids exposing user data. The custom speculator cut about 100ms from a ~290ms p50 baseline, roughly 40% of server-side decode latency, and beat proprietary providers by over 60ms. Out-of-distribution evaluation was used to guard against overfitting.

The quest for software engineering knowledge.

Look:
Layout: