Fix sendable warning in whispercontext
This commit is contained in:
parent
04910a6dfb
commit
797d3da7ba
@ -104,19 +104,21 @@ actor WhisperContext {
|
||||
}
|
||||
|
||||
static func createContext(path: String) async throws -> WhisperContext {
|
||||
// Create the context in an isolated task
|
||||
return try await Task.detached {
|
||||
var params = whisper_context_default_params()
|
||||
#if targetEnvironment(simulator)
|
||||
params.use_gpu = false
|
||||
print("Running on the simulator, using CPU")
|
||||
#endif
|
||||
let context = whisper_init_from_file_with_params(path, params)
|
||||
if let context {
|
||||
return WhisperContext(context: context)
|
||||
} else {
|
||||
|
||||
guard let contextPtr = whisper_init_from_file_with_params(path, params) else {
|
||||
print("Couldn't load model at \(path)")
|
||||
throw WhisperError.couldNotInitializeContext
|
||||
}
|
||||
|
||||
// Create the actor instance directly in this task
|
||||
return WhisperContext(context: contextPtr)
|
||||
}.value
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user