Picovoice Platform
Flutter Quick Start
Platforms
- Flutter (1.20.0+)
- Android (4.4+, API 19+)
- iOS (9.0+)
Requirements
- Flutter SDK
- Android SDK (16+)
- JDK (8+)
- Xcode (9+)
Picovoice Account & AccessKey
Signup or Login to Picovoice Console to get your AccessKey
.
Make sure to keep your AccessKey
secret.
Quick Start
Setup
Install Flutter SDK.
Run
flutter doctor
to determine any missing requirements.Add the Picovoice plugin to your app project by referencing it in
pubspec.yaml
:
- Enable the proper permission for recording with the hardware's microphone on both iOS and Android:
iOS
Open your Info.plist
and add the following line:
Android
Open your AndroidManifest.xml
and add the following line:
Usage
Add a Porcupine keyword file (
.ppn
) and a Rhino context file (.rhn
) to theassets
folder in the project directory.Add it to the
pubspec.yaml
:
- Create an instance of
PicovoiceManager
using the constructorPicovoiceManager.create()
that detects the wake word and infers intents from spoken commands:
Alternatively, if the model files are deployed to the device with a different method, the absolute paths to the files on device can be used.
The _wakeWordCallback
and _inferenceCallback
parameters are functions that are invoked when Porcupine detects the wake
word and Rhino makes an intent inference, respectively.
Start audio capture and processing:
Stop it when done with Picovoice:
Custom Wake Words & Contexts
Create custom wake words and contexts with the Picovoice Console.
Download the custom Porcupine keyword (
.ppn
) and Rhino context (.rhn
) files.Add them to the
pubspec.yaml
:
- Create an instance of
PicovoiceManager
using the constructorPicovoiceManager.create()
.
Non-English Languages
Use the corresponding model file (.pv
) to infer non-English wake words and contexts. The model files for all supported
languages are available on
the Porcupine GitHub repository
and Rhino GitHub repository.
- Add the model files to the
assets
folder in the project directory as well as keyword and context files. - Add it to the
pubspec.yaml
:
- Create an instance of
PicovoiceManager
using the constructorPicovoiceManager.create()
:
Alternatively, if the model files are deployed to the device with a different method, the absolute paths to the files on device can be used.
Demo
For the Picovoice Flutter SDK, we offer demo applications that demonstrate how to use the End-to-End Picovoice platform on real-time audio streams (i.e. microphone input).
Setup
Clone the Picovoice GitHub Repository:
Usage
Replace
{YOUR_ACCESS_KEY_HERE}
with a validAccessKey
in the demo/flutter/lib/main.dart file:Copy assets:
NOTE: on Windows, Git Bash or another bash shell is required, or you will have to manually copy
- The android keyword
into
${DEMO_FOLDER}/assets/keyword_files/android
. - The android context
into
${DEMO_FOLDER}/assets/contexts/android
. - The iOS keyword
into
${DEMO_FOLDER}/assets/keyword_files/ios
. - The iOS context
into
${DEMO_FOLDER}/assets/contexts/ios
.
- Build and deploy the demo to your device:
For more information on our Picovoice demos for Flutter, head over to our GitHub repository.
Resources
Package
API
GitHub
Benchmarks
Further Reading
Video