iosCobra - iOS Quick Start

Platforms

  • iOS (9.0+)

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 Xcode.

  2. Install CocoaPods

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

pod 'Cobra-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 the Cobra VAD engine:

import Cobra
do {
cobra = try Cobra(accessKey: "${ACCESS_KEY}")
} catch { }

Pass in frames of audio to the .process function:

func getNextAudioFrame() -> [Int16] {
return audioFrame;
}
while true {
do {
let voiceProbability = try cobra.process(getNextAudioFrame())
// take action based on the probability of voice
} catch { }
}

Release resources explicitly when done with Cobra:

cobra.delete()

Demo

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

Setup

Clone the Repository

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

Usage

  1. Install dependencies:
cd cobra/demo/ios/CobraDemo
pod install
  1. Replace let ACCESS_KEY = "${YOUR_ACCESS_KEY_HERE}" in the file ViewModel.swift with a valid AccessKey.

  2. Open the CobraDemo XCode project and run the demo.

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

Resources

Packages

API

GitHub

Benchmark

Further Reading


Issue with this doc? Please let us know.