Leopard - 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
Install Xcode.
Install CocoaPods
Import the Leopard iOS binding by adding the following line to
Podfile
:
pod 'Leopard-iOS'
- Run the following from the project directory:
pod install
- 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:
- Either creating a model in Picovoice CAT Console or get the default model in /lib/common/leopard_params.pv.
- 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 Leopardlet 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
- Install dependencies:
cd leopard/demo/ios/LeopardDemopod install
Replace
let accessKey = "${YOUR_ACCESS_KEY_HERE}"
in the file ViewController.swift with a validAccessKey
.Open the
LeopardDemo.xcworkspace
and run the demo.