Add ZeroGPU support and Windows local startup
Browse files- Add @spaces.GPU decorators to all GPU-intensive functions
- Update requirements.txt with proper versions and dependencies
- Add ZeroGPU support to vynl_generator.py, ai_studio.py, vynl_rvc.py
- Create Windows startup batch file (start_vynl.bat)
- Add local_config.py for environment detection
- Update gradio to 4.44.0 for ZeroGPU compatibility
- Fix AudioCraft dependency version
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- README.md +1 -2
- ai_studio.py +19 -3
- app.py +13 -4
- local_config.py +95 -0
- requirements.txt +10 -8
- start_vynl.bat +112 -0
- vynl_generator.py +15 -1
- vynl_rvc.py +17 -2
README.md
CHANGED
|
@@ -4,11 +4,10 @@ emoji: '🎸'
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 4.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
license: other
|
| 11 |
-
hardware: zero-a10g
|
| 12 |
---
|
| 13 |
|
| 14 |
# VYNL - Complete Music Production Suite
|
|
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
license: other
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
# VYNL - Complete Music Production Suite
|
ai_studio.py
CHANGED
|
@@ -13,6 +13,19 @@ from datetime import datetime
|
|
| 13 |
from typing import Optional, List, Tuple
|
| 14 |
import subprocess
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# Persistent storage for models
|
| 17 |
MODELS_DIR = Path(os.environ.get('VYNL_MODELS_DIR', Path.home() / '.vynl_models'))
|
| 18 |
MODELS_DIR.mkdir(parents=True, exist_ok=True)
|
|
@@ -271,11 +284,12 @@ def create_training_manifest(audio_files: List[str], descriptions: List[str],
|
|
| 271 |
return str(manifest_path)
|
| 272 |
|
| 273 |
|
|
|
|
| 274 |
def train_model(training_dir: Path, model_name: str, style_description: str,
|
| 275 |
base_model: str = "small", epochs: int = 10,
|
| 276 |
progress_callback=None) -> Tuple[Optional[str], str]:
|
| 277 |
"""
|
| 278 |
-
Fine-tune MusicGen on custom audio
|
| 279 |
|
| 280 |
Note: Full fine-tuning requires significant GPU memory.
|
| 281 |
This uses a simplified approach with style conditioning.
|
|
@@ -404,10 +418,11 @@ def analyze_training_style(audio_files: List[Path]) -> dict:
|
|
| 404 |
# GENERATION
|
| 405 |
# ============================================================================
|
| 406 |
|
|
|
|
| 407 |
def generate_music(prompt: str, model_choice: str, duration: int = 30,
|
| 408 |
temperature: float = 1.0, progress_callback=None) -> Tuple[Optional[str], str]:
|
| 409 |
"""
|
| 410 |
-
Generate music using MusicGen with optional custom style
|
| 411 |
"""
|
| 412 |
if not HAS_AUDIOCRAFT:
|
| 413 |
return None, "AudioCraft not installed. Install with: pip install audiocraft"
|
|
@@ -498,9 +513,10 @@ def generate_music(prompt: str, model_choice: str, duration: int = 30,
|
|
| 498 |
return None, f"Generation error: {str(e)}"
|
| 499 |
|
| 500 |
|
|
|
|
| 501 |
def generate_with_melody(prompt: str, melody_audio: str, model_choice: str,
|
| 502 |
duration: int = 30, progress_callback=None) -> Tuple[Optional[str], str]:
|
| 503 |
-
"""Generate music conditioned on a melody/reference audio"""
|
| 504 |
if not HAS_AUDIOCRAFT or not HAS_LIBROSA:
|
| 505 |
return None, "AudioCraft and librosa required"
|
| 506 |
|
|
|
|
| 13 |
from typing import Optional, List, Tuple
|
| 14 |
import subprocess
|
| 15 |
|
| 16 |
+
# ZeroGPU support for HuggingFace Spaces
|
| 17 |
+
try:
|
| 18 |
+
import spaces
|
| 19 |
+
HAS_ZEROGPU = True
|
| 20 |
+
except ImportError:
|
| 21 |
+
HAS_ZEROGPU = False
|
| 22 |
+
class spaces:
|
| 23 |
+
@staticmethod
|
| 24 |
+
def GPU(duration=60):
|
| 25 |
+
def decorator(func):
|
| 26 |
+
return func
|
| 27 |
+
return decorator
|
| 28 |
+
|
| 29 |
# Persistent storage for models
|
| 30 |
MODELS_DIR = Path(os.environ.get('VYNL_MODELS_DIR', Path.home() / '.vynl_models'))
|
| 31 |
MODELS_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
| 284 |
return str(manifest_path)
|
| 285 |
|
| 286 |
|
| 287 |
+
@spaces.GPU(duration=600)
|
| 288 |
def train_model(training_dir: Path, model_name: str, style_description: str,
|
| 289 |
base_model: str = "small", epochs: int = 10,
|
| 290 |
progress_callback=None) -> Tuple[Optional[str], str]:
|
| 291 |
"""
|
| 292 |
+
Fine-tune MusicGen on custom audio (GPU accelerated)
|
| 293 |
|
| 294 |
Note: Full fine-tuning requires significant GPU memory.
|
| 295 |
This uses a simplified approach with style conditioning.
|
|
|
|
| 418 |
# GENERATION
|
| 419 |
# ============================================================================
|
| 420 |
|
| 421 |
+
@spaces.GPU(duration=300)
|
| 422 |
def generate_music(prompt: str, model_choice: str, duration: int = 30,
|
| 423 |
temperature: float = 1.0, progress_callback=None) -> Tuple[Optional[str], str]:
|
| 424 |
"""
|
| 425 |
+
Generate music using MusicGen with optional custom style (GPU accelerated)
|
| 426 |
"""
|
| 427 |
if not HAS_AUDIOCRAFT:
|
| 428 |
return None, "AudioCraft not installed. Install with: pip install audiocraft"
|
|
|
|
| 513 |
return None, f"Generation error: {str(e)}"
|
| 514 |
|
| 515 |
|
| 516 |
+
@spaces.GPU(duration=300)
|
| 517 |
def generate_with_melody(prompt: str, melody_audio: str, model_choice: str,
|
| 518 |
duration: int = 30, progress_callback=None) -> Tuple[Optional[str], str]:
|
| 519 |
+
"""Generate music conditioned on a melody/reference audio (GPU accelerated)"""
|
| 520 |
if not HAS_AUDIOCRAFT or not HAS_LIBROSA:
|
| 521 |
return None, "AudioCraft and librosa required"
|
| 522 |
|
app.py
CHANGED
|
@@ -21,9 +21,11 @@ warnings.filterwarnings('ignore')
|
|
| 21 |
try:
|
| 22 |
import spaces
|
| 23 |
HAS_ZEROGPU = True
|
|
|
|
| 24 |
except ImportError:
|
| 25 |
HAS_ZEROGPU = False
|
| 26 |
-
|
|
|
|
| 27 |
class spaces:
|
| 28 |
@staticmethod
|
| 29 |
def GPU(duration=60):
|
|
@@ -31,6 +33,9 @@ except ImportError:
|
|
| 31 |
return func
|
| 32 |
return decorator
|
| 33 |
|
|
|
|
|
|
|
|
|
|
| 34 |
# ============================================================================
|
| 35 |
# MODULE IMPORTS
|
| 36 |
# ============================================================================
|
|
@@ -274,8 +279,9 @@ def download_youtube(url: str) -> tuple:
|
|
| 274 |
except Exception as e:
|
| 275 |
return None, str(e)
|
| 276 |
|
|
|
|
| 277 |
def separate_stems(audio_path: str, progress=None) -> dict:
|
| 278 |
-
"""Separate audio into stems using Demucs"""
|
| 279 |
try:
|
| 280 |
import subprocess
|
| 281 |
stems_dir = OUTPUT_DIR / f"stems_{datetime.now().strftime('%H%M%S')}"
|
|
@@ -284,6 +290,7 @@ def separate_stems(audio_path: str, progress=None) -> dict:
|
|
| 284 |
if progress:
|
| 285 |
progress(0.3, "Running Demucs stem separation...")
|
| 286 |
|
|
|
|
| 287 |
cmd = ['python', '-m', 'demucs', '-o', str(stems_dir), audio_path]
|
| 288 |
subprocess.run(cmd, capture_output=True, check=True)
|
| 289 |
|
|
@@ -411,8 +418,9 @@ def process_song(audio, yt_url, name, lyrics, do_stems, do_chords, do_daw, user_
|
|
| 411 |
# AI STUDIO FUNCTIONS
|
| 412 |
# ============================================================================
|
| 413 |
|
|
|
|
| 414 |
def generate_ai_music(prompt, genre, mood, key, bpm, time_sig, duration, instruments, temperature, user_email, progress=gr.Progress()):
|
| 415 |
-
"""Generate AI music with full parameters"""
|
| 416 |
if not HAS_AUDIOCRAFT:
|
| 417 |
return None, "AudioCraft not installed.\n\nThis feature requires a GPU-enabled environment.\n\nFor local installation with GPU:\npip install audiocraft xformers\npip install torch torchaudio --index-url https://download.pytorch.org/whl/cu118"
|
| 418 |
|
|
@@ -454,8 +462,9 @@ def generate_ai_music(prompt, genre, mood, key, bpm, time_sig, duration, instrum
|
|
| 454 |
|
| 455 |
return audio_path, status
|
| 456 |
|
|
|
|
| 457 |
def apply_voice_clone(audio, voice_model, pitch_shift, user_email, progress=gr.Progress()):
|
| 458 |
-
"""Apply voice cloning/conversion"""
|
| 459 |
if not audio:
|
| 460 |
return None, "Please provide audio"
|
| 461 |
|
|
|
|
| 21 |
try:
|
| 22 |
import spaces
|
| 23 |
HAS_ZEROGPU = True
|
| 24 |
+
print("ZeroGPU available - running on HuggingFace Spaces")
|
| 25 |
except ImportError:
|
| 26 |
HAS_ZEROGPU = False
|
| 27 |
+
print("ZeroGPU not available - running locally")
|
| 28 |
+
# Dummy decorator for local use
|
| 29 |
class spaces:
|
| 30 |
@staticmethod
|
| 31 |
def GPU(duration=60):
|
|
|
|
| 33 |
return func
|
| 34 |
return decorator
|
| 35 |
|
| 36 |
+
# Check if running on HuggingFace Spaces
|
| 37 |
+
IS_HF_SPACE = os.environ.get('SPACE_ID') is not None
|
| 38 |
+
|
| 39 |
# ============================================================================
|
| 40 |
# MODULE IMPORTS
|
| 41 |
# ============================================================================
|
|
|
|
| 279 |
except Exception as e:
|
| 280 |
return None, str(e)
|
| 281 |
|
| 282 |
+
@spaces.GPU(duration=120)
|
| 283 |
def separate_stems(audio_path: str, progress=None) -> dict:
|
| 284 |
+
"""Separate audio into stems using Demucs (GPU accelerated)"""
|
| 285 |
try:
|
| 286 |
import subprocess
|
| 287 |
stems_dir = OUTPUT_DIR / f"stems_{datetime.now().strftime('%H%M%S')}"
|
|
|
|
| 290 |
if progress:
|
| 291 |
progress(0.3, "Running Demucs stem separation...")
|
| 292 |
|
| 293 |
+
# Use GPU if available
|
| 294 |
cmd = ['python', '-m', 'demucs', '-o', str(stems_dir), audio_path]
|
| 295 |
subprocess.run(cmd, capture_output=True, check=True)
|
| 296 |
|
|
|
|
| 418 |
# AI STUDIO FUNCTIONS
|
| 419 |
# ============================================================================
|
| 420 |
|
| 421 |
+
@spaces.GPU(duration=300)
|
| 422 |
def generate_ai_music(prompt, genre, mood, key, bpm, time_sig, duration, instruments, temperature, user_email, progress=gr.Progress()):
|
| 423 |
+
"""Generate AI music with full parameters (GPU accelerated)"""
|
| 424 |
if not HAS_AUDIOCRAFT:
|
| 425 |
return None, "AudioCraft not installed.\n\nThis feature requires a GPU-enabled environment.\n\nFor local installation with GPU:\npip install audiocraft xformers\npip install torch torchaudio --index-url https://download.pytorch.org/whl/cu118"
|
| 426 |
|
|
|
|
| 462 |
|
| 463 |
return audio_path, status
|
| 464 |
|
| 465 |
+
@spaces.GPU(duration=120)
|
| 466 |
def apply_voice_clone(audio, voice_model, pitch_shift, user_email, progress=gr.Progress()):
|
| 467 |
+
"""Apply voice cloning/conversion (GPU accelerated)"""
|
| 468 |
if not audio:
|
| 469 |
return None, "Please provide audio"
|
| 470 |
|
local_config.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
VYNL Local Configuration
|
| 4 |
+
Environment detection and configuration for local vs HuggingFace deployment
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
import sys
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
# ============================================================================
|
| 12 |
+
# ENVIRONMENT DETECTION
|
| 13 |
+
# ============================================================================
|
| 14 |
+
|
| 15 |
+
def is_huggingface_space():
|
| 16 |
+
"""Check if running on HuggingFace Spaces"""
|
| 17 |
+
return os.environ.get('SPACE_ID') is not None
|
| 18 |
+
|
| 19 |
+
def is_gpu_available():
|
| 20 |
+
"""Check if GPU is available"""
|
| 21 |
+
try:
|
| 22 |
+
import torch
|
| 23 |
+
return torch.cuda.is_available()
|
| 24 |
+
except ImportError:
|
| 25 |
+
return False
|
| 26 |
+
|
| 27 |
+
def get_device():
|
| 28 |
+
"""Get the compute device"""
|
| 29 |
+
if is_gpu_available():
|
| 30 |
+
import torch
|
| 31 |
+
return torch.device('cuda')
|
| 32 |
+
return 'cpu'
|
| 33 |
+
|
| 34 |
+
# ============================================================================
|
| 35 |
+
# PATHS
|
| 36 |
+
# ============================================================================
|
| 37 |
+
|
| 38 |
+
def get_output_dir():
|
| 39 |
+
"""Get output directory"""
|
| 40 |
+
if is_huggingface_space():
|
| 41 |
+
import tempfile
|
| 42 |
+
return Path(tempfile.gettempdir()) / 'vynl_output'
|
| 43 |
+
else:
|
| 44 |
+
return Path(os.environ.get('VYNL_OUTPUT_DIR', Path.cwd() / 'output'))
|
| 45 |
+
|
| 46 |
+
def get_catalog_dir():
|
| 47 |
+
"""Get catalog directory"""
|
| 48 |
+
return Path(os.environ.get('VYNL_CATALOG_DIR', Path.home() / '.vynl_catalog'))
|
| 49 |
+
|
| 50 |
+
def get_models_dir():
|
| 51 |
+
"""Get models directory"""
|
| 52 |
+
return Path(os.environ.get('VYNL_MODELS_DIR', Path.home() / '.vynl_models'))
|
| 53 |
+
|
| 54 |
+
# ============================================================================
|
| 55 |
+
# CONFIGURATION
|
| 56 |
+
# ============================================================================
|
| 57 |
+
|
| 58 |
+
class Config:
|
| 59 |
+
"""VYNL Configuration"""
|
| 60 |
+
|
| 61 |
+
IS_HF_SPACE = is_huggingface_space()
|
| 62 |
+
HAS_GPU = is_gpu_available()
|
| 63 |
+
DEVICE = get_device()
|
| 64 |
+
|
| 65 |
+
OUTPUT_DIR = get_output_dir()
|
| 66 |
+
CATALOG_DIR = get_catalog_dir()
|
| 67 |
+
MODELS_DIR = get_models_dir()
|
| 68 |
+
|
| 69 |
+
# Create directories
|
| 70 |
+
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
| 71 |
+
CATALOG_DIR.mkdir(parents=True, exist_ok=True)
|
| 72 |
+
MODELS_DIR.mkdir(parents=True, exist_ok=True)
|
| 73 |
+
|
| 74 |
+
# Feature flags
|
| 75 |
+
ENABLE_AUDIOCRAFT = True
|
| 76 |
+
ENABLE_RVC = True
|
| 77 |
+
ENABLE_DEMUCS = True
|
| 78 |
+
|
| 79 |
+
# Generation limits
|
| 80 |
+
MAX_DURATION_SECONDS = 600 # 10 minutes
|
| 81 |
+
MAX_FILE_SIZE_MB = 100
|
| 82 |
+
|
| 83 |
+
@classmethod
|
| 84 |
+
def print_status(cls):
|
| 85 |
+
"""Print configuration status"""
|
| 86 |
+
print(f"VYNL Configuration:")
|
| 87 |
+
print(f" Environment: {'HuggingFace Space' if cls.IS_HF_SPACE else 'Local'}")
|
| 88 |
+
print(f" GPU Available: {cls.HAS_GPU}")
|
| 89 |
+
print(f" Device: {cls.DEVICE}")
|
| 90 |
+
print(f" Output Dir: {cls.OUTPUT_DIR}")
|
| 91 |
+
print(f" Catalog Dir: {cls.CATALOG_DIR}")
|
| 92 |
+
print(f" Models Dir: {cls.MODELS_DIR}")
|
| 93 |
+
|
| 94 |
+
if __name__ == "__main__":
|
| 95 |
+
Config.print_status()
|
requirements.txt
CHANGED
|
@@ -1,13 +1,15 @@
|
|
| 1 |
-
gradio=
|
| 2 |
-
huggingface_hub=
|
| 3 |
-
|
|
|
|
| 4 |
librosa>=0.10.0
|
| 5 |
soundfile>=0.12.0
|
| 6 |
scipy>=1.10.0
|
| 7 |
-
yt-dlp>=
|
| 8 |
-
torch>=2.
|
| 9 |
-
torchaudio>=2.
|
| 10 |
demucs>=4.0.0
|
| 11 |
pyloudnorm>=0.1.0
|
| 12 |
-
audiocraft
|
| 13 |
-
xformers
|
|
|
|
|
|
| 1 |
+
gradio>=4.44.0
|
| 2 |
+
huggingface_hub>=0.21.0
|
| 3 |
+
spaces>=0.30.0
|
| 4 |
+
numpy>=1.24.0,<2.0.0
|
| 5 |
librosa>=0.10.0
|
| 6 |
soundfile>=0.12.0
|
| 7 |
scipy>=1.10.0
|
| 8 |
+
yt-dlp>=2024.1.0
|
| 9 |
+
torch>=2.1.0
|
| 10 |
+
torchaudio>=2.1.0
|
| 11 |
demucs>=4.0.0
|
| 12 |
pyloudnorm>=0.1.0
|
| 13 |
+
audiocraft>=1.3.0
|
| 14 |
+
xformers>=0.0.23
|
| 15 |
+
accelerate>=0.25.0
|
start_vynl.bat
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
REM ============================================================================
|
| 3 |
+
REM VYNL - Complete Music Production Suite
|
| 4 |
+
REM Windows Startup Script
|
| 5 |
+
REM Copyright (c) 2024-2026 Robert T. Lackey. All rights reserved.
|
| 6 |
+
REM ============================================================================
|
| 7 |
+
|
| 8 |
+
title VYNL - Music Production Suite
|
| 9 |
+
|
| 10 |
+
echo.
|
| 11 |
+
echo ============================================================
|
| 12 |
+
echo VYNL - Complete Music Production Suite
|
| 13 |
+
echo Copyright (c) 2024-2026 Robert T. Lackey
|
| 14 |
+
echo Stone and Lantern Music Group
|
| 15 |
+
echo ============================================================
|
| 16 |
+
echo.
|
| 17 |
+
|
| 18 |
+
REM Check if Python is installed
|
| 19 |
+
python --version >nul 2>&1
|
| 20 |
+
if errorlevel 1 (
|
| 21 |
+
echo ERROR: Python is not installed or not in PATH
|
| 22 |
+
echo Please install Python 3.10 or higher from https://python.org
|
| 23 |
+
pause
|
| 24 |
+
exit /b 1
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
REM Check Python version
|
| 28 |
+
for /f "tokens=2" %%i in ('python --version 2^>^&1') do set PYVER=%%i
|
| 29 |
+
echo Found Python %PYVER%
|
| 30 |
+
|
| 31 |
+
REM Set up virtual environment
|
| 32 |
+
if not exist "venv" (
|
| 33 |
+
echo Creating virtual environment...
|
| 34 |
+
python -m venv venv
|
| 35 |
+
if errorlevel 1 (
|
| 36 |
+
echo ERROR: Failed to create virtual environment
|
| 37 |
+
pause
|
| 38 |
+
exit /b 1
|
| 39 |
+
)
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
REM Activate virtual environment
|
| 43 |
+
echo Activating virtual environment...
|
| 44 |
+
call venv\Scripts\activate.bat
|
| 45 |
+
|
| 46 |
+
REM Check if dependencies are installed
|
| 47 |
+
if not exist "venv\.installed" (
|
| 48 |
+
echo Installing dependencies (this may take several minutes)...
|
| 49 |
+
echo.
|
| 50 |
+
|
| 51 |
+
REM Upgrade pip first
|
| 52 |
+
python -m pip install --upgrade pip
|
| 53 |
+
|
| 54 |
+
REM Install PyTorch with CUDA support
|
| 55 |
+
echo Installing PyTorch with CUDA support...
|
| 56 |
+
pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu118
|
| 57 |
+
|
| 58 |
+
REM Install other requirements
|
| 59 |
+
echo Installing remaining dependencies...
|
| 60 |
+
pip install gradio>=4.44.0
|
| 61 |
+
pip install numpy>=1.24.0
|
| 62 |
+
pip install librosa>=0.10.0
|
| 63 |
+
pip install soundfile>=0.12.0
|
| 64 |
+
pip install scipy>=1.10.0
|
| 65 |
+
pip install yt-dlp>=2024.1.0
|
| 66 |
+
pip install demucs>=4.0.0
|
| 67 |
+
pip install pyloudnorm>=0.1.0
|
| 68 |
+
pip install audiocraft>=1.3.0
|
| 69 |
+
pip install xformers>=0.0.23
|
| 70 |
+
pip install accelerate>=0.25.0
|
| 71 |
+
|
| 72 |
+
REM Create marker file
|
| 73 |
+
echo. > venv\.installed
|
| 74 |
+
echo Dependencies installed successfully!
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
REM Check for NVIDIA GPU
|
| 78 |
+
nvidia-smi >nul 2>&1
|
| 79 |
+
if errorlevel 1 (
|
| 80 |
+
echo.
|
| 81 |
+
echo WARNING: NVIDIA GPU not detected or drivers not installed
|
| 82 |
+
echo VYNL will run on CPU (slower performance)
|
| 83 |
+
echo For best results, install NVIDIA drivers from https://nvidia.com/drivers
|
| 84 |
+
echo.
|
| 85 |
+
) else (
|
| 86 |
+
echo NVIDIA GPU detected - GPU acceleration enabled
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
REM Set environment variables
|
| 90 |
+
set VYNL_LOCAL=1
|
| 91 |
+
set VYNL_OUTPUT_DIR=%~dp0output
|
| 92 |
+
set VYNL_CATALOG_DIR=%USERPROFILE%\.vynl_catalog
|
| 93 |
+
set VYNL_MODELS_DIR=%USERPROFILE%\.vynl_models
|
| 94 |
+
|
| 95 |
+
REM Create output directory
|
| 96 |
+
if not exist "output" mkdir output
|
| 97 |
+
|
| 98 |
+
echo.
|
| 99 |
+
echo ============================================================
|
| 100 |
+
echo Starting VYNL...
|
| 101 |
+
echo Open http://localhost:7860 in your browser
|
| 102 |
+
echo Press Ctrl+C to stop the server
|
| 103 |
+
echo ============================================================
|
| 104 |
+
echo.
|
| 105 |
+
|
| 106 |
+
REM Start the application
|
| 107 |
+
python app.py
|
| 108 |
+
|
| 109 |
+
REM Deactivate on exit
|
| 110 |
+
call venv\Scripts\deactivate.bat
|
| 111 |
+
|
| 112 |
+
pause
|
vynl_generator.py
CHANGED
|
@@ -15,6 +15,19 @@ from typing import Optional, Tuple, List
|
|
| 15 |
import warnings
|
| 16 |
warnings.filterwarnings('ignore')
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# ============================================================================
|
| 19 |
# AUDIOCRAFT IMPORTS
|
| 20 |
# ============================================================================
|
|
@@ -361,6 +374,7 @@ def get_generator() -> MusicGenerator:
|
|
| 361 |
# HIGH-LEVEL API
|
| 362 |
# ============================================================================
|
| 363 |
|
|
|
|
| 364 |
def generate_song(
|
| 365 |
prompt: str = "",
|
| 366 |
genre: str = "",
|
|
@@ -376,7 +390,7 @@ def generate_song(
|
|
| 376 |
progress_callback=None
|
| 377 |
) -> Tuple[Optional[str], str]:
|
| 378 |
"""
|
| 379 |
-
High-level song generation API.
|
| 380 |
|
| 381 |
Args:
|
| 382 |
prompt: Custom text prompt
|
|
|
|
| 15 |
import warnings
|
| 16 |
warnings.filterwarnings('ignore')
|
| 17 |
|
| 18 |
+
# ZeroGPU support for HuggingFace Spaces
|
| 19 |
+
try:
|
| 20 |
+
import spaces
|
| 21 |
+
HAS_ZEROGPU = True
|
| 22 |
+
except ImportError:
|
| 23 |
+
HAS_ZEROGPU = False
|
| 24 |
+
class spaces:
|
| 25 |
+
@staticmethod
|
| 26 |
+
def GPU(duration=60):
|
| 27 |
+
def decorator(func):
|
| 28 |
+
return func
|
| 29 |
+
return decorator
|
| 30 |
+
|
| 31 |
# ============================================================================
|
| 32 |
# AUDIOCRAFT IMPORTS
|
| 33 |
# ============================================================================
|
|
|
|
| 374 |
# HIGH-LEVEL API
|
| 375 |
# ============================================================================
|
| 376 |
|
| 377 |
+
@spaces.GPU(duration=300)
|
| 378 |
def generate_song(
|
| 379 |
prompt: str = "",
|
| 380 |
genre: str = "",
|
|
|
|
| 390 |
progress_callback=None
|
| 391 |
) -> Tuple[Optional[str], str]:
|
| 392 |
"""
|
| 393 |
+
High-level song generation API (GPU accelerated).
|
| 394 |
|
| 395 |
Args:
|
| 396 |
prompt: Custom text prompt
|
vynl_rvc.py
CHANGED
|
@@ -17,6 +17,19 @@ from typing import Optional, Tuple, List, Dict
|
|
| 17 |
from datetime import datetime
|
| 18 |
import json
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# ============================================================================
|
| 21 |
# CONFIGURATION
|
| 22 |
# ============================================================================
|
|
@@ -282,6 +295,7 @@ PRESET_VOICES = {
|
|
| 282 |
# RVC INFERENCE
|
| 283 |
# ============================================================================
|
| 284 |
|
|
|
|
| 285 |
def convert_voice(
|
| 286 |
input_audio: str,
|
| 287 |
model_id: str = None,
|
|
@@ -296,7 +310,7 @@ def convert_voice(
|
|
| 296 |
progress_callback=None
|
| 297 |
) -> Tuple[Optional[str], str]:
|
| 298 |
"""
|
| 299 |
-
Convert voice using RVC model.
|
| 300 |
|
| 301 |
Args:
|
| 302 |
input_audio: Path to input audio file
|
|
@@ -401,6 +415,7 @@ def convert_voice(
|
|
| 401 |
# RVC TRAINING
|
| 402 |
# ============================================================================
|
| 403 |
|
|
|
|
| 404 |
def train_voice_model(
|
| 405 |
name: str,
|
| 406 |
training_files: List[str],
|
|
@@ -412,7 +427,7 @@ def train_voice_model(
|
|
| 412 |
progress_callback=None
|
| 413 |
) -> Tuple[Optional[str], str]:
|
| 414 |
"""
|
| 415 |
-
Train a custom RVC voice model.
|
| 416 |
|
| 417 |
Args:
|
| 418 |
name: Name for the voice model
|
|
|
|
| 17 |
from datetime import datetime
|
| 18 |
import json
|
| 19 |
|
| 20 |
+
# ZeroGPU support for HuggingFace Spaces
|
| 21 |
+
try:
|
| 22 |
+
import spaces
|
| 23 |
+
HAS_ZEROGPU = True
|
| 24 |
+
except ImportError:
|
| 25 |
+
HAS_ZEROGPU = False
|
| 26 |
+
class spaces:
|
| 27 |
+
@staticmethod
|
| 28 |
+
def GPU(duration=60):
|
| 29 |
+
def decorator(func):
|
| 30 |
+
return func
|
| 31 |
+
return decorator
|
| 32 |
+
|
| 33 |
# ============================================================================
|
| 34 |
# CONFIGURATION
|
| 35 |
# ============================================================================
|
|
|
|
| 295 |
# RVC INFERENCE
|
| 296 |
# ============================================================================
|
| 297 |
|
| 298 |
+
@spaces.GPU(duration=120)
|
| 299 |
def convert_voice(
|
| 300 |
input_audio: str,
|
| 301 |
model_id: str = None,
|
|
|
|
| 310 |
progress_callback=None
|
| 311 |
) -> Tuple[Optional[str], str]:
|
| 312 |
"""
|
| 313 |
+
Convert voice using RVC model (GPU accelerated).
|
| 314 |
|
| 315 |
Args:
|
| 316 |
input_audio: Path to input audio file
|
|
|
|
| 415 |
# RVC TRAINING
|
| 416 |
# ============================================================================
|
| 417 |
|
| 418 |
+
@spaces.GPU(duration=600)
|
| 419 |
def train_voice_model(
|
| 420 |
name: str,
|
| 421 |
training_files: List[str],
|
|
|
|
| 427 |
progress_callback=None
|
| 428 |
) -> Tuple[Optional[str], str]:
|
| 429 |
"""
|
| 430 |
+
Train a custom RVC voice model (GPU accelerated).
|
| 431 |
|
| 432 |
Args:
|
| 433 |
name: Name for the voice model
|