Picovoice WordmarkPicovoice Console
Introduction
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSNodejsPythonRaspberry PiReact NativeRustWebWindows
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
FAQ
Introduction
AndroidCiOSLinuxmacOSPythonWebWindows
AndroidCiOSPythonWeb
SummaryOctopus Speech-to-IndexGoogle Speech-to-TextMozilla DeepSpeech
FAQ
Introduction
AndroidAngularArduinoBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaMicrocontrollerNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidAngularBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonlinuxmacOSNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidBeagleboneCiOSNvidia JetsonLinuxmacOSPythonRaspberry PiRustWebWindows
AndroidCiOSPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidAngularArduinoBeagleBoneC.NETFlutterlink to GoiOSJavaNvidia JetsonMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustUnityVueWeb
AndroidAngularCMicrocontroller.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
Picovoice SDK - FAQ
IntroductionSTM32F407G-DISC1 (Arm Cortex-M4)STM32F411E-DISCO (Arm Cortex-M4)STM32F769I-DISCO (Arm Cortex-M7)IMXRT1050-EVKB (Arm Cortex-M7)
FAQGlossary

Porcupine Wake Word
iOS Quick Start


Platforms

  • iOS (9.0+)

Requirements

  • Xcode
  • CocoaPods

Picovoice Account & AccessKey

Signup or Login to Picovoice Console to get your AccessKey. Make sure to keep your AccessKey secret.

Quick Start

Setup

  1. Install Xcode.

  2. Install CocoaPods

  3. Import the Porcupine iOS binding by adding the following line to Podfile:

pod 'Porcupine-iOS'
  1. Run the following from the project directory:
pod install
  1. Add the following to the app's Info.plist file to enable recording with an iOS device's microphone
<key>NSMicrophoneUsageDescription</key>
<string>[Permission explanation]</string>

Usage

Create an instance of PorcupineManager that detects the included built-in wake words porcupine and bumblebee:

import Porcupine
do {
let porcupineManager = try PorcupineManager(
accessKey: "${ACCESS_KEY}",
keywords: [Porcupine.BuiltInKeyword.porcupine, Porcupine.BuiltInKeyword.bumblebee],
onDetection: wakeWordCallback)
} catch { }

The wakeWordCallback parameter is a function that will be invoked when Porcupine has detected one of the keywords.

let wakeWordCallback: ((Int32) -> Void) = { keywordIndex in
if keywordIndex == 0 {
// porcupine detected
} else if keywordIndex == 1 {
// bumblebee detected
}
}
}

Start audio capture and wake word detection:

do {
porcupineManager.start()
} catch { }

Stop audio capture and processing with:

porcupineManager.stop()

Release resources explicitly when done with Porcupine:

porcupineManager.delete()
To use your own audio processing pipeline, check out the Low-Level Porcupine API.

Custom Keywords

Create custom keywords using the Picovoice Console. Download the custom wake word file (.ppn) and include it in the app as a bundled resource (found by selecting in Build Phases > Copy Bundle Resources). Then, get its path from the app bundle:

let keywordPath = Bundle.main.path(forResource: "${CUSTOM_KEYWORD}", ofType: "ppn")

And create an instance of PorcupineManager that detects the custom keyword:

do {
let porcupineManager = try PorcupineManager(
accessKey: "${ACCESS_KEY}",
keywordPath: keywordPath,
onDetection: wakeWordCallback)
} catch { }

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 GitHub repository.

Pass in the model file using the modelPath input argument to change the detection language:

let modelPath = Bundle.main.path(forResource: "${MODEL_FILE}", ofType: "pv")
do {
let porcupineManager = try PorcupineManager(
accessKey: "${ACCESS_KEY}",
keywordPath: keywordPath,
modelPath: modelPath,
onDetection: wakeWordCallback)
} catch { }

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 iOS 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 Repository:

git clone --recurse-submodules https://github.com/Picovoice/porcupine.git

Usage

  1. Install dependencies:
cd porcupine/demo/ios/ForegroundApp
pod install
  1. Replace let accessKey = "${YOUR_ACCESS_KEY_HERE}" in the file ViewController.swift with a valid AccessKey.

  2. Open the PorcupineForegroundAppDemo.xcworkspace and run the demo.

The demo detects the chosen keyword only when the application is in focus. To see an example of Porcupine in a background service, head over to our Github repository.

Resources

Package

  • Porcupine-iOS on Cocoapods

API

  • Porcupine-iOS API Docs

GitHub

  • Porcupine iOS SDK on GitHub
  • Porcupine iOS Demos on GitHub

Benchmark

  • Wake Word Benchmark

Further Reading

  • Siri Gets a Barista Job: Adding Offline Voice AI to a SwiftUI App

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Porcupine Wake Word iOS Quick Start
  • Platforms
  • Requirements
  • Picovoice Account & AccessKey
  • Quick Start
  • Setup
  • Usage
  • Custom Keywords
  • Non-English Languages
  • Demo
  • Setup
  • Usage
  • Resources
Platform
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Octopus Speech-to-Index
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Resources
  • Docs
  • Console
  • Blog
  • Demos
Sales
  • Pricing
  • Starter Tier
  • Enterprise
Company
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • Twitter
  • Medium
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2022 Picovoice Inc.