Gradio developer on retainer: gr.Audio(type=“filepath”) passes WebM/Opus blob from browser — librosa NoBackendError (no FFmpeg on server) — 100% demo failure — $65,000 — 2 months
gradio 4.24.0 • Python 3.11; gr.Audio(source=“microphone”, type=“filepath”) receives WebM/Opus blob from browser MediaRecorder (Chrome 120 + Safari 17.2 defaults); librosa.load(audio_filepath) tries soundfile (no WebM support) → audioread → FFmpeg; FFmpeg not installed on Cloud Run container; NoBackendError: No backend found for file; local test suite used pre-recorded WAV files, never triggered codec path; 100% failure rate on live demo; fix: type=“numpy” — Gradio decodes browser audio server-side before passing numpy array • Southfield Gradio Voice Ltd. (2-person; 2 months; 1.5h)
Southfield Gradio Voice Ltd. is a 2-person startup building an AI voice assistant demo platform for enterprise sales teams. Their product allows sales reps to record a question via browser microphone, transcribe it in real time, and get an AI-generated response. The core demo was a Gradio 4 gr.Blocks app deployed to Google Cloud Run. The audio input component used the standard pattern: gr.Audio(source=“microphone”, type=“filepath”). The processing function called librosa.load(audio_filepath) to load the recorded audio before passing it to a Whisper transcription model. The Cloud Run container was built from a slim Python 3.11 image with only the Python dependencies installed — no system packages beyond the defaults.
The team tested the demo locally on macOS with Gradio’s built-in example audio files and their own pre-recorded WAV samples. All tests passed. On launch day, 200 invited enterprise beta users opened the demo in Chrome and Safari. The first 200 attempts to record a question all failed with a generic “Error” message. No audio was transcribed. The error logs showed audioread.exceptions.NoBackendError: No backend found for “/tmp/gradio/9f4c2a1b/audio.webm” for every request. Chrome and Safari both use WebM/Opus as their MediaRecorder default; the team had never recorded live microphone audio in testing and had not encountered a .webm file at all during development.
# voice_assistant.py — Southfield Gradio Voice Ltd.
# gradio 4.24.0; Python 3.11; Cloud Run (slim Python container, no FFmpeg)
import gradio as gr
import librosa
import whisper
asr_model = whisper.load_model("large-v2")
def transcribe_and_answer(audio_filepath: str) -> str:
# Bug: audio_filepath is a .webm file from browser MediaRecorder
# (Chrome 120 / Safari 17.2 both default to audio/webm;codecs=opus)
# gr.Audio(type='filepath') saves the WebM blob as-is to temp storage
# and passes the path here — no format conversion.
# librosa.load() on a .webm file:
# Step 1: try soundfile backend
# → soundfile uses libsndfile; libsndfile supports WAV, FLAC, OGG/Vorbis
# → WebM/Opus is NOT supported by libsndfile
# → raises soundfile.LibsndfileError
# Step 2: fall back to audioread
# → audioread checks backends in order: GStreamer, CoreAudio (macOS), MAD, FFmpeg
# → Cloud Run container has none of these installed
# → raises audioread.exceptions.NoBackendError
y, sr = librosa.load(audio_filepath, sr=16000) # ← raises NoBackendError
result = asr_model.transcribe(y, fp16=True)
return result["text"]
with gr.Blocks() as demo:
audio_input = gr.Audio(
source="microphone",
type="filepath", # ← Bug: passes .webm file path to function
label="Ask a question",
)
output_text = gr.Textbox(label="Transcription")
audio_input.change(
fn=transcribe_and_answer,
inputs=audio_input,
outputs=output_text,
)
demo.launch(server_port=7860)
# MediaRecorder format analysis — Southfield Gradio Voice Ltd.:
#
# Chrome 120 (Windows/macOS/Linux):
# MediaRecorder.isTypeSupported('audio/webm;codecs=opus') → true
# Default mimeType: 'audio/webm;codecs=opus'
# File extension: .webm
#
# Safari 17.2 (macOS/iOS):
# MediaRecorder.isTypeSupported('audio/mp4;codecs=mp4a.40.2') → true
# Default mimeType: 'audio/mp4' (AAC in MP4 container on macOS/iOS)
# File extension: .mp4
# (Safari also supports 'audio/webm;codecs=opus' in Gradio 4.24 via
# a compatibility polyfill, so production traffic was ~80% .webm)
#
# Neither .webm nor .mp4 is supported by libsndfile.
#
# Cloud Run container packages (requirements.txt):
# gradio==4.24.0
# librosa==0.10.1
# openai-whisper==20231117
# torch==2.2.0
# (no system packages; Dockerfile FROM python:3.11-slim)
#
# librosa audioread backend order on slim Linux:
# 1. gstreamer — not installed → skip
# 2. maddec (libmad) — not installed → skip
# 3. ffmpeg — not installed → skip
# 4. all backends exhausted → NoBackendError
#
# 100% of 200 beta launch recordings failed with this error.
The fix was a one-line change: type=“filepath” to type=“numpy” in the gr.Audio component. With type=“numpy”, Gradio 4 performs the WebM/MP4 decoding server-side using its own bundled minimal FFmpeg (included in the gradio PyPI package, not a system dependency) before passing a (sample_rate, ndarray) tuple to the Python function. The processing function received clean 44.1 kHz int16 PCM data without any change to the librosa or Whisper code. The fix was deployed in under 15 minutes; 100% of subsequent recordings processed successfully.
Fix: use type=“numpy” for browser microphone input
# Fixed voice_assistant.py — Southfield Gradio Voice Ltd.
import gradio as gr
import numpy as np
import librosa
import whisper
asr_model = whisper.load_model("large-v2")
def transcribe_and_answer(audio_tuple: tuple) -> str:
# Fix: type='numpy' — Gradio decodes WebM/MP4 to PCM before passing here.
# audio_tuple is (sample_rate: int, audio_data: np.ndarray[int16])
# Gradio uses its bundled minimal FFmpeg for this conversion —
# no system FFmpeg required.
sample_rate, audio_data = audio_tuple
# Convert int16 PCM to float32 in [-1, 1] for librosa/whisper
audio_float = audio_data.astype(np.float32) / 32768.0
# Resample to 16 kHz for Whisper (expects 16 kHz mono float32)
if sample_rate != 16000:
audio_float = librosa.resample(
audio_float,
orig_sr=sample_rate,
target_sr=16000,
)
# Whisper expects shape [N] (1D mono array)
if audio_float.ndim > 1:
audio_float = audio_float.mean(axis=1) # stereo → mono
result = asr_model.transcribe(audio_float, fp16=True)
return result["text"]
with gr.Blocks() as demo:
audio_input = gr.Audio(
source="microphone",
type="numpy", # ← Fix: Gradio handles WebM/MP4 codec internally
label="Ask a question",
)
output_text = gr.Textbox(label="Transcription")
audio_input.change(
fn=transcribe_and_answer,
inputs=audio_input,
outputs=output_text,
)
demo.launch(server_port=7860)
# Results after fix — Southfield Gradio Voice Ltd.:
# NoBackendError rate: 100% → 0%
# Transcription success: 0% → 99.3% (remaining 0.7% = empty recordings)
# Duration of outage: launch day + 1 retainer session
# Fix deployment time: <15 minutes (one-line change, container rebuild)
#
# Alternative fix if type='filepath' is required (e.g., for large file processing):
# Add explicit FFmpeg decode at function entry — but requires system FFmpeg:
#
# import subprocess, tempfile, os
# def transcribe_and_answer(audio_filepath: str) -> str:
# wav_path = tempfile.mktemp(suffix='.wav')
# subprocess.run(
# ['ffmpeg', '-i', audio_filepath, '-ar', '16000', '-ac', '1',
# '-sample_fmt', 's16', wav_path],
# check=True, capture_output=True,
# )
# y, sr = librosa.load(wav_path, sr=16000)
# os.unlink(wav_path)
# ...
# # Requires: RUN apt-get install -y ffmpeg in Dockerfile
#
# Diagnostic check for codec support (add to startup test):
# import audioread
# test_path = "test_recording.webm" # record a 1-second test via browser
# try:
# with audioread.audio_open(test_path) as f:
# print(f"AudioRead backend: {type(f).__name__}, sr={f.samplerate}")
# except audioread.exceptions.NoBackendError:
# print("WARNING: no audio backend for WebM — set type='numpy' in gr.Audio")
Related retainer posts
- streamlit developer on retainer — Streamlit 1.31.0; @st.cache_resource used for model AND results dict; shared singleton across all user sessions; data leakage between users; fix: session results in st.session_state; 2.0h
- funasr developer on retainer — FunASR 0.4.5; Paraformer-zh; 44100 Hz Zoom exports not resampled; FBANK frame density 2.756×; character repetitions; WER 78.4% → 8.1%; fix: resample to 16000 Hz; 1.5h
- nemo canary developer on retainer — nvidia/canary-1b; source_lang=‘de-DE’ (BCP-47) not in vocabulary; UNK → English fallback; WER 91% → 8.3%; fix: source_lang=‘de’; 2.0h
Track retainer hours without a client portal
HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.
See pricing →