Octopus - iOS API
API Reference for the Octopus iOS SDK (Cocoapod)
Octopus
public class Octopus { }
Class for the Octopus Speech-to-Index engine.
Octopus.pcmDataSampleRate
Octopus.pcmDataSampleRate: Int
Required audio sample rate for PCM data
Octopus.version
Octopus.version: String
Octopus version
Octopus.init()
public init(accessKey: String, modelPath:String? = nil) throws
Constructor for the Octopus class
Parameters
accessKey
String : The AccessKey obtained from Picovoice Console.modelPath
String? : Absolute path to file containing model parameters (.pv
).
Throws
OctopusError
: If an error occurs while creating an instance of Octopus.
Octopus.delete()
public func delete()
Releases resources acquired by Octopus
.
Octopus.indexAudioData()
public func indexAudioData(pcm:[Int16]) throws -> OctopusMetadata
Parameters
pcm
[Int16] : An array of audio samples. The audio needs to have a sample rate equal topcmDataSampleRate
and be single-channel, 16-bit linearly-encoded.
Returns
OctopusMetadata
: OctopusMetadata object that is used to perform searches.
Throws
OctopusError
: If an error occurs while processing the pcm array.
Octopus.indexAudioFile()
public func indexAudioFile(path:String) throws -> OctopusMetadata
Parameters
path
String : Absolute path to an audio file. Supported formats are:FLAC
,MP3
,Ogg
,Opus
,Vorbis
,WAV
, andWebM
.
Returns
OctopusMetadata
: OctopusMetadata object that is used to perform searches.
Throws
OctopusError
: If an error occurs while processing the audio file.
Octopus.search()
public func search(metadata: OctopusMetadata, phrases:Set<String>) throws -> Dictionary<String, [OctopusMatch]>
Parameters
metadata
OctopusMetadata : AnOctopusMetadata
object obtained viaindexAudioData
orindexAudioFile
.phrases
Set<String> : A set of phrases to search for in the metadata.- Returns
Dictionary<String, [
OctopusMatch]>
: A dictionary of phrases and match arrays. Matches are represented by immutableOctopusMatch
objects.
Throws
OctopusError
: If an error occurs while processing the searching the metadata.
OctopusError
public enum OctopusError: Error { }
Error type thrown by the Octopus iOS SDK.
case OctopusOutOfMemoryError(_ message:String)case OctopusIOError(_ message:String)case OctopusInvalidArgumentError(_ message:String)case OctopusStopIterationError(_ message:String)case OctopusKeyError(_ message:String)case OctopusInvalidStateError(_ message:String)case OctopusRuntimeError(_ message:String)case OctopusActivationError(_ message:String)case OctopusActivationLimitError(_ message:String)case OctopusActivationThrottledError(_ message:String)case OctopusActivationRefusedError(_ message:String)case OctopusInternalError(_ message:String)
OctopusMatch
public struct OctopusMatch { }
The type representing a matched search result.
OctopusMatch.start
OctopusMatch.start: Float
Start time of match in seconds
OctopusMatch.end
OctopusMatch.end: Float
End time of match in seconds
OctopusMatch.probability
OctopusMatch.probability: Float
Probability of the match being correct (floating-point value between [0, 1]).
OctopusMetadata
public class OctopusMetadata { }
The class representing audio indexed by Octopus
. Returned by Octopus.indexAudioData
or Octopus.indexAudioFile
.
OctopusMetadata.init()
public init(metadataBytes:[UInt8])
Constructor.
Parameters
metadataBytes
[UInt8] : A byte array that was previously obtained viagetBytes
.
OctopusMetadata.delete()
public func delete()
Releases resources acquired by OctopusMetadata
.
OctopusMetadata.getBytes()
public func getBytes() throws -> [UInt8]
Gets a binary representation of the metadata.
Returns
[UInt8]
: A byte array of the metadata.
Throws
OctopusError
: If an error occurs while retrieving the metadata bytes.