pythonCobra - Python Quick Start

Platforms

  • Linux (x86_64)
  • macOS (x86_64, arm64)
  • Windows (x86_64)
  • BeagleBone
  • NVIDIA Jetson Nano
  • Raspberry Pi (Zero, 2, 3, 4)

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 Python 3.
  2. Install the pvcobra Python package using PIP:
pip3 install pvcobra

Usage

Create an instance of the Cobra VAD engine:

import pvcobra
cobra = pvcobra.create(access_key='${ACCESS_KEY}')

Pass in frames of audio to the .process function:

def get_next_audio_frame():
pass
while True:
audio_frame = get_next_audio_frame()
voice_probability = cobra.process(audio_frame)

Release resources explicitly when done with Cobra:

cobra.delete()

Demo

For the Cobra Python SDK, we offer demo applications that demonstrate how to use the VAD engine on real-time audio streams (i.e. microphone input) and audio files.

Setup

Install the pvcobrademo Python package using PIP:

pip3 install pvcobrademo

This package installs command-line utilities for the Cobra Python demos.

Usage

Use the --help flag to see the usage options for the demo:

cobra_demo_mic --help

Ensure you have a working microphone connected to your system and run the following command to detect voice activity:

cobra_demo_mic --access_key ${ACCESS_KEY}

For more information on our Cobra demos for Python, head over to our GitHub repository.

Resources

Packages

API

GitHub

Benchmark

Further Reading


Issue with this doc? Please let us know.