Leopard - iOS API
API Reference for the iOS Leopard SDK (Cocoapod)
Leopard
public class Leopard { }
Class for the Leopard Speech-to-Text engine.
Resources should be cleaned when you are done using the delete()
function.
Leopard.init()
init
method for Leopard Speech-to-Text engine with a mixture of arguments.
public init(accessKey: String, modelPath: String) throws -> Leopard
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.modelPath
String : Absolute path to file containing model parameters (.pv
).
Throws
LeopardError
: If an error occurs while creating an instance of Leopard Speech-to-Text engine.
public init(accessKey: String, modelURL: URL) throws -> Leopard
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.modelURL
URL : URL to file containing model parameters (.pv
).
Throws
LeopardError
: If an error occurs while creating an instance of Leopard Speech-to-Text engine.
Leopard.delete()
Releases resources acquired by the Leopard engine.
public func delete()
Leopard.process()
Processes given audio data with the Leopard Speech-to-Text engine.
public func process(pcm: [Int16]) throws -> String
Parameters
pcm
[Int16] : The incoming audio needs to have a sample rate equal toLeopard.sampleRate
and be 16-bit linearly-encoded. Furthermore, Leopard operates on single-channel audio.
Returns
- String : Inferred transcription.
Throws
LeopardError
: If there is an error while processing the audio frame.
Leopard.processFile()
Processes a given audio file with the Leopard Speech-to-Text engine.
public func processFile(audioPath: String) throws -> String
Parameters
audioPath
String : Absolute path to the audio file. The file needs to have a sample rate equal to or greater thanLeopard.sampleRate
. The supported formats are:FLAC
,MP3
,Ogg
,Opus
,Vorbis
,WAV
, andWebM
.
Returns
- String : Inferred transcription.
Throws
LeopardError
: If there is an error while processing the audio frame.
Leopard.sampleRate
Leopard.sampleRate: UInt32
Audio sample rate accepted by Leopard.
Leopard.version
Leopard.version: String
Current Leopard version.
LeopardError
public class LeopardError : LocalizedError { }
Error thrown if an error occurs within Leopard Speech-to-Text engine.
public class LeopardMemoryError : LeopardError {}public class LeopardIOError : LeopardError {}public class LeopardInvalidArgumentError : LeopardError {}public class LeopardStopIterationError : LeopardError {}public class LeopardKeyError : LeopardError {}public class LeopardInvalidStateError : LeopardError {}public class LeopardRuntimeError : LeopardError {}public class LeopardActivationError : LeopardError {}public class LeopardActivationLimitError : LeopardError {}public class LeopardActivationThrottledError : LeopardError {}public class LeopardActivationRefusedError : LeopardError {}