Porcupine Wake Word
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 Porcupine Wake Word 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
Create an instance of PorcupineManager
using the constructor PorcupineManager.fromKeywords
that detects the included
built-in wake words porcupine
and bumblebee
:
The _wakeWordCallback
parameter is a function that is invoked when Porcupine Wake Word detects the wake word:
Start audio capture and wake word detection:
Stop with:
Release resources explicitly when done with Porcupine:
Custom Keywords
- Create custom keywords using the Picovoice Console.
- Download the custom wake word file (
.ppn
). - Add the file to the
assets
folder in the project directory. - Add the relative path to the
pubspec.yaml
:
- Use the
PorcupineManager.fromKeywordPaths
static constructor and provide the paths to the.ppn
file(s):
Alternatively, if the keyword files are deployed to the device with a different method, the absolute paths to the files on device can be used.
Non-English Languages
Use the corresponding model file (.pv
) to detect non-English wake words.
The model files for all supported languages are available
on the Porcupine Wake Word GitHub repository.
- Add the file to the
assets
folder in the project directory. - Add it to the
pubspec.yaml
:
Pass in the model file using the modelPath
parameter to change the detection language:
Alternatively, if the model file is deployed to the device with a different method, the absolute path to the file on device can be used.
Demo
For the Porcupine Wake Word Flutter SDK, we offer demo applications that demonstrate how to use the Wake Word engine on real-time audio streams (i.e. microphone input).
Setup
Clone the Porcupine Wake Word 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 Porcupine Wake Word demos for Flutter, head over to our GitHub repository.