Spaces:
Configuration error
Configuration error
Fix cross-origin isolation to resolve TTS crash and slow ASR on HuggingFace
#4
by Paulescu - opened
No description provided.
Paulescu changed pull request status to open
Problem
Two bugs appear when the app runs on HuggingFace Spaces but not
locally:
- TTS crashes with
Error: input 'depth_slices_in' is missing in 'feeds' - ASR is ~6x slower (0.8 tok/s on HF vs 4.6 tok/s locally)
Root cause
HuggingFace's static file server does not send the
Cross-Origin-Opener-Policy: same-origin
and Cross-Origin-Embedder-Policy: require-corp headers
required for cross-origin isolation.
Without them, SharedArrayBuffer is blocked by the browser,
which breaks ONNX Runtime Web's
WebGPU backend:
- The vocoder's
depth_slicesgpu-buffer tensor cannot be
passed betweensession.run()calls,
causing the TTS crash at step 1 of the vocoder loop - WASM falls back to single-threaded, causing the ASR slowdown
Locally, Vite's dev server injects these headers, so the issue
is invisible until deployed.
Fix
A coi-serviceworker.js service worker that intercepts all HTTP
responses and injects COOP/COEP
headers client-side. This is the standard approach used by many
HuggingFace WebGPU demos.
Files changed
public/coi-serviceworker.js: new service worker (dual-mode:
registers itself, then adds headers to all responses)index.html: loads the service worker beforemain.jsvite.config.js: adds COOP/COEP headers to thepreview
server block (mirrors the existingserverblock)
Paulescu changed pull request title from Fix cross-origin isolation to resolve TTS crash and slow ASR on HuggingFace to [WIP do not merge]Fix cross-origin isolation to resolve TTS crash and slow ASR on HuggingFace
Paulescu changed pull request title from [WIP do not merge]Fix cross-origin isolation to resolve TTS crash and slow ASR on HuggingFace to Fix cross-origin isolation to resolve TTS crash and slow ASR on HuggingFace
ykhrustalev changed pull request status to merged