DEV Community

Cover image for How to Remove Background Music and Keep Only the Voice. With Prompts for Claude Code, Codex, Grok and Antigravity
Hisashi Space
Hisashi Space

Posted on

How to Remove Background Music and Keep Only the Voice. With Prompts for Claude Code, Codex, Grok and Antigravity

I wanted to reuse the narration from some old TikTok videos I made.

The problem: the videos had background music, and I no longer had the original voice recordings.

So I removed the music and kept only the voice.

Left: with background music. Right: the same scene, voice only

I used Demucs, a free sound separation model released by Meta.
It ran entirely on my Mac and took about 16 seconds for two videos.

This post shows how I did it, how I asked Claude Code, and how to ask Codex, Grok and Antigravity to do the same.

What Demucs does

Demucs splits audio into four parts:

  • Vocals
  • Drums
  • Bass
  • Other instruments

It was built to pull singing voices out of songs, but it works the same way for speech over background music.

It is free and runs on your own computer. You do not need to upload your audio anywhere.

What you can use it for

  • Reuse the voice from an old video in a new one
  • Check what someone is saying when the music is too loud
  • Prepare clean voice samples, for example for text to speech

How I asked Claude Code

All I did was ask Claude Code in plain language (I asked in Japanese; translated here).

First, I pasted the video URLs and asked for the audio:

Extract the audio from these TikTok videos for me
Enter fullscreen mode Exit fullscreen mode

Then, when I worried about the music:

Ah, the background music will probably hurt the quality
Enter fullscreen mode Exit fullscreen mode

Finally, to get the files:

Put them in Downloads too
Enter fullscreen mode Exit fullscreen mode

That was enough for it to:

  • Save the videos
  • Install Demucs
  • Separate the voice from the music
  • Write the voice only audio to my Downloads folder

I did not have to look up Demucs or learn how to install it.

Asking Codex, Grok or Antigravity

Any AI agent that can run commands on your computer can do this. Here is how to start each one:

  • Codex (OpenAI): codex
  • Grok Build (xAI): grok
  • Antigravity (Google): agy

I have only tried this with Claude Code.
So that other agents do not get lost, here is a prompt that spells out every step. Paste it after you start the agent.

Extract only the spoken voice from this video.
Video file: (paste the file path)

Steps
1. Create a working folder and a Python virtual environment inside it
2. Install demucs in that environment
3. Extract the audio from the video with ffmpeg
4. Use demucs with --two-stems=vocals to split voice from everything else
5. Save the voice only file (vocals.wav) to my Downloads folder

Rules
- Do not delete any files outside the working folder
- When you finish, tell me what was created and where
Enter fullscreen mode Exit fullscreen mode

Doing it yourself

You can also run it without an AI agent. In the macOS Terminal:

python3 -m venv demucs-env
source demucs-env/bin/activate
pip install demucs
demucs --two-stems=vocals your-audio.wav
Enter fullscreen mode Exit fullscreen mode

--two-stems=vocals splits the audio into "vocals" and "everything else".
The voice only file is saved as vocals.wav inside a folder called separated.

Things to keep in mind

  • Only use it on videos you made, or videos you have permission to use
  • Where the music and the voice are equally loud, a little music may remain

Summary

  • You can pull just the voice out of a video with background music
  • I used Demucs, a free model from Meta
  • It ran on my Mac in about 16 seconds for two videos
  • With Claude Code, asking in plain language was enough
  • For Codex, Grok and Antigravity, paste a prompt that lists every step

Top comments (0)