31 lines
749 B
Python
31 lines
749 B
Python
from abc import ABC, abstractmethod
|
|||
|
|
from dataclasses import dataclass
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass
|
||
|
|
class GenerationRequest:
|
||
|
|
prompt: str
|
||
|
|
mode: str # "instrumental" | "vocals"
|
||
|
|
lyrics: str | None
|
||
|
|
duration_seconds: int
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass
|
||
|
|
class GenerationResult:
|
||
|
|
audio_path: Path
|
||
|
|
duration_seconds: float
|
||
|
|
sample_rate: int
|
||
|
|
|
||
|
|
|
||
|
|
class MusicGenerationProvider(ABC):
|
||
|
|
"""Pluggable backend for turning a prompt (+ optional lyrics) into a song.
|
||
|
|
|
||
|
|
Swap implementations (mock, local model, remote GPU endpoint) without
|
||
|
|
touching the worker or API — the worker only depends on this interface.
|
||
|
|
"""
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
def generate(self, request: GenerationRequest, output_dir: Path) -> GenerationResult:
|
||
|
|
...
|