From 2846fd95523c5d1a270b741db9849a31322dcf12 Mon Sep 17 00:00:00 2001 From: ZachNagengast Date: Wed, 28 Feb 2024 12:14:06 -0800 Subject: [PATCH] Update download logic for example app --- Examples/WhisperAX/WhisperAX.xcodeproj/project.pbxproj | 4 ++-- .../xcshareddata/swiftpm/Package.resolved | 3 ++- Examples/WhisperAX/WhisperAX/Views/ContentView.swift | 10 ++++++---- Sources/WhisperKit/Core/WhisperKit.swift | 4 +++- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Examples/WhisperAX/WhisperAX.xcodeproj/project.pbxproj b/Examples/WhisperAX/WhisperAX.xcodeproj/project.pbxproj index 3a1596c..4a4d4bc 100644 --- a/Examples/WhisperAX/WhisperAX.xcodeproj/project.pbxproj +++ b/Examples/WhisperAX/WhisperAX.xcodeproj/project.pbxproj @@ -866,7 +866,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 14.0; - MARKETING_VERSION = 0.1.0; + MARKETING_VERSION = 0.1.1; PRODUCT_BUNDLE_IDENTIFIER = com.argmax.whisperkit.WhisperAX; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; @@ -909,7 +909,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 14.0; - MARKETING_VERSION = 0.1.0; + MARKETING_VERSION = 0.1.1; PRODUCT_BUNDLE_IDENTIFIER = com.argmax.whisperkit.WhisperAX; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; diff --git a/Examples/WhisperAX/WhisperAX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Examples/WhisperAX/WhisperAX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d611531..307759d 100644 --- a/Examples/WhisperAX/WhisperAX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Examples/WhisperAX/WhisperAX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,7 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/huggingface/swift-transformers.git", "state" : { - "revision" : "564442fba36b0b694d730a62d0593e5f54043b55" + "revision" : "564442fba36b0b694d730a62d0593e5f54043b55", + "version" : "0.1.2" } } ], diff --git a/Examples/WhisperAX/WhisperAX/Views/ContentView.swift b/Examples/WhisperAX/WhisperAX/Views/ContentView.swift index 0abc80a..e4648cf 100644 --- a/Examples/WhisperAX/WhisperAX/Views/ContentView.swift +++ b/Examples/WhisperAX/WhisperAX/Views/ContentView.swift @@ -151,10 +151,6 @@ struct ContentView: View { }) } .onAppear { - Task { - whisperKit = try await WhisperKit(verbose: true, logLevel: .debug) - } - #if os(macOS) selectedCategoryId = menu.first(where: { $0.name == selectedTab })?.id #endif @@ -713,6 +709,12 @@ struct ContentView: View { } }) } + + await MainActor.run { + loadingProgressValue = specializationProgressRatio + modelState = .downloaded + } + if let modelFolder = folder { whisperKit.modelFolder = modelFolder diff --git a/Sources/WhisperKit/Core/WhisperKit.swift b/Sources/WhisperKit/Core/WhisperKit.swift index 171a161..f257cdd 100644 --- a/Sources/WhisperKit/Core/WhisperKit.swift +++ b/Sources/WhisperKit/Core/WhisperKit.swift @@ -163,7 +163,9 @@ public class WhisperKit: Transcriber { do { let modelFolder = try await hubApi.snapshot(from: repo, matching: ["*\(variant.description)/*"]) { progress in Logging.debug(progress) - progressCallback?(progress) + if let callback = progressCallback { + callback(progress) + } } let modelFolderName = modelFolder.appending(path: "openai_whisper-\(variant)")