Skip to content

Commit

Permalink
Fix setupModels error handling (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
finnvoor committed Mar 19, 2024
1 parent 686bb26 commit bd75392
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Sources/WhisperKit/Core/WhisperKit.swift
Expand Up @@ -182,7 +182,7 @@ public class WhisperKit: Transcriber {
useBackgroundSession: Bool = false,
from repo: String = "argmaxinc/whisperkit-coreml",
progressCallback: ((Progress) -> Void)? = nil
) async throws -> URL? {
) async throws -> URL {
let hubApi = HubApi(downloadBase: downloadBase, useBackgroundSession: useBackgroundSession)
let repo = Hub.Repo(id: repo, type: .models)
do {
Expand All @@ -197,9 +197,8 @@ public class WhisperKit: Transcriber {
return modelFolderName
} catch {
Logging.debug(error)
throw error
}

return nil
}

/// Sets up the model folder either from a local path or by downloading from a repository.
Expand All @@ -219,13 +218,12 @@ public class WhisperKit: Transcriber {
} else if download {
let repo = modelRepo ?? "argmaxinc/whisperkit-coreml"
do {
let hubModelFolder = try await Self.download(
self.modelFolder = try await Self.download(
variant: modelVariant,
downloadBase: downloadBase,
useBackgroundSession: useBackgroundDownloadSession,
from: repo
)
self.modelFolder = hubModelFolder!
} catch {
// Handle errors related to model downloading
throw WhisperError.modelsUnavailable("""
Expand Down

0 comments on commit bd75392

Please sign in to comment.