Spaces:
Running
on
Zero
Running
on
Zero
Gamahea
commited on
Commit
·
900e408
1
Parent(s):
5520c26
Deploy Music Generation Studio - 2025-12-12 17:35
Browse files- README.md +0 -1
- app.py +14 -0
- requirements.txt +2 -1
README.md
CHANGED
|
@@ -9,7 +9,6 @@ app_file: app.py
|
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
python_version: 3.11
|
| 12 |
-
suggested_hardware: cpu-basic
|
| 13 |
---
|
| 14 |
|
| 15 |
# 🎵 Music Generation Studio
|
|
|
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
python_version: 3.11
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
# 🎵 Music Generation Studio
|
app.py
CHANGED
|
@@ -10,6 +10,18 @@ from pathlib import Path
|
|
| 10 |
import shutil
|
| 11 |
import subprocess
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# Run DiffRhythm2 source setup if needed
|
| 14 |
setup_script = Path(__file__).parent / "setup_diffrhythm2_src.sh"
|
| 15 |
if setup_script.exists():
|
|
@@ -80,6 +92,7 @@ def get_lyricmind_service():
|
|
| 80 |
logger.info("LyricMind model loaded")
|
| 81 |
return lyricmind_service
|
| 82 |
|
|
|
|
| 83 |
def generate_lyrics(prompt: str, duration: int, progress=gr.Progress()):
|
| 84 |
"""Generate lyrics from prompt using analysis"""
|
| 85 |
try:
|
|
@@ -112,6 +125,7 @@ def generate_lyrics(prompt: str, duration: int, progress=gr.Progress()):
|
|
| 112 |
logger.error(f"Error generating lyrics: {e}", exc_info=True)
|
| 113 |
return f"❌ Error: {str(e)}"
|
| 114 |
|
|
|
|
| 115 |
def generate_music(prompt: str, lyrics: str, lyrics_mode: str, duration: int, position: str, progress=gr.Progress()):
|
| 116 |
"""Generate music clip and add to timeline"""
|
| 117 |
try:
|
|
|
|
| 10 |
import shutil
|
| 11 |
import subprocess
|
| 12 |
|
| 13 |
+
# Import spaces for ZeroGPU support
|
| 14 |
+
try:
|
| 15 |
+
import spaces
|
| 16 |
+
HAS_SPACES = True
|
| 17 |
+
except ImportError:
|
| 18 |
+
HAS_SPACES = False
|
| 19 |
+
# Create a dummy decorator for local development
|
| 20 |
+
class spaces:
|
| 21 |
+
@staticmethod
|
| 22 |
+
def GPU(func):
|
| 23 |
+
return func
|
| 24 |
+
|
| 25 |
# Run DiffRhythm2 source setup if needed
|
| 26 |
setup_script = Path(__file__).parent / "setup_diffrhythm2_src.sh"
|
| 27 |
if setup_script.exists():
|
|
|
|
| 92 |
logger.info("LyricMind model loaded")
|
| 93 |
return lyricmind_service
|
| 94 |
|
| 95 |
+
@spaces.GPU
|
| 96 |
def generate_lyrics(prompt: str, duration: int, progress=gr.Progress()):
|
| 97 |
"""Generate lyrics from prompt using analysis"""
|
| 98 |
try:
|
|
|
|
| 125 |
logger.error(f"Error generating lyrics: {e}", exc_info=True)
|
| 126 |
return f"❌ Error: {str(e)}"
|
| 127 |
|
| 128 |
+
@spaces.GPU
|
| 129 |
def generate_music(prompt: str, lyrics: str, lyrics_mode: str, duration: int, position: str, progress=gr.Progress()):
|
| 130 |
"""Generate music clip and add to timeline"""
|
| 131 |
try:
|
requirements.txt
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
# Core dependencies for HuggingFace Spaces deployment
|
| 2 |
gradio==4.44.0
|
|
|
|
| 3 |
numpy>=1.24.0,<2.0.0
|
| 4 |
scipy>=1.10.0
|
| 5 |
librosa>=0.10.0
|
|
@@ -7,7 +8,7 @@ soundfile>=0.12.0
|
|
| 7 |
pydantic>=2.0.0
|
| 8 |
pyyaml>=6.0
|
| 9 |
|
| 10 |
-
# PyTorch -
|
| 11 |
torch>=2.4.0,<2.5.0
|
| 12 |
torchaudio>=2.4.0,<2.5.0
|
| 13 |
|
|
|
|
| 1 |
# Core dependencies for HuggingFace Spaces deployment
|
| 2 |
gradio==4.44.0
|
| 3 |
+
spaces>=0.28.3
|
| 4 |
numpy>=1.24.0,<2.0.0
|
| 5 |
scipy>=1.10.0
|
| 6 |
librosa>=0.10.0
|
|
|
|
| 8 |
pydantic>=2.0.0
|
| 9 |
pyyaml>=6.0
|
| 10 |
|
| 11 |
+
# PyTorch - GPU mode for ZeroGPU
|
| 12 |
torch>=2.4.0,<2.5.0
|
| 13 |
torchaudio>=2.4.0,<2.5.0
|
| 14 |
|