Class Octopus


  • public class Octopus
    extends java.lang.Object
    Android binding for Octopus Speech-to-Index engine. It transforms audio into searchable metadata.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Octopus.Builder  
    • Constructor Summary

      Constructors 
      Constructor Description
      Octopus​(java.lang.String accessKey, java.lang.String modelPath)
      Constructor.
    • Constructor Detail

      • Octopus

        public Octopus​(java.lang.String accessKey,
                       java.lang.String modelPath)
                throws OctopusException
        Constructor.
        Parameters:
        accessKey - AccessKey obtained from Picovoice Console
        modelPath - 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 to getPcmDataSampleRate() 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 via indexAudioData(short[]) or indexAudioFile(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.