Package ai.picovoice.octopus
Class Octopus
- java.lang.Object
-
- ai.picovoice.octopus.Octopus
-
public class Octopus extends java.lang.ObjectAndroid binding for Octopus Speech-to-Index engine. It transforms audio into searchable metadata.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOctopus.Builder
-
Constructor Summary
Constructors Constructor Description Octopus(java.lang.String accessKey, java.lang.String modelPath)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete()Releases resources acquired by Octopus.intgetPcmDataSampleRate()Getter for required audio sample rate for PCM data.java.lang.StringgetVersion()Getter for Octopus version.OctopusMetadataindexAudioData(short[] pcm)Indexes raw PCM data.OctopusMetadataindexAudioFile(java.lang.String path)Reads and indexes a given audio file.java.util.HashMap<java.lang.String,OctopusMatch[]>search(OctopusMetadata metadata, java.util.HashSet<java.lang.String> phrases)Searches metadata for a given set of phrases.
-
-
-
Constructor Detail
-
Octopus
public Octopus(java.lang.String accessKey, java.lang.String modelPath) throws OctopusExceptionConstructor.- Parameters:
accessKey- AccessKey obtained from Picovoice ConsolemodelPath- Absolute path to the file containing Octopus model parameters.*- Throws:
OctopusException- if there is an error while initializing Octopus.
-
-
Method Detail
-
delete
public void delete()
Releases resources acquired by Octopus.
-
indexAudioData
public OctopusMetadata indexAudioData(short[] pcm) throws OctopusException
Indexes raw PCM data.- Parameters:
pcm- An array of audio samples. The audio needs to have a sample rate equal togetPcmDataSampleRate()and be single-channel, 16-bit linearly-encoded.- Returns:
- OctopusMetadata object that is used to perform searches
- Throws:
OctopusException- if there is an error while processing the audio data.
-
indexAudioFile
public OctopusMetadata indexAudioFile(java.lang.String path) throws OctopusException
Reads and indexes a given audio file.- Parameters:
path- Absolute path to an audio file.- Returns:
- OctopusMetadata object that is used to perform searches
- Throws:
OctopusException- if there is an error while processing the audio data.
-
search
public java.util.HashMap<java.lang.String,OctopusMatch[]> search(OctopusMetadata metadata, java.util.HashSet<java.lang.String> phrases) throws OctopusException
Searches metadata for a given set of phrases.- Parameters:
metadata- An OctopusMetata object obtained viaindexAudioData(short[])orindexAudioFile(String).phrases- A set of phrases to search for in the metadata- Returns:
- a map of phrases and match arrays. Matches are represented by immutable OctopusMatch objects.
- Throws:
OctopusException- if there is an error while performing the search query.
-
getPcmDataSampleRate
public int getPcmDataSampleRate()
Getter for required audio sample rate for PCM data.- Returns:
- Required audio sample rate for PCM data.
-
getVersion
public java.lang.String getVersion()
Getter for Octopus version.- Returns:
- Octopus version.
-
-