-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add audio device selector to transcribe + take a stab at Delete/Retry models #54
Conversation
@@ -779,13 +812,35 @@ struct ContentView: View { | |||
try await whisperKit.loadModels() | |||
|
|||
await MainActor.run { | |||
if !localModels.contains(model) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local models doesnt refresh if you redownload a model after deleting without this
Nice idea with the delete and retry! This is probably a good time to handle canceling the previous download task in resetState() because it's a static method. As-is, if you are in the middle of a download and tap the restart button, the previous download will continue and a new one will start. It may require something like this: let downloadTask = Task {
folder = try await WhisperKit.download(variant: model, from: repoName, progressCallback: { progress in
DispatchQueue.main.async {
loadingProgressValue = Float(progress.fractionCompleted) * specializationProgressRatio
modelState = .downloading
}
// Check for cancellation here
try Task.checkCancellation()
})
} or something similar to how the progressbar task gets cancelled: let progressBarTask = Task {
await updateProgressBar(targetProgress: 0.9, maxTime: 240)
}
// Prewarm models
do {
try await whisperKit.prewarmModels()
progressBarTask.cancel()
} catch {
print("Error prewarming models, retrying: \(error.localizedDescription)")
progressBarTask.cancel()
if !redownload {
loadModel(model, redownload: true)
return
} else {
// Redownloading failed, error out
modelState = .unloaded
return
}
} What do you think? This would also solve a few edge cases with the model selection, like if you select a new model while the previous one is downloading. |
Also played around with the mic selector placement, what do you think of this setup? Added a PR to your repo: cgfarmer4#1 ![]() ![]() |
Adjust mic device picker location
Beautiful, merged your PR and will take a look at cancelling the download tonight. |
I removed the retry, getting downloads to cancel is going to require a larger refactor of this function.
Going for this path, you get an error that Then I tried this which fixes the warning:
Next approach I tried was assigning the main How about I leave in the delete + your update and call it on this one? The download cancellation needs a rethink or Im totally missing something. |
No problem! We can get to that later on, but this is a good addition as-is 👍 |
Addresses #13 + adds audio device view in both sections.