diff --git a/lib/models/whisper/whisper_isolate.dart b/lib/models/whisper/whisper_isolate.dart index d31b7e2..bea75b6 100644 --- a/lib/models/whisper/whisper_isolate.dart +++ b/lib/models/whisper/whisper_isolate.dart @@ -12,6 +12,7 @@ class WhisperIsolateMessage { final SendPort replyPort; final String modelPath; final String? ortDylibPathOverride; + final String? ortExtensionsDylibPathOverride; final List audioBytes; WhisperIsolateMessage({ @@ -19,6 +20,7 @@ class WhisperIsolateMessage { required this.modelPath, required this.audioBytes, this.ortDylibPathOverride, + this.ortExtensionsDylibPathOverride, }); } @@ -36,6 +38,10 @@ void whisperIsolateEntryPoint(SendPort mainSendPort) { if (message.ortDylibPathOverride != null) { fonnxOrtDylibPathOverride = message.ortDylibPathOverride; } + if (message.ortExtensionsDylibPathOverride != null) { + fonnxOrtExtensionsDylibPathOverride = + message.ortExtensionsDylibPathOverride; + } // Lazily create the Ort session if it's not already done. ortSessionObjects ??= createOrtSession(message.modelPath, includeOnnxExtensionsOps: true); @@ -109,6 +115,7 @@ class WhisperIsolateManager { String modelPath, List audioBytes, { String? ortDylibPathOverride, + String? ortExtensionsDylibPathOverride, }) async { await start(); final response = ReceivePort(); @@ -117,6 +124,7 @@ class WhisperIsolateManager { modelPath: modelPath, audioBytes: audioBytes, ortDylibPathOverride: ortDylibPathOverride, + ortExtensionsDylibPathOverride: ortExtensionsDylibPathOverride, ); _sendPort!.send(message); diff --git a/lib/models/whisper/whisper_native.dart b/lib/models/whisper/whisper_native.dart index 5f9a51f..7d821a4 100644 --- a/lib/models/whisper/whisper_native.dart +++ b/lib/models/whisper/whisper_native.dart @@ -20,7 +20,12 @@ class WhisperNative implements Whisper { Future doInference(List bytes) async { await _whisperIsolateManager.start(); if (!kIsWeb && Platform.environment['FLUTTER_TEST'] == 'true') { - return _whisperIsolateManager.sendInference(modelPath, bytes); + return _whisperIsolateManager.sendInference( + modelPath, + bytes, + ortDylibPathOverride: fonnxOrtDylibPathOverride, + ortExtensionsDylibPathOverride: fonnxOrtExtensionsDylibPathOverride, + ); } switch (defaultTargetPlatform) {