wasmCobra - Web Quick Start

Platforms

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

Requirements

Picovoice Account & AccessKey

  1. Login or signup for a free account on the Picovoice Console.
  2. Go to the AccessKey tab to create one or use an existing AccessKey. Be sure to keep your AccessKey secret.

Quick Start

Setup

  1. Install Node.js.

  2. Install the Web Voice Processor and Cobra Web Worker packages:

npm install @picovoice/cobra-web-worker @picovoice/web-voice-processor

Usage

Create an instance of CobraWorker:

import { CobraWorkerFactory } from "@picovoice/cobra-web-worker";
const callback = (voiceProbability) => {
// take action based on voice probability
}
let cobraWorker = await CobraWorkerFactory.create("${ACCESS_KEY}", callback);

Initialize and start the Web Voice Processor to pass audio to the Cobra engine:

import { WebVoiceProcessor } from "@picovoice/web-voice-processor"
const webVoiceProcessor = await WebVoiceProcessor.init({
engines: [cobraWorker]
});
webVoiceProcessor.start();

Release resources explicitly when done with Cobra:

webVoiceProcessor.release()
cobraWorker.sendMessage({command: "release"})

Demo

For the Cobra Web SDK, there is a Web demo project available on the Cobra GitHub repository.

Setup

Clone the Cobra repository from GitHub:

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

Usage

  1. Install dependencies and run:
cd cobra/demo/web
npm install
npm run start
  1. Open http://localhost:5000 to view it in the browser.

Resources

Packages

API

GitHub

Benchmark

Further Reading


Issue with this doc? Please let us know.