Octopus Speech-to-Index
Android API
API Reference for the Android Octopus SDK (octopus-android)
package: ai.picovoice.octopus
Octopus
Class for the Octopus Speech-to-Index engine.
Octopus must be initialized using the Builder() Class. Resources should be cleaned when you are done using the delete()
function.
Octopus.delete()
Releases resources acquired by Octopus
.
Octopus.getPcmDataSampleRate()
Getter for required audio sample rate for PCM data.
Returns
int
: Required audio sample rate for PCM data.
Octopus.getVersion()
Getter for version.
Returns
String
: CurrentOctopus
version.
Octopus.indexAudioData()
Indexes given PCM audio data. The incoming audio needs to have a sample rate equal to .getSampleRate()
and be 16-bit linearly-encoded. Furthermore, Octopus
operates on single channel audio. If you wish to process data in a different sample rate or format consider using .indexAudioFile()
.
Parameters
pcm
short[] : An array of audio samples.
Returns
OctopusMetadata
: Octopus metadata object.
Throws
OctopusException
: if there is an error while processing the audio data.
Octopus.indexAudioFile()
Indexes an audio file.
Parameters
path
String : Absolute path to an audio file on device.
Returns
OctopusMetadata
: Octopus metadata object.
Throws
OctopusException
: if there is an error while processing the audio file.
Octopus.search()
Searches metadata for a given set of phrases.
Parameters
metadata
OctopusMetadata : Octopus metadata object returned from index.
Returns
HashMap<String, OctopusMatch[]>
: A map of phrases and match arrays. Matches are represented by immutable OctopusMatch objects.
Throws
OctopusException
: if there is an error while searching the metadata.
Octopus.Builder
Builder for creating an instance of Octopus
with a mixture of default arguments.
Octopus.Builder.build()
Creates an instance of Octopus
Speech-to-Index engine.
Parameters
context
Context : The Android app context.
Returns
Octopus
: An instance of Octopus Speech-to-Index engine.
Throws
OctopusException
: If an error occurs while creating an instance of Octopus Speech-to-Index engine.
Octopus.Builder.setAccessKey()
Sets the AccessKey of the builder.
Parameters
accessKey
String : AccessKey provided by Picovoice Console.
Returns
Octopus.Builder
: Modified Octopus.Builder object.
Octopus.Builder.setModelPath()
Sets the model path of the builder.
Parameters
modelPath
String : Path to the file containing model parameters (.pv
). Can be either a path that is relative to the project'sassets
folder or an absolute path to the file on device.
Returns
Octopus.Builder
: Modified Octopus.Builder object.
OctopusMetadata
Type which contains audio metadata to be searched against. The object can be serialized (via .getBytes()
) and deserialized (via constructor)) for reuse. Resources must explicitly be released by calling .delete()
.
Parameters
metadataBytes
byte[] : A byte array previously obtained via.getBytes()
.
OctopusMetadata.getBytes()
Gets the metadata in the form of a byte array.
Returns
byte[]
: The metadata in the form of a byte array.
OctopusMetadata.delete()
Releases resources acquired by OctopusMetadata.
OctopusMatch
Type which contains a search result from a call to .search()
.
OctopusMatch.getStartSec()
Getter for the start of a match.
Returns
float
: Start of the matched audio in seconds.
OctopusMatch.getEndSec()
Getter for the end of a match.
Returns
float
: End of the matched audio in seconds.
OctopusMatch.getProbability()
Getter for the probability (confidence) that this matches the search phrase.
Returns
float
: Probability (confidence) of match in range [0, 1].
OctopusException
Exception thrown if an error occurs within Octopus
Speech-to-Index engine.
Exceptions: