/
/
/
1"""Smart Fades audio analysis provider."""
2
3from __future__ import annotations
4
5from typing import TYPE_CHECKING
6
7from music_assistant.helpers.util import verify_system_meets_requirements
8
9if TYPE_CHECKING:
10 from music_assistant_models.config_entries import ProviderConfig
11 from music_assistant_models.enums import ProviderFeature
12 from music_assistant_models.provider import ProviderManifest
13
14 from music_assistant.mass import MusicAssistant
15
16 from .provider import SmartFadesProvider
17
18SUPPORTED_FEATURES: set[ProviderFeature] = set()
19
20# Smart Fades runs on-device ML (torch) inference; gate it to capable hardware.
21# 4GB nominal, matching the Balanced buffer threshold (the minimum buffer smart crossfade
22# needs). The gate applies meets_memory_target()'s tolerance, so a genuine 4GB host (which
23# reports ~3.8GB after the kernel/firmware reservation) still passes.
24MIN_RAM_GB = 4.0
25MIN_CPU_CORES = 2
26
27
28async def setup(
29 mass: MusicAssistant,
30 manifest: ProviderManifest,
31 config: ProviderConfig,
32) -> SmartFadesProvider:
33 """Set up the Smart Fades provider."""
34 # Gate before importing the provider module so the heavy torch/beat_this stack is
35 # never imported on a host that does not meet the minimal requirements.
36 await verify_system_meets_requirements(
37 feature_name="Smart Fades",
38 min_memory_gb=MIN_RAM_GB,
39 min_cpu_cores=MIN_CPU_CORES,
40 require_ml_inference=True,
41 )
42 from .provider import SmartFadesProvider # noqa: PLC0415
43
44 return SmartFadesProvider(mass, manifest, config, SUPPORTED_FEATURES)
45