alphacep / vosk-flutter

Apache License 2.0
50 stars 30 forks source link

Linux support #8

Closed sergsavchuk closed 1 year ago

sergsavchuk commented 1 year ago

image

How it works

Linux support is based on the use of the dart FFI. We generate dart bindings to native C functions from declarations in vosk_api.h using ffigen. Then we add the vosk lib binary to the list of libraries bundled with the application and load that binary using our custom CLI tool. And that's all, now we can call native C functions from the dart code.

CLI tool

Plugins CLI tool is responsible for loading the Vosk binaries(currently only for Linux). It has single command(install) with options generated from options.dart using build_cli.

Helpful resources

Github Actions

Other minor changes

Things to discuss

Vosk API header

Initially I've tried to add vosk-api as a submodule of the repository, but there is a bug in publish command, so I abandoned that idea and just put the vosk_api.h to the project by hand. Maybe there is better solution that I don't see.

Versioning

I've just bumped the plugin version to 0.3.47 according to the Dart community convention:

Although semantic versioning doesn’t promise any compatibility between versions prior to 1.0.0, the Dart community convention is to treat those versions semantically as well. The interpretation of each number is just shifted down one slot: going from 0.1.2 to 0.2.0 indicates a breaking change, going to 0.1.3 indicates a new feature, and going to 0.1.2+1 indicates a change that doesn’t affect the public API. For simplicity’s sake, avoid using + after the version reaches 1.0.0.

nshmyrev commented 1 year ago

Cool, thank you!

I've sent you a request to join repo with write permissions. It would be great if you could join!