Skip to content

tdtCtc110m failed to download ctcHeadModel in parakeet-ctc-110m #524

@Josscii

Description

@Josscii

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions