Deploy MusicGen in no time with Inference Endpoints
MusicGen, which has no transformers pipeline, can be served on Hugging Face Inference Endpoints by writing a custom handler. You duplicate the facebook/musicgen-large repo, add a handler.py whose EndpointHandler loads the model in float16 on CUDA and runs generate with the request's parameters, and add a requirements.txt pinning transformers and accelerate. An instance with at least 16 GB RAM is enough for musicgen-large. You can then query the endpoint via curl or huggingface_hub's InferenceClient and write the returned waveform to a 32 kHz WAV with scipy, and the same pattern works for any Hub model without a pipeline.
Related posts
- Deploying Speech-to-Speech on Hugging Face
Hugging Face mediumAdeptHugging 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.
- Powerful ASR + diarization + speculative decoding with Hugging Face Inference Endpoints
Hugging Face mediumAdeptA 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.
- Blazingly fast whisper transcriptions with Inference Endpoints
Hugging Face easyNoviceHugging 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.
- AudioLDM 2, but faster ⚡️
Hugging Face mediumAdeptAudioLDM 2, a text-to-audio latent diffusion model conditioned on CLAP, Flan-T5 and GPT2-generated embeddings, can be made over 10x faster in Hugging Face Diffusers with minimal quality loss. Half precision, PyTorch 2.0 SDPA (flash-attention-style) attention and torch.compile on the UNet cut a 200-step generation from about 13 seconds to 4 seconds. Swapping the default DDIM scheduler for DPMSolverMultistep at 20 steps brings a 10-second clip under 1 second. Negative prompting improves quality at no extra inference cost. Memory scales quadratically with audio length in cross-attention, which matters for long samples and large batches.
- Why we’re switching to Hugging Face Inference Endpoints, and maybe you should too
Hugging Face mediumAdeptA team moved CPU-based transformer inference off a self-built FastAPI + Docker + AWS ECS/Fargate stack onto Hugging Face Inference Endpoints, collapsing deployment to train, push to Hub, deploy. In ab benchmarks with a RoBERTa text classifier, a 4-vCPU endpoint answered in 80±30 ms versus ~200 ms on their ECS container, and an 8-vCPU endpoint in 43 ms. Cost runs 24–50% higher than Fargate (about $60/month more for a large instance), which they judge worth it without a dedicated MLOps team, though not at hundreds of services. The main gap they note is the lack of a Terraform provider; they deploy with their own hugie CLI.