Closed guygodin closed 1 year ago
Can you create a reproduction project of what you're trying to do?
My guess is you're only referencing the project from a netstandard or net-6.0/net7.0 project, and not a native one. You would need to reference it in your native project (As in, reference Whisper.net and Whisper.net.Runtime in your Android project) for the right TFM to take effect.
It is still producing the same exception when the Whisper.net and Whisper.net.Runtime packages are referenced in the native Android project. The exception thrown is:
System.IO.FileNotFoundException: 'Native Library not found in path /data/data/com.companyname.whispertest/files/.__override__/runtimes/linux-arm64/whisper.so. Verify you have have included the native Whisper library in your application, or install the default libraries with the Whisper.net.Runtime NuGet.'
I've attached a sample project that reproduces the issue WhisperTest.zip
@guygodin Ahhh, I see what you did.
This only supports net6+ projects; you're using Mono Android. That's why it defaults to the .NET Standard implementation since that's the baseline level for what you're targeting.
Update to the newest .NET Android (dotnet workload install android
and dotnet new android
) and it will work.
If you're hellbent on using Xamarin.Android instead, You should be able to do it. If you download the Whisper.net.Runtime nuget, extract the Android packages, link those to your project, and then set Bypass Loading to true (https://github.com/sandrohanea/whisper.net/blob/main/Whisper.net/LibraryLoader/NativeLibraryLoader.cs#L25) it should work.
Although, again, I would upgrade to .NET Android.
Ah got it, thanks for the insights. I'll look into bypass loading.
Just FYI, the bypassLoading argument isn't being picked up because it is assigned after trying to load:
https://github.com/sandrohanea/whisper.net/blob/main/Whisper.net/WhisperFactory.cs#L36
The NativeLibraryLoader uses conditional preprocessor directives (#if ANDROID) which are not being applied so the existing NuGet ends up trying to load the Linux arm64 library and fails. Might be wrong but I think looking for the platform at runtime would be the correct way of supporting the various platforms. Cheers!