Picovoice Platform
Flutter Quick Start
Platforms
- Flutter (2.8.1+)
- Android (5.0+, API 21+)
- iOS (13.0+)
Requirements
- Flutter SDK
- Android SDK (21+)
- JDK (8+)
- Xcode (13+)
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
- Run the
prepare_demo
script with a language code to set up the demo in the language of your choice (e.g.de
-> German,ko
-> Korean). To see a list of available languages, runprepare_demo
without a language code.
Replace
{YOUR_ACCESS_KEY_HERE}
with a validAccessKey
in the demo/flutter/lib/main.dart file:Build and deploy the demo to your device:
For more information on our Picovoice demos for Flutter, head over to our GitHub repository.