Closed drasticactions closed 1 year ago
Hello @drasticactions, First, I want to thank you for this amazing contribution. I cloned it locally and check a few more cases but overall, it looks awesome 😎
Really great work!
In terms of your CI, I'm not sure if the NativeBuild
YAML works, but the Dotnet
one , the way I wrote it, will only compile under Windows and Mac, because the apple TFMs (net6.0-ios
, etc) are only supported there.
I introduced the TFMs because of the NativeMethods
class and DllImport
as it (AFAIK) requires the __Internal
name for linked libraries on iOS platforms. If there is another way to make that work, I could change it back to be netstandard2.0 and 2.1. The targets file should still work fine as that's on the users project rather than the library itself to put the files in the right place, and with the flags I have it should work.
I can fix remaining warnings (marked as errors in CI) in future PR (They were there even before but only these workloads identified them).
Thanks! For anyone reading this who wants to try it out now (As I'm not sure if you want to push a point release for this or wait for the next Whisper.cpp), you can create your own nugets with an updated version tag:
make nuget
nuget pack Whisper.net.Runtime.nuspec -Version $(VERSION) -OutputDirectory ./nupkgs
dotnet pack Whisper.net/Whisper.net.csproj -p:Version=$(VERSION) -o ./nupkgs -c Release
Replacing $(VERSION) with whatever you want to call it (Ex. 1.3.0.1).
Then you can install them locally, and update them to the newest version whenever that lands.
Thanks again for this capability!
I was thinking to create a preview version 1.4.0.0-preview1 in nuget, so it will be easier to try it out for everyone :)
Will wait for the whisper.cpp to release 1.4.0.0 in order to create 1.4.0.0 as stable version.
This PR makes a few under-the-hood changes to how the runtime drivers are loaded and run, enabling support for more platforms that
whisper.cpp
supports, including iOS, Catalyst, tvOS, and Android.To do this, I need to make some changes in how the runtime drivers were loaded, and add some new scripts:
runtime
folder. While the default Whisper drivers are compiled as dynamic libraries, they don't have to be. You can create static versions and link them in. Moreover, if you did compile a version for a different platform, like iOS, theNativeLibraryLoader
class would assume that it needs to load a driver and will throw since the platforms are not listed.__Internal
for iOS and Catalyst, as the library is already loaded and linked, and this name is required for it to work.Runtime
folder fromWhisper.net
and created a new nuget,Whisper.net.Runtime
, including a targets file and all the native libraries.net7.0
, etc), if you include the Runtime nuget, it will function like the original library and dump the desktop libraries into the runtime folder.Whisper.net.Runtime
directory.make apple
. This will build all of the runtime libraries and lipo them into smaller linked versions.make android
I have an example of the nuget in action at https://github.com/drasticactions/Drastic.Whisper/tree/main/samples and https://github.com/drasticactions/Drastic.Whisper/tree/main/nuget