Skip to content

Latest commit

 

History

History
53 lines (42 loc) · 1.07 KB

README.md

File metadata and controls

53 lines (42 loc) · 1.07 KB

vosk_flutter_plugin

Flutter plugin for Vosk speech recognition.

How to use

Configurations

Add this pro guard rules in ...android/app/proguard-rules.pro If the file does not exist create it.

-keep class com.sun.jna.* { *; }
-keepclassmembers class * extends com.sun.jna.* { public *; }

Add this plugin to pubspec.yaml

vosk_flutter_plugin:

Load and init model

ByteData modelZip = await rootBundle.load('assets/models/vosk-model-small-en-us-0.15.zip');
await VoskFlutterPlugin.initModel(modelZip);

Start recognition

VoskFlutterPlugin.start();

Stop recognition

VoskFlutterPlugin.stop();

Listen to results

StreamBuilder(
  stream: VoskFlutterPlugin.onPartial(),
  builder: (context, snapshot) => Text(snapshot.data.toString()),
),

StreamBuilder(
  stream: VoskFlutterPlugin.onResult(),
  builder: (context, snapshot) => Text(snapshot.data.toString()),
),

StreamBuilder(
  stream: VoskFlutterPlugin.onFinalResult(),
  builder: (context, snapshot) => Text(snapshot.data.toString()),
),