Inspiration

Singers, choirs, worship teams and music students all hit the same wall: the song they want to practise is on YouTube, but it's in the wrong key, too fast, and the lyrics are somewhere else. Getting a backing track usually means a paid service, a desktop app, or uploading someone else's music to a server. We wanted it to take one click, inside the browser, with the audio staying on your own machine.

What it does

StemShift is a Chrome extension that turns any song playing on YouTube into a practice-ready karaoke track.

  • Capture: click the toolbar icon and the studio docks in Chrome's side panel next to the video. It records the tab's audio, at 1× or 2× speed to halve the wait. Nothing is downloaded from YouTube.
  • Separate: a neural source-separation model (UVR MDX-Net) runs locally on your GPU through WebGPU and ONNX Runtime Web, splitting the song into an instrumental and a vocal stem. Each stem gets a lane with a fader, mute and solo, plus one-click A/B against the original.
  • Reshape: the key and BPM are detected automatically. Pitch and speed change independently, with EQ and reverb on top. Or just describe a vibe ("slowed + reverb") and Gemini sets the knobs.
  • Lyrics: StemShift finds the real lyrics (the video's own subtitles, then the open LRCLIB database) and lines them up with the isolated vocal stem. If nothing is published, Gemini transcribes the vocal stem. Lyrics can be rewritten with AI (clean up explicit lines, stronger rhymes, simpler words, singable translations) while keeping each line's syllable count so it still fits the melody.
  • Export: a 1080p karaoke MP4 with a music-reactive visual and lyrics highlighted in time, encoded in the browser with WebCodecs. Also WAV stems and .lrc lyrics re-timed to the new tempo.

How we built it: Firebase AI Logic hybrid inference

All AI calls go through firebase/ai (getGenerativeModel with hybrid params) in src/ai.js, and every task is routed to the side that suits it:

  • Text tasks (lyric rewrites, the remix assistant) use InferenceMode.PREFER_ON_DEVICE. They run on Gemini Nano through Chrome's built-in Prompt API when it's available (private, free, works offline) and fall back to cloud Gemini automatically when it isn't.
  • Audio tasks (transcription, and timing words-only lyrics to the vocals) use PREFER_IN_CLOUD, because on-device audio input isn't supported yet. Only the 16 kHz mono vocal stem is sent, never the full mix.
  • One JSON schema drives both paths: responseConstraint on-device and responseJsonSchema in the cloud, so responses have the same shape whichever side answers. The UI shows which side actually answered (inferenceSource) as an on-device or cloud badge.
  • A mode switch (prefer on-device / only on-device / prefer cloud / only cloud), a Gemini Nano status pill, and a download button that calls initializeDeviceModel() with progress.

Supporting Firebase products: App Check (debug provider, since MV3 extension pages can't load reCAPTCHA), Remote Config (cloud model and limits, changeable without republishing), and anonymous Auth + Firestore for a library of lyrics and remix settings (never audio).

The rest is plain web platform: Chrome Extensions MV3 (tabCapture, side panel, offscreen documents), Web Audio and AudioWorklet, Web Workers for DSP, ONNX Runtime Web on WebGPU with a WASM fallback, WebCodecs with mp4-muxer, and esbuild.

Challenges we ran into

  • Fast capture inserts silence. At 2× playback, Chrome's tab audio emits short runs of exact digital silence every few seconds and then carries on, pushing the song later. We tracked it down by cross-correlating captures against a clean reference, then added a pass that cuts those runs out (with tests), so 2× captures are now seamless.
  • App Check inside an extension. reCAPTCHA can't load under the MV3 content security policy, so the extension uses the App Check debug provider with a token entered in Settings and stored only in chrome.storage.local.
  • Keeping rewrites aligned. Lyric rewrites must return exactly one line per input line so timestamps stay correct. Structured output on both the on-device and cloud paths, plus batching to stay inside Gemini Nano's context window, made that reliable.
  • Lining up published lyrics with a specific recording: a global offset search against the vocal stem's energy, then small per-line corrections.

What we learned

Hybrid inference works best when each task is routed deliberately: short, private text work belongs on-device, and audio goes to the cloud until on-device audio input lands. Using one schema for both paths kept the app code to a single path.

What's next

On-device transcription once Gemini Nano accepts audio, a Chrome Web Store release, and more stems (drums, bass) for practice.

Try it

Download the zip from the v1.2.0 release, unzip it, and load the folder at chrome://extensions with Developer mode on (Load unpacked). Capture, stem separation, key and tempo, lyrics and export work without any setup. The cloud AI features need an App Check token in ⚙ Settings.

Built With

  • chrome
  • cloud-firestore
  • esbuild
  • firebase
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-remote-config
  • gemini
  • gemini-nano
  • javascript
  • onnx-runtime-web
  • web-audio-api
  • webcodecs
  • webgpu
Share this project:

Updates

Submission history