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
Angular Quick Start


Platforms

  • Chrome & Chromium-based browsers
  • Edge
  • Firefox
  • Safari

Requirements

  • Picovoice Account and AccessKey
  • Node.js 14+
  • Angular 13+
  • npm

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 Node.js.

  2. Install the npm packages:

    • @picovoice/porcupine-angular
    • @picovoice/web-voice-processor
npm install @picovoice/porcupine-angular @picovoice/web-voice-processor

Usage

Put the model file in the project's public directory or generate a base64 model using the build in script:

npx pvbase64 -i ${PORCUPINE_PARAMS_PATH} -o ${OUTPUT_FILE_PATH}

Create a porcupineModel object with either of the methods above:

const PORCUPINE_MODEL_BASE64 = /* Base64 representation of the `.pv` model file*/;
const porcupineModel = {
publicPath: "${MODEL_RELATIVE_PATH}", // or
base64: PORCUPINE_MODEL_BASE64
}

Add the PorcupineService to an Angular component. Subscribe to the keywordDetection event for the built-in keywords porcupine and bumblebee:

import { Subscription } from "rxjs"
import { PorcupineService } from "@picovoice/porcupine-angular"
export class VoiceWidget {
private keywordSubscription: Subscription
constructor(private porcupineService: PorcupineService) {
this.keywordSubscription = porcupineService.keywordDetection$.subscribe(
porcupineDetection => {
console.log(`Porcupine Detected "${porcupineDetection.label}"`)
});
this.isLoadedSubscription = porcupineService.isLoaded$.subscribe(
isLoaded => {
console.log(isLoaded);
});
this.isListeningSubscription = porcupineService.isListening$.subscribe(
isListening => {
console.log(isListening);
});
this.errorSubscription = porcupineService.error$.subscribe(
error => {
console.error(error);
});
}
async ngOnInit() {
await this.porcupineService.init(
${ACCESS_KEY},
[BuiltInKeyword.Porcupine],
porcupineModel,
)
}
ngOnDestroy() {
this.keywordSubscription.unsubscribe();
this.isLoadedSubscription.unsubscribe();
this.isListeningSubscription.unsubscribe();
this.errorSubscription.unsubscribe();
this.porcupineService.release();
}
}

The PorcupineService will take care of microphone access and audio downsampling (via @picovoice/web-voice-processor).

Custom Keywords

Create custom keywords using the Picovoice Console. Train and download a Porcupine keyword model (.ppn) for the target platform Web (WASM). This model file can be used directly with publicPath, but, if base64 is preferable, convert the .ppn file to a base64 JavaScript variable using the built-in pvbase64 script:

npx pvbase64 -i ${KEYWORD_FILE}.ppn -o ${KEYWORD_BASE64}.js -n ${KEYWORD_BASE64_VAR_NAME}

Similar to the model file (.pv), keyword files (.ppn) are saved in IndexedDB to be used by Web Assembly. Either base64 or publicPath must be set for each keyword to instantiate Porcupine. If both are set, Porcupine will use the base64 model. An arbitrary label is required to identify the keyword once the detection occurs.

const keywordModel = {
publicPath: "${KEYWORD_RELATIVE_PATH}",
// or
base64: "${KEYWORD_BASE64_STRING}",
label: "${KEYWORD_LABEL}",
}

Then, initialize an instance of Porcupine:

await this.porcupineService.init(
"${ACCESS_KEY}",
[keywordModel],
porcupineModel,
);

Switching Languages

In order to use Porcupine with other languages, you need to use the corresponding model file (.pv) for the desired language. The model files for all supported languages are available on the Picovoice GitHub repository.

Demo

For the Porcupine Angular SDK, there is an Angular demo project available on the Porcupine GitHub repository.

Setup

Clone the Porcupine repository from GitHub:

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

Usage

  1. Install dependencies and run:
cd porcupine/demo/angular
npm install
npm run start
  1. Open http://localhost:4200 to view it in the browser.

Resources

Packages

  • @picovoice/porcupine-angular on the npm registry
  • @picovoice/porcupine-web on the npm registry
  • @picovoice/web-voice-processor on the npm registry

API

  • @picovoice/porcupine-angular API Docs

GitHub

  • Porcupine Angular SDK on GitHub
  • Porcupine Angular Demo on GitHub

Benchmark

  • Wake Word Benchmark

Further Reading

  • Voice-enabling an Angular App with Wake Words

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Porcupine Wake Word Angular Quick Start
  • Platforms
  • Requirements
  • Picovoice Account & AccessKey
  • Quick Start
  • Setup
  • Usage
  • Custom Keywords
  • Switching 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.