---
title: "Powerful ASR + diarization + speculative decoding with Hugging Face Inference Endpoints"
description: "A custom inference handler on Hugging Face Inference Endpoints serves Whisper ASR, Pyannote speaker diarization and speculative decoding behind a single API endpoint."
url: "https://swe.quest/articles/powerful-asr-diarization-speculative-decoding-with-hugging-face-inference-ed388c1f3bfe4f4b"
canonical: "https://huggingface.co/blog/asr-diarization"
source: "Hugging Face"
published: "2024-05-01"
difficulty: "medium"
kind: "How-to"
reading_minutes: 7
tags: ["speech-audio","inference","python"]
---

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

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-05-01, 7 min read, How-to. Original: [https://huggingface.co/blog/asr-diarization](https://huggingface.co/blog/asr-diarization)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Speech & audio](https://swe.quest/tags/speech-audio.md) (AI & ML)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Python ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- Hugging Face transformers pipelines
- speculative decoding basics

## Keywords

Whisper, Pyannote, Hugging Face Inference Endpoints, speculative decoding, distil-whisper, Insanely Fast Whisper, k6

## Related posts

- [Speculative Decoding for 2x Faster Whisper Inference](https://swe.quest/articles/speculative-decoding-for-2x-faster-whisper-inference-c8681e4ac958e48b.md): Hugging Face · 2023-12-20 · Medium · 12 min read · Speech & audio, Inference & serving, Performance engineering, Python
  Speculative decoding speeds up Whisper transcription by about 2x while producing mathematically identical outputs.
- [Blazingly fast whisper transcriptions with Inference Endpoints](https://swe.quest/articles/blazingly-fast-whisper-transcriptions-with-inference-endpoints-d93b7d262c3a1210.md): Hugging Face · 2025-05-13 · Easy · 6 min read · Inference & serving, Speech & audio, Performance engineering
  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.
- [Deploying Speech-to-Speech on Hugging Face](https://swe.quest/articles/deploying-speech-to-speech-on-hugging-face-f49accac75643214.md): Hugging Face · 2024-10-22 · Medium · 10 min read · Inference & serving, Speech & audio, Containers, Real-time systems, Python
  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.
- [Fine-Tune Whisper For Multilingual ASR with 🤗 Transformers](https://swe.quest/articles/fine-tune-whisper-for-multilingual-asr-with-transformers-718acb121632ac73.md): Hugging Face · 2022-11-03 · Medium · 25 min read · Speech & audio, Model training, Python
  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.
- [Achieve state-of-the-art inference latencies with speculative decoding](https://swe.quest/articles/achieve-state-of-the-art-inference-latencies-with-speculative-decoding-29855d3aec239f45.md): Modal · 2026-06-24 · Hard · 9 min read · Inference & serving, LLMs, Performance engineering, Model training
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
