alphacep / vosk-flutter

Apache License 2.0
50 stars 30 forks source link

feat: plugin rework #3

Closed sergsavchuk closed 1 year ago

sergsavchuk commented 1 year ago

Hi there! Me and @EvgeniyVabishchevich reworked the plugin to make it more flexible and useful (sorry for making this PR so huge).

Motivation

I am using this plugin in my private project and I felt a lack of control over recognition when using it. There was also an unpleasant bug: the model was loaded in a separate thread on the Android side, so await VoskFlutterPlugin.initModel(modelZip); didn't wait for the model to load, and if you had started recognition immediately after that, you would have received an error.

Major changes

Bumped VOSK android lib version to 0.3.46

Added the ability to create and work with VOSK Models and Recognizers

Now you can create multiple recognizers, configure them and use them to recognize audio data.

Applied very_good_analysis

To keep the plugin's code readability and the overall code quality at a high level.

Added unit tests

Utility code that doesn't use platform calls are covered with unit tests

Added integration tests

To test the code that use platform calls I added integration tests that can be run on an android device or emulator.

Configured Github Actions

To check the style and formatting of the code, to run unit and integration tests on each pull request. There is also a badge in Readme.md which displays the status of the last worklow run: image

Minor changes

Further thoughts

FFI

This has already been mentioned in #2, but it would be great to use Dart FFI to interact with VOSK lib, as it's done in Java VOSK API via JNA. Maybe I'll try to do that somewhere in the future :smiley:.

Publishing

It will be great to publish the plugin to pub.dev to make it more accessible for developers. But it will take some effort on your part. If you would like to publish the package and will have time to do so, please feel free to contact me with any questions.

nshmyrev commented 1 year ago

Cool job done, thanks a lot! I'll publish coming days on pub.dev

Please let us know if you have other thoughts!

nshmyrev commented 1 year ago

I published https://pub.dev/packages/vosk_flutter but didn't test fully, thanks a lot again!

sergsavchuk commented 1 year ago

I published https://pub.dev/packages/vosk_flutter but didn't test fully, thanks a lot again!

:rocket: It looks great, you can actually transfer the package to a verified account associated with your domain(https://alphacephei.com/), more info about this here