sandrohanea / whisper.net

Whisper.net. Speech to text made simple using Whisper Models
MIT License
534 stars 82 forks source link

Add Support For More Platforms (iOS, Mac Catalyst, tvOS, Android) #30

Closed drasticactions closed 1 year ago

drasticactions commented 1 year ago

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.

スクリーンショット 2023-04-30 19 49 09 スクリーンショット 2023-04-30 19 43 47

To do this, I need to make some changes in how the runtime drivers were loaded, and add some new scripts:

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

sandrohanea commented 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!

drasticactions commented 1 year ago

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.

sandrohanea commented 1 year ago

I can fix remaining warnings (marked as errors in CI) in future PR (They were there even before but only these workloads identified them).

drasticactions commented 1 year ago

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:

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.

sandrohanea commented 1 year ago

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.