AIModelRegistry

Global registry for AI model providers.

Allows apps to register model loaders once at startup, which are then automatically used by com.musicmuni.voxatrace.tona.PitchDetection and com.musicmuni.voxatrace.calibra.CalibraVAD factories when creating AI-based detectors.

Zero-Config Usage (Recommended)

After calling VT.initialize(), models are auto-loaded from bundled assets:

// At app startup
VT.initializeWithApiKey("api_key", context)

// Later, anywhere in the app - models auto-load from bundled assets
val detector = PitchDetection.createDetector(config)
val vad = CalibraVAD.create(VADModelProvider.speech())

Sideloading Custom Models

To use custom models instead of bundled ones, register providers:

// Override globally
AIModelRegistry.registerSwiftF0 { loadCustomPitchModel() }
AIModelRegistry.registerSpeechVAD { loadCustomSileroModel() }

// Or per-call (supported by factory methods)
val vad = CalibraVAD.create(VADModelProvider.speech { customLoader() })

Functions

Link copied to clipboard
fun clear()

Clear all registered providers (for testing).

Link copied to clipboard

Check if Singing VAD models are available (registered or bundled).

Link copied to clipboard

Check if Speech VAD model is available (registered or bundled).

Link copied to clipboard

Check if SwiftF0 model is available (registered or bundled).

Link copied to clipboard
fun registerSpeechVAD(provider: () -> ByteArray)

Register Speech VAD (Silero) model provider for automatic loading.

Link copied to clipboard
fun registerSwiftF0(provider: () -> ByteArray)

Register SwiftF0 model provider for automatic loading. Used by com.musicmuni.voxatrace.tona.PitchDetection and SingingRealtime VAD.