iosLeopard - iOS Quick Start

Platforms

  • iOS (9.0+)

Requirements

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

  2. Install CocoaPods

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

pod 'Leopard-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>

Adding Leopard models

Add the Leopard model file in Xcode by:

  1. Either creating a model in Picovoice CAT Console or get the default model in /lib/common/leopard_params.pv.
  2. Add the model as a bundled resource by selecting Build Phases and adding it to Copy Bundle Resources step.

Usage

Create an instance of Leopard:

import Leopard
let accessKey = "${ACCESS_KEY}"
let modelPath = Bundle(for: type(of: self)).path(
forResource: "${LEOPARD_MODEL_FILE}",
ofType: "pv")!
do {
let leopard = Leopard(accessKey: accessKey, modelPath: modelPath)
} catch { }

Transcribe an audio file either by passing the absolute path or an url to the file:

do {
let audioPath = Bundle(for: type(of: self)).path(
forResource: "${AUDIO_FILE_NAME}",
ofType: "${AUDIO_FILE_EXTENSION}")
let transcript = leopard.process_file(audioPath);
} catch let error as LeopardError {
// handle error
} catch { }

Release resources explicitly when done with Leopard:

leopard.delete()

Demo

For the Leopard iOS SDK, we offer demo applications that demonstrate how to use the Speech-to-Text engine on audio recordings.

Setup

Clone the Leopard repository from GitHub using HTTPS:

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

Usage

  1. Install dependencies:
cd leopard/demo/ios/LeopardDemo
pod install
  1. Replace let accessKey = "${YOUR_ACCESS_KEY_HERE}" in the file ViewController.swift with a valid AccessKey.

  2. Open the LeopardDemo.xcworkspace and run the demo.

Resources

Packages

API

GitHub

Benchmark


Issue with this doc? Please let us know.