leopard_flutter 1.0.0 leopard_flutter: ^1.0.0 copied to clipboard
A Flutter plugin for Picovoice's Leopard Speech-to-Text engine
Leopard Binding for Flutter #
Leopard Speech-to-Text Engine #
Made in Vancouver, Canada by Picovoice
Leopard is an on-device speech-to-text engine. Leopard is:
- Private; All voice processing runs locally.
- Accurate [1]
- Compact and Computationally-Efficient [2]
- Cross-Platform:
- Linux (x86_64)
- macOS (x86_64, arm64)
- Windows (x86_64)
- Android
- iOS
- Raspberry Pi (4, 3)
- NVIDIA Jetson Nano
Compatibility #
This binding is for running Leopard on Flutter 1.20.0+ on the following platforms:
- Android 4.4+ (API 19+)
- iOS 9.0+
Installation #
To start, you must have the Flutter SDK installed on your system. Once installed, you can run flutter doctor
to determine any other missing requirements.
To add the Leopard plugin to your app project, you can reference it in your pub.yaml:
dependencies:
leopard_flutter: ^<version>
AccessKey #
The Leopard SDK requires a valid AccessKey
at initialization. AccessKey
s act as your credentials when using Leopard SDKs.
You can create your AccessKey
for free. Make sure to keep your AccessKey
secret.
To obtain your AccessKey
:
- Login or Signup for a free account on the Picovoice Console.
- Once logged in, go to the
AccessKey
tab to create one or use an existingAccessKey
.
Permissions #
To enable recording with the hardware's microphone, you must first ensure that you have enabled the proper permission on both iOS and Android.
On iOS, open your Info.plist and add the following line:
<key>NSMicrophoneUsageDescription</key>
<string>[Permission explanation]</string>
On Android, open your AndroidManifest.xml and add the following line:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
Leopard Model File Integration #
Add the Leopard model file to your Flutter application by:
- Either creating a model in Picovoice Console or using the default model in /lib/common/leopard_params.pv.
- Add the model file to an
assets
folder in your project directory. - Then add it to your
pubspec.yaml
:
flutter:
assets:
- assets/leopard_model.pv
- In this example, the path to the model file in code would then be as follows:
String modelPath = "assets/leopard_model.pv";
Usage #
An instance of Leopard
is created by passing a model file path into its static constructor create
:
import 'package:leopard_flutter/leopard.dart';
const accessKey = "{ACCESS_KEY}" // AccessKey obtained from Picovoice Console (https://picovoice.ai/console/)
void createLeopard() async {
try {
_leopard = await Leopard.create(accessKey, '{LEOPARD_MODEL_PATH}');
} on LeopardException catch (err) {
// handle Leopard init error
}
}
Transcribe an audio file by passing in the path:
try {
String transcript = = await _leopard.processFile("${AUDIO_FILE_PATH}");
} on LeopardException catch (err) { }
When done resources have to be released explicitly:
leopard.delete();
Demo App #
For example usage refer to our Flutter demo application.