Picovoice Cobra

repository·main·Indexed 42 days ago

https://github.com/picovoice/cobra

A highly-accurate and lightweight voice activity detection (VAD) engine designed for real-time audio processing. Cobra is an on-device, private, streaming engine that processes audio locally across multiple platforms, including Android, iOS, Node.js, Python, .NET, and Web.

Tokens
14.8K
Snippets
66
Records
89
Agent score
54%

What's inside Cobra

  1. Cobra Node.js Compatibility and Requirements

    main

    Requirements

    • Node.js Version: 18 or higher.

    Supported Platforms

    • Linux (x86_64)
    • macOS (x86_64, arm64)
    • Windows (x86_64, arm64)
    • Raspberry Pi (3, 4, 5)

    Engine Capabilities

    Cobra is an on-device, private, streaming voice activity detection engine that processes all audio locally.

  2. Configure the Android Demo with your AccessKey

    main

    To run the Android demo, you must provide your AccessKey in the source code. Locate the ACCESS_KEY variable within MainActivity.java and replace its value with your actual key before building the project.

    // In MainActivity.java
    String ACCESS_KEY = "YOUR_ACCESS_KEY_HERE";
  3. Install and run the cobra-web-demo

    main

    To run the local web demo for Cobra in a browser, follow these steps:

    1. Install dependencies using yarn or npm.
    2. Run the start script to launch a local web server.
    3. Open the URL provided in the terminal output (typically http://localhost:5000) in your browser.
    4. Wait for Cobra and the WebVoiceProcessor to initialize. Once ready, speaking will display voice probability on the screen.
    # Using yarn
    yarn
    yarn start
    
    # Using npm
    npm install
    npm run start
  4. Install Cobra for iOS

    main

    You can install the Cobra iOS binding using either Swift Package Manager (SPM) or CocoaPods.

    Swift Package Manager (SPM)

    Open your project's Package Dependencies in Xcode and add the following repository URL: https://github.com/Picovoice/cobra.git

    CocoaPods

    Add the following line to your Podfile:

    pod 'Cobra-iOS'
  5. Install Cobra for Android via Maven Central

    main

    To include Cobra in your Android project, first ensure that mavenCentral() is included in your top-level build.gradle file. Then, add the Cobra dependency to your app's build.gradle file using the following implementation line (replace ${version} with the desired version):

    dependencies {
        // ...
        implementation 'ai.picovoice:cobra-android:${version}'
    }
  6. Configure Microphone Permissions for Cobra

    main

    To allow Cobra to access the device microphone, you must add the NSMicrophoneUsageDescription key to your app's Info.plist file with a string explaining why the app needs microphone access.

    <key>NSMicrophoneUsageDescription</key>
    <string>[Permission explanation]</string>
  7. Run Web Cobra Demos

    main

    Navigate to demo/web and use yarn or npm to install dependencies and start the development server. Once running, access the demo at http://localhost:5000.

    yarn
    yarn start
    
    # OR
    
    npm install
    npm run start
  8. Run iOS Cobra Demos

    main
    Install the Cobra-iOS CocoaPod using pod install from the project directory. Replace the ACCESS_KEY in ViewModel.swift with your Picovoice AccessKey, then open the generated CobraDemo.xcworkspace in Xcode to run the application.
    pod install