Fix sendable warning in whispercontext

This commit is contained in:
Beingpax 2025-03-06 17:37:23 +05:45
parent 04910a6dfb
commit 797d3da7ba

View File

@ -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
}