-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
137 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
examples/bark.swiftui/bark.swiftui/Bindings/ProgressData.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// ProgressData.swift | ||
// bark.swiftui | ||
// | ||
// Created by Pierre-Antoine BANNIER on 10/05/2024. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
import bark | ||
|
||
class ProgressData: ObservableObject { | ||
static let shared = ProgressData() | ||
|
||
@Published var progress: Float = 0.0 | ||
@Published var stepTitle: String = "Progress..." | ||
|
||
private init() {} | ||
} | ||
|
||
func cCallbackBridge(bctx: OpaquePointer?, step: bark_encoding_step, progress: Int32, userData: UnsafeMutableRawPointer?) { | ||
DispatchQueue.main.async { | ||
let progressValue = Float(progress) / 100.0 | ||
var stepTitle: String | ||
|
||
switch step { | ||
case bark_encoding_step(rawValue: 0): | ||
stepTitle = "Semantic tokens (1/3)" | ||
case bark_encoding_step(rawValue: 1): | ||
stepTitle = "Coarse tokens (2/3)" | ||
default: | ||
stepTitle = "Fine tokens (3/3)" | ||
} | ||
|
||
// Update the shared observable object | ||
ProgressData.shared.progress = progressValue | ||
ProgressData.shared.stepTitle = stepTitle | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.