Although the code says it is a beta feature, but when AsrManager try to load models for tdtCtc110m, it will always try to download ctcHeadModel from parakeet-ctc-110m hf repo, and the DownloadUtils has bug downloading specific model in some repo, it will download all the requiredModels of the model, not the modelnames it passed in.
|
// [Beta] Optionally load CTC head model for custom vocabulary. |
|
// Supports two paths: |
|
// v1: CtcHead.mlmodelc placed manually in the TDT model directory |
|
// v2: Auto-download from FluidInference/parakeet-ctc-110m-coreml HF repo |
|
var ctcHeadModel: MLModel? |
|
if version == .tdtCtc110m { |
|
// v1: Check local TDT model directory first |
|
let repoDir = repoPath(from: directory, version: version) |
|
let ctcHeadPath = repoDir.appendingPathComponent(Names.ctcHeadFile) |
|
if FileManager.default.fileExists(atPath: ctcHeadPath.path) { |
|
let ctcConfig = MLModelConfiguration() |
|
ctcConfig.computeUnits = config.computeUnits |
|
ctcHeadModel = try? MLModel(contentsOf: ctcHeadPath, configuration: ctcConfig) |
|
if ctcHeadModel != nil { |
|
logger.info("[Beta] Loaded CTC head model from local directory") |
|
} else { |
|
logger.warning("CTC head model found but failed to load: \(ctcHeadPath.path)") |
|
} |
|
} |
|
|
|
// v2: Fall back to downloading from parakeet-ctc-110m HF repo |
|
if ctcHeadModel == nil { |
|
do { |
|
let ctcModels = try await DownloadUtils.loadModels( |
|
.parakeetCtc110m, |
|
modelNames: [Names.ctcHeadFile], |
|
directory: parentDirectory, |
|
computeUnits: config.computeUnits, |
|
progressHandler: progressHandler |
|
) |
|
ctcHeadModel = ctcModels[Names.ctcHeadFile] |
|
if ctcHeadModel != nil { |
|
logger.info("[Beta] Loaded CTC head model from HF repo") |
|
} |
|
} catch { |
|
logger.warning("CTC head model not available: \(error.localizedDescription)") |
|
} |
|
} |
|
} |
|
let repoPath = directory.appendingPathComponent(repo.folderName) |
|
let requiredModels = ModelNames.getRequiredModelNames(for: repo, variant: variant) |
|
let allModelsExist = requiredModels.allSatisfy { model in |
|
let modelPath = repoPath.appendingPathComponent(model) |
|
return FileManager.default.fileExists(atPath: modelPath.path) |
|
} |
I believe this is not the desired hehavior.
Although the code says it is a beta feature, but when
AsrManagertry to load models fortdtCtc110m, it will always try to download ctcHeadModel fromparakeet-ctc-110mhf repo, and the DownloadUtils has bug downloading specific model in some repo, it will download all therequiredModelsof the model, not themodelnamesit passed in.FluidAudio/Sources/FluidAudio/ASR/Parakeet/SlidingWindow/TDT/AsrModels.swift
Lines 270 to 308 in 4ef33f0
FluidAudio/Sources/FluidAudio/DownloadUtils.swift
Lines 205 to 210 in 4ef33f0
I believe this is not the desired hehavior.