codekingpro commited on
Commit
95a9a89
·
verified ·
1 Parent(s): ab22367

Upload folder using huggingface_hub

Browse files
.gitignore ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ====================================================
2
+ # 🔱 TitanAudio Pro - Gold-Standard Git Ignore
3
+ # ====================================================
4
+
5
+ # Virtual Environment (Always ignore local environments)
6
+ venv/
7
+ .venv/
8
+ env/
9
+ ENV/
10
+
11
+ # Python Cache & Compiled Files
12
+ __pycache__/
13
+ *.pyc
14
+ *.pyo
15
+ *.pyd
16
+ .pytest_cache/
17
+ .mypy_cache/
18
+
19
+ # Audio Pipeline Outputs (Prevent pushing massive WAV files)
20
+ Outputs/
21
+ *.wav
22
+ *.mp3
23
+ *.flac
24
+ *.ogg
25
+
26
+ # IDEs & System files
27
+ .vscode/
28
+ .idea/
29
+ .DS_Store
30
+ Thumbs.db
0_Infrastructure/gpu_check.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import sys
3
+
4
+ print("=" * 40)
5
+ print(" TitanAudio Pro - GPU System Check")
6
+ print("=" * 40)
7
+
8
+ cuda_ok = torch.cuda.is_available()
9
+ print(f"PyTorch Version : {torch.__version__}")
10
+ print(f"CUDA Available : {cuda_ok}")
11
+
12
+ if cuda_ok:
13
+ print(f"CUDA Version : {torch.version.cuda}")
14
+ print(f"GPU Device : {torch.cuda.get_device_name(0)}")
15
+ print(f"VRAM Total : {round(torch.cuda.get_device_properties(0).total_memory / 1024**3, 2)} GB")
16
+ print(f"VRAM Free : {round((torch.cuda.get_device_properties(0).total_memory - torch.cuda.memory_allocated(0)) / 1024**3, 2)} GB")
17
+ print("\n STATUS: GPU READY - 100% GPU pipeline active!")
18
+ else:
19
+ print("\n WARNING: CUDA not available. CPU mode only.")
20
+ sys.exit(1)
21
+
22
+ print("=" * 40)
23
+
24
+ # Also check key libraries
25
+ print("\n Checking installed libraries...")
26
+ libs = [
27
+ ("demucs", "demucs"),
28
+ ("librosa", "librosa"),
29
+ ("pedalboard", "pedalboard"),
30
+ ("soundfile", "soundfile"),
31
+ ("audiomentations", "audiomentations"),
32
+ ("onnxruntime", "onnxruntime"),
33
+ ]
34
+
35
+ for name, module in libs:
36
+ try:
37
+ m = __import__(module)
38
+ ver = getattr(m, "__version__", "installed")
39
+ print(f" [OK] {name} v{ver}")
40
+ except ImportError:
41
+ print(f" [MISSING] {name} - needs install")
42
+
43
+ print("\nCheck complete!")
2_Stem_Separation/separate_gpu.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import torch
3
+ import demucs.separate
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ def separate_audio_gpu(input_file, output_dir):
8
+ """
9
+ Separates audio into 4 stems using Demucs v4 (HTDemucs) on GPU.
10
+ """
11
+ print(f"\n[STAGE 2] Starting Stem Separation (GPU)...")
12
+ print(f"Target File: {input_file}")
13
+
14
+ # Ensure output directory exists
15
+ os.makedirs(output_dir, exist_ok=True)
16
+
17
+ # Device check
18
+ device = "cuda" if torch.cuda.is_available() else "cpu"
19
+ print(f"Using Device: {device}")
20
+
21
+ # Demucs arguments
22
+ # htdemucs is the latest v4 model
23
+ args = [
24
+ "-d", device,
25
+ "--out", output_dir,
26
+ "-n", "htdemucs",
27
+ str(input_file)
28
+ ]
29
+
30
+ try:
31
+ demucs.separate.main(args)
32
+ print(f"[SUCCESS] Stems saved to: {output_dir}")
33
+ return True
34
+ except Exception as e:
35
+ print(f"[ERROR] Separation failed: {e}")
36
+ return False
37
+
38
+ if __name__ == "__main__":
39
+ if len(sys.argv) < 2:
40
+ print("Usage: python separate_gpu.py <input_path>")
41
+ else:
42
+ input_path = sys.argv[1]
43
+ out_path = os.path.join(os.getcwd(), "Outputs", "Stems")
44
+ separate_audio_gpu(input_path, out_path)
3_Transformation/apply_fx_gpu.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import soundfile as sf
4
+ from pedalboard import Pedalboard, Reverb, Compressor, HighShelfFilter, LowShelfFilter, Chorus, Distortion
5
+ from pedalboard.io import AudioFile
6
+ import numpy as np
7
+ from pathlib import Path
8
+
9
+ def apply_transformations_gpu(input_folder, output_folder):
10
+ print(f"\n[STAGE 3] Applying Multi-Layer Transformations...")
11
+ print(f"Reading from: {input_folder}")
12
+ os.makedirs(output_folder, exist_ok=True)
13
+
14
+ vocal_board = Pedalboard([Compressor(threshold_db=-20, ratio=4), Reverb(room_size=0.1, wet_level=0.1), HighShelfFilter(cutoff_frequency_hz=3000, gain_db=2)])
15
+ drum_board = Pedalboard([Distortion(drive_db=2), LowShelfFilter(cutoff_frequency_hz=150, gain_db=3)])
16
+ music_board = Pedalboard([Chorus(depth=0.2, rate_hz=1.0), Reverb(room_size=0.2, wet_level=0.15)])
17
+
18
+ files_processed = 0
19
+ # Walk through input folder to find stems
20
+ for root, dirs, files in os.walk(input_folder):
21
+ for file in files:
22
+ if file.endswith(('.wav', '.mp3', '.flac')):
23
+ input_path = os.path.join(root, file)
24
+ output_path = os.path.join(output_folder, f"transformed_{file}")
25
+
26
+ print(f" Processing: {file}")
27
+ with AudioFile(input_path) as f:
28
+ audio = f.read(f.frames)
29
+ samplerate = f.samplerate
30
+ board = vocal_board if "vocals" in file.lower() else (drum_board if "drums" in file.lower() else music_board)
31
+ effected = board(audio, samplerate)
32
+ with AudioFile(output_path, 'w', samplerate, effected.shape[0]) as o:
33
+ o.write(effected)
34
+ files_processed += 1
35
+
36
+ print(f"[SUCCESS] {files_processed} stems transformed and saved to: {output_folder}")
37
+
38
+ if __name__ == "__main__":
39
+ stems_in = os.path.join(os.getcwd(), "Outputs", "Stems")
40
+ fx_out = os.path.join(os.getcwd(), "Outputs", "Transformed")
41
+ apply_transformations_gpu(stems_in, fx_out)
5_Mastering/master_final.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ from pathlib import Path
4
+ import matchering as mg
5
+ import sys
6
+
7
+ def merge_stems_ffmpeg(stems_folder, output_file, ffmpeg_path):
8
+ print(f"\n[STAGE 6] Mixing Stems using FFmpeg...")
9
+ stems = [os.path.join(stems_folder, f) for f in os.listdir(stems_folder) if f.startswith("transformed_")]
10
+ if not stems:
11
+ print("[ERROR] No transformed stems found!")
12
+ return False
13
+
14
+ cmd = [ffmpeg_path, "-y"]
15
+ for s in stems:
16
+ cmd.extend(["-i", s])
17
+
18
+ cmd.extend([
19
+ "-filter_complex", f"amix=inputs={len(stems)}:duration=longest",
20
+ "-ac", "2",
21
+ output_file
22
+ ])
23
+ subprocess.run(cmd, capture_output=True)
24
+ return True
25
+
26
+ def apply_mastering(input_file, output_file):
27
+ print(f"\n[STAGE 5] Applying AI Mastering (Matchering)...")
28
+ try:
29
+ # Correct Matchering v2 usage: result is the target path string
30
+ mg.process(
31
+ target=input_file,
32
+ reference=input_file,
33
+ save_to=output_file
34
+ )
35
+ print(f"[SUCCESS] Mastered file saved: {output_file}")
36
+ return True
37
+ except Exception as e:
38
+ print(f"[ERROR] Mastering failed: {e}")
39
+ # If matchering fails, we still have the final mix
40
+ return False
41
+
42
+ if __name__ == "__main__":
43
+ FFMPEG_BIN = "D:/CODE/Apps/devtools/ffmpeg/bin/ffmpeg.exe"
44
+ FX_DIR = os.path.join(os.getcwd(), "Outputs", "Transformed")
45
+ MIXED_WAV = os.path.join(os.getcwd(), "Outputs", "Final_Mix.wav")
46
+ MASTERED_WAV = os.path.join(os.getcwd(), "Outputs", "Titan_Master_Final.wav")
47
+
48
+ if merge_stems_ffmpeg(FX_DIR, MIXED_WAV, FFMPEG_BIN):
49
+ apply_mastering(MIXED_WAV, MASTERED_WAV)
README.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🔱 TitanAudio Pro: The Phantom Engine
2
+ A professional GPU-accelerated audio transformation pipeline designed to bypass Content ID fingerprints using advanced AI synthesis.
3
+
4
+ ## 🏗️ Project Architecture (GPU-Only)
5
+
6
+ ### Stage 1: Deep Audio Analysis (`1_Analysis`)
7
+ - **Tools:** Librosa (GPU-backed via CuPy/Torch), Crepe.
8
+ - **Goal:** Extract BPM, Key, Pitch, and Spectral Centroid.
9
+
10
+ ### Stage 2: AI Stem Separation (`2_Stem_Separation`)
11
+ - **Tools:** Demucs v4 (HTDemucs) - CUDA Enabled.
12
+ - **Goal:** Separate Vocals, Drums, Bass, and Other.
13
+
14
+ ### Stage 3: Multi-Layer Transformation (`3_Transformation`)
15
+ - **Tools:** Pedalboard (VST3/GPU), Audiomentations (Torch-based).
16
+ - **Goal:** Phase shifting, Micro-latency, Random EQ, Reverb.
17
+
18
+ ### Stage 4: AI Identity Regeneration (`4_Regeneration`)
19
+ - **Tools:** RVC v2 (CUDA), Meta AudioCraft (MusicGen/AudioGen).
20
+ - **Goal:** Complete Timbre replacement and Melody-conditioned synthesis.
21
+
22
+ ### Stage 5: AI Mastering & Quality Check (`5_Mastering`)
23
+ - **Tools:** Matchering, Pyloudnorm, VISQOL.
24
+ - **Goal:** Professional loudness and artifact verification.
25
+
26
+ ---
27
+ ## 🛠️ Infrastructure Requirements
28
+ - **OS:** Windows (PowerShell)
29
+ - **GPU:** NVIDIA (CUDA Toolkit 11.8/12.1)
30
+ - **Python:** 3.10+ (Inside `venv`)
main_pipeline.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import subprocess
4
+ import torch
5
+ from pathlib import Path
6
+
7
+ # Project paths
8
+ PROJECT_ROOT = Path(__file__).resolve().parent
9
+ VENV_PYTHON = PROJECT_ROOT / "venv" / "Scripts" / "python.exe"
10
+
11
+ def print_banner():
12
+ banner = """
13
+ +----------------------------------------------------------+
14
+ | *** TITANAUDIO PRO : THE PHANTOM ENGINE *** |
15
+ | -- GPU-Accelerated Audio AI Pipeline -- |
16
+ +----------------------------------------------------------+
17
+ """
18
+ print(banner)
19
+
20
+ def print_sys_info():
21
+ print(" [SYSTEM STATUS]")
22
+ cuda_avail = torch.cuda.is_available()
23
+ print(f" |-- PyTorch Version : {torch.__version__}")
24
+ print(f" |-- CUDA Available : {'YES (GPU)' if cuda_avail else 'NO (CPU)'}")
25
+ if cuda_avail:
26
+ device_name = torch.cuda.get_device_name(0)
27
+ total_mem = round(torch.cuda.get_device_properties(0).total_memory / 1024**3, 2)
28
+ print(f" |-- GPU Device : {device_name}")
29
+ print(f" +-- Total VRAM : {total_mem} GB")
30
+ print(" " + "-"*58 + "\n")
31
+
32
+ def run_stage(stage_num, stage_name, script_path, args=[]):
33
+ print(f" => [STEP {stage_num}/3] {stage_name}...")
34
+ cmd = [str(VENV_PYTHON), str(script_path)] + args
35
+ print(f" | Executing: {script_path.name}")
36
+
37
+ # Run the stage script
38
+ result = subprocess.run(cmd, capture_output=False)
39
+
40
+ if result.returncode == 0:
41
+ print(f" +==> [SUCCESS] {stage_name} completed successfully!\n")
42
+ return True
43
+ else:
44
+ print(f" +==> [ERROR] {stage_name} failed with exit code {result.returncode}\n")
45
+ return False
46
+
47
+ def main():
48
+ print_banner()
49
+ print_sys_info()
50
+
51
+ if len(sys.argv) < 2:
52
+ print(" [ERROR] No input file provided!")
53
+ print(" Usage: python main_pipeline.py <input_audio_file>\n")
54
+ return
55
+
56
+ input_file = sys.argv[1]
57
+ input_path = Path(input_file).resolve()
58
+
59
+ if not input_path.exists():
60
+ print(f" [ERROR] Input file not found: {input_file}\n")
61
+ return
62
+
63
+ # --- STAGE 2: Separation ---
64
+ sep_script = PROJECT_ROOT / "2_Stem_Separation" / "separate_gpu.py"
65
+ if not run_stage(1, "Deep AI Stem Separation (Demucs)", sep_script, [str(input_path)]):
66
+ print(" [CRITICAL] Separation failed. Pipeline aborted.\n")
67
+ return
68
+
69
+ # --- STAGE 3: Transformation ---
70
+ fx_script = PROJECT_ROOT / "3_Transformation" / "apply_fx_gpu.py"
71
+ if not run_stage(2, "Multi-Layer FX Transformation (Pedalboard)", fx_script):
72
+ print(" [CRITICAL] FX transformation failed. Pipeline aborted.\n")
73
+ return
74
+
75
+ # --- STAGE 5 & 6: Mix & Master ---
76
+ master_script = PROJECT_ROOT / "5_Mastering" / "master_final.py"
77
+ if not run_stage(3, "High-Fidelity AI Mastering (Matchering)", master_script):
78
+ print(" [CRITICAL] AI Mastering failed. Pipeline aborted.\n")
79
+ return
80
+
81
+ # Final Success Summary
82
+ print(" " + "="*58)
83
+ print(" *** TITAN ENGINE SUCCESS: Audio processed flawlessly! ***")
84
+ print(f" * Final Mix: Outputs/Final_Mix.wav")
85
+ print(f" * Mastered : Outputs/Titan_Master_Final.wav")
86
+ print(" " + "="*58 + "\n")
87
+
88
+ if __name__ == "__main__":
89
+ main()
requirements.txt ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ====================================================
2
+ # 🔱 TitanAudio Pro - System Dependencies
3
+ # ====================================================
4
+
5
+ # Core PyTorch (CUDA Enabled is recommended)
6
+ torch>=2.0.0
7
+
8
+ # Stem Separation & Analysis
9
+ demucs>=4.0.0
10
+ librosa>=0.10.0
11
+ soundfile>=0.12.0
12
+
13
+ # FX Transformation
14
+ pedalboard>=0.9.0
15
+ audiomentations>=0.30.0
16
+
17
+ # AI Mastering
18
+ matchering>=2.0.0
19
+ pyloudnorm>=0.1.0