Spaces:
Running
on
Zero
Running
on
Zero
Gamahea
commited on
Commit
·
4894d05
1
Parent(s):
1270cfb
Deploy Music Generation Studio - 2025-12-12 17:31
Browse files- .gitignore +1 -1
- backend/models/__init__.py +12 -0
- backend/models/schemas.py +58 -0
.gitignore
CHANGED
|
@@ -3,7 +3,7 @@ __pycache__/
|
|
| 3 |
*.pyo
|
| 4 |
.Python
|
| 5 |
*.log
|
| 6 |
-
models/
|
| 7 |
outputs/
|
| 8 |
logs/
|
| 9 |
.env
|
|
|
|
| 3 |
*.pyo
|
| 4 |
.Python
|
| 5 |
*.log
|
| 6 |
+
/models/
|
| 7 |
outputs/
|
| 8 |
logs/
|
| 9 |
.env
|
backend/models/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Models package"""
|
| 2 |
+
# Models are imported directly where needed
|
| 3 |
+
|
| 4 |
+
__all__ = [
|
| 5 |
+
'ClipPosition',
|
| 6 |
+
'ExportFormat',
|
| 7 |
+
'GenerationRequest',
|
| 8 |
+
'LyricsRequest',
|
| 9 |
+
'TimelineClip',
|
| 10 |
+
'ExportRequest'
|
| 11 |
+
]
|
| 12 |
+
|
backend/models/schemas.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Data models and schemas
|
| 3 |
+
"""
|
| 4 |
+
from enum import Enum
|
| 5 |
+
from typing import Optional
|
| 6 |
+
from pydantic import BaseModel, Field, validator
|
| 7 |
+
|
| 8 |
+
class ClipPosition(str, Enum):
|
| 9 |
+
"""Clip position on timeline"""
|
| 10 |
+
INTRO = "intro"
|
| 11 |
+
PREVIOUS = "previous"
|
| 12 |
+
NEXT = "next"
|
| 13 |
+
OUTRO = "outro"
|
| 14 |
+
|
| 15 |
+
class ExportFormat(str, Enum):
|
| 16 |
+
"""Export audio formats"""
|
| 17 |
+
WAV = "wav"
|
| 18 |
+
MP3 = "mp3"
|
| 19 |
+
FLAC = "flac"
|
| 20 |
+
|
| 21 |
+
class LyricsRequest(BaseModel):
|
| 22 |
+
"""Lyrics generation request schema"""
|
| 23 |
+
prompt: str = Field(..., min_length=1, description="Theme or description for lyrics")
|
| 24 |
+
style: Optional[str] = Field(None, description="Music style/genre")
|
| 25 |
+
duration: int = Field(30, ge=10, le=120, description="Duration in seconds (affects lyrics length)")
|
| 26 |
+
|
| 27 |
+
@validator('prompt')
|
| 28 |
+
def validate_prompt(cls, v):
|
| 29 |
+
if not v or not v.strip():
|
| 30 |
+
raise ValueError('Prompt cannot be empty')
|
| 31 |
+
return v.strip()
|
| 32 |
+
|
| 33 |
+
class GenerationRequest(BaseModel):
|
| 34 |
+
"""Music generation request schema"""
|
| 35 |
+
prompt: str = Field(..., min_length=1, description="Music generation prompt")
|
| 36 |
+
lyrics: Optional[str] = Field(None, description="Optional lyrics text for vocals")
|
| 37 |
+
duration: int = Field(30, ge=10, le=120, description="Clip duration in seconds")
|
| 38 |
+
|
| 39 |
+
@validator('prompt')
|
| 40 |
+
def validate_prompt(cls, v):
|
| 41 |
+
if not v or not v.strip():
|
| 42 |
+
raise ValueError('Prompt cannot be empty')
|
| 43 |
+
return v.strip()
|
| 44 |
+
|
| 45 |
+
class TimelineClip(BaseModel):
|
| 46 |
+
"""Timeline clip model"""
|
| 47 |
+
clip_id: str = Field(..., description="Unique clip identifier")
|
| 48 |
+
file_path: str = Field(..., description="Path to audio file")
|
| 49 |
+
duration: float = Field(..., ge=0, description="Clip duration in seconds")
|
| 50 |
+
timeline_position: int = Field(..., ge=0, description="Position in timeline")
|
| 51 |
+
start_time: float = Field(0, ge=0, description="Start time in final mix")
|
| 52 |
+
music_path: Optional[str] = Field(None, description="URL path to music file for playback")
|
| 53 |
+
|
| 54 |
+
class ExportRequest(BaseModel):
|
| 55 |
+
"""Export request schema"""
|
| 56 |
+
filename: Optional[str] = Field("output", description="Output filename")
|
| 57 |
+
format: ExportFormat = Field(ExportFormat.WAV, description="Export format")
|
| 58 |
+
normalize: bool = Field(True, description="Normalize audio levels")
|