Creating an MR from the original MP3 audio in Python - Deleting Voice Track from Audio File

CK CK 3788 
Created at
Updated at  
439 0 0

Spleeter is a Python-based audio source separation library that uses deep neural networks to separate different instruments and vocals from a mixed audio track. You can install it using `pip install spleeter`, and its core functionality is accessed through the `spleeter separate` command. You can specify the desired output format (e.g., WAV or MP3), the number of stems (e.g., 2 for vocals and accompaniment, or 4 for vocals, drums, bass, and other instruments), and even customize the model used for separation. Spleeter also offers a graphical interface for basic operations and is known for its efficient and high-quality audio separation capabilities. 
 

Deleting a specific voice from an audio file (like an MP3) is possible, though it can be complex. It requires isolating the voice of interest, which may involve techniques like voice separation and filtering. Here’s a basic outline of the process:

  1. Speech/Voice Separation: First, isolate the voice from other sounds in the audio. Libraries like Spleeter (a pre-trained model for source separation) can split audio into vocal and instrumental tracks, which may help in isolating a specific voice if the file has multiple voices. However, if you need to remove just one speaker from a multi-speaker file, you’d need speaker diarization.
  2. Speaker Diarization and Identification: Use models that can identify different speakers in an audio clip, such as pyAudioAnalysis, pyannote.audio (a toolkit for speaker diarization), or pre-trained models from Hugging Face. This will allow you to pinpoint segments in which each speaker is speaking.
  3. Removing or Replacing Voice Segments: After identifying the voice segments, you can use libraries like pydub or librosa to remove or replace those segments.

 

Pydub is a Python library designed for manipulating audio files. It provides a high-level interface for basic audio operations like loading, saving, splitting, concatenating, and applying effects to audio files in various formats. Pydub leverages the powerful audio processing capabilities of FFmpeg, making it easy for developers to work with audio data in Python without needing to directly interact with FFmpeg's command-line interface. Pydub's simplicity and flexibility make it a valuable tool for audio processing tasks in Python projects. 

 

Example Workflow with Spleeter and pydub

Here’s a simple way to remove vocals altogether (like a karaoke track) using Spleeter and then apply more specific modifications with pydub. Unfortunately, removing one specific speaker voice from a multi-speaker file is more complex and would require machine learning models for speaker diarization.

# Step 1: Separate vocal and instrumental using Spleeter
# Install Spleeter with: pip install spleeter
import spleeter
from pydub import AudioSegment

# Run Spleeter to separate vocals and instruments
subprocess.run(["spleeter", "separate", "original_audio.mp3", "-p", "spleeter:2stems", "-o", "output"])

# Step 2: Load the separated files (vocal and instrumental)
instrumental = AudioSegment.from_file("output/original_audio/accompaniment.wav")
vocals = AudioSegment.from_file("output/original_audio/vocals.wav")

# Optional: Further process vocals to isolate specific speakers (requires a diarization library)

# Step 3: Recombine or remove segments
# For instance, if you want to remove vocals, just use the instrumental track
instrumental.export("output_audio_no_vocals.mp3", format="mp3")

To identify and remove a specific voice, you'd use a speaker diarization library to pinpoint the specific speaker segments.

Tags Deleting Voice Track Dubbing Python Dubbing pydub spleeter Facebook X
Comments 0
Similar posts
  1. Python Audio Separation Libraries allowing you to isolate individual tracks
    1,442
  1. How do I get the maximum available of thread in python?
    990
  2. Using Queue Algorithm with Redis - RPUSH and LPOP
    769
  3. Use cache concept with Redis : Let's do Redis programming with Python
    531
  4. Installing Python 3.8 in a venv environment on CentOS 7
    463
  5. CUDA versus OpenCL
    578
  6. Simple gRPC server based on Python
    394
  7. Python code to convert PDF file to Excel Spreadsheet
    699
  8. Python script to list files on your Google Drive and download one of them
    940
  9. Coinbase Python API - Basic Example
    461
  10. AWS Lambda Code Example based on Python
    333
  11. Python code using GPU on CentOS with AWS
    1,251
  12. Video Scence Detection with PySceneDetect
    2,320
  13. Python Audio Separation Libraries allowing you to isolate individual tracks
    1,442
  14. Python Version Control for Library Compatibility with pyenv - Downgrading/Upgrading Python Version
    908
  15. Deleting a specific user voice from the original audio track with Python
    548
  16. Creating mp3 audio file based on the text input with Python
    465
  17. Implementing Text To Speech / Audio with Python3 and pyttsx3
    355
  18. Building Initial Virtual Environment at Python - The first step you should do for Python Programming
    559
  19. Python Simplified Assignment Operators
    533
  20. Trackback module used for Python Threading debugging
    843
  21. Python Flask with simple HTML files to server web pages along with API
    927
  22. Python Flask web server tutorial from the scratch
    622
  23. Simple Web Server based in Python
    371
  24. Thread Implementation in Python
    509
  25. A shell script that activates a Python virtual environment and then runs a specific Python script
    742
  26. Learning about Python Multiprocessing Technique
    592
  27. Simple Example to get the total number of records in BigQuery with Python
    666
  28. Using BigQuery in Python
    410
  29. Python Web Programming based on Django from the Scratch
    373
  30. Flink with Python: Core Concepts, Kafka Integration, and Architectural Trade-offs
    187
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    39
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    34
  3. How do I create animated background for Google Meet?
    20,611
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    244
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    94
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    156
  7. Array of arguments passed to script in PHP
    90
  8. Invalid Auction Storms in Ad Tech
    98
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    202
  10. The Two Clocks of Ad Server Architecture
    69
  11. Frequency Cap Architecture Overview
    514
  12. Collecting Proof-of-Play from 100,000 Screens
    146
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    287
  14. What is RedisVL?
    108
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    230
  16. TPU & GPU Cluster Management Tools
    243
  17. The Concept of Scaffolding in AI Agents
    232
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    582
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    258
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    338
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    202
  22. Machine Learning: Training vs. Ranking
    221
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    222
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    195
  25. Designing a Data Curation System Around a Vector Database
    220
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    256
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    656
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    195
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    216
  30. Understanding Data Lineage
    259