NCKitModelLocator
Locates the bundled NCKit model and returns a filesystem path for NCKitProcessor.
API​
Swift
public enum NCKitModelLocator {
public static var defaultBundle: Bundle { get }
public static func modelTarGzURL(bundle: Bundle = defaultBundle) throws -> URL
}
Kotlin
object NCKitModelLocator {
@JvmStatic
fun modelFile(context: Context): File
/** Alias matching iOS `modelTarGzURL`. */
@JvmStatic
fun modelTarGzFile(context: Context): File
}
Usage​
Swift
import NCKit
let modelURL = try NCKitModelLocator.modelTarGzURL()
Kotlin
import com.fiveexceptions.nckit.NCKitModelLocator
val modelFile = NCKitModelLocator.modelFile(context)
Swift
// Optional: search a specific bundle first, then Bundle.main
let modelURL = try NCKitModelLocator.modelTarGzURL(bundle: .main)
Kotlin
// Thread-safe: concurrent first calls are serialised; later calls are instant
val modelFile = NCKitModelLocator.modelFile(applicationContext)
On Android the locator tries NCKit_model.dfn3, then NCKit_model.tar.gz, then the older DeepFilterNet3_onnx.dfn3. The first match is copied to cache/nckit_model.tar.gz.
Throws​
| Error | When |
|---|---|
NCKitError.missingModel / NCKitException.MissingModel | Model not found in bundle / AAR assets |