Picovoice WordmarkPicovoice Console
Introduction
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSNodejsPythonRaspberry PiReact NativeRustWebWindows
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
FAQ
Introduction
AndroidCiOSLinuxmacOSPythonWebWindows
AndroidCiOSPythonWeb
SummaryOctopus Speech-to-IndexGoogle Speech-to-TextMozilla DeepSpeech
FAQ
Introduction
AndroidAngularArduinoBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaMicrocontrollerNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidAngularBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonlinuxmacOSNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidBeagleboneCiOSNvidia JetsonLinuxmacOSPythonRaspberry PiRustWebWindows
AndroidCiOSPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidAngularArduinoBeagleBoneC.NETFlutterlink to GoiOSJavaNvidia JetsonMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustUnityVueWeb
AndroidAngularCMicrocontroller.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
Picovoice SDK - FAQ
IntroductionSTM32F407G-DISC1 (Arm Cortex-M4)STM32F411E-DISCO (Arm Cortex-M4)STM32F769I-DISCO (Arm Cortex-M7)IMXRT1050-EVKB (Arm Cortex-M7)
FAQGlossary

Octopus Speech-to-Index
Android API


API Reference for the Android Octopus SDK (octopus-android)

package: ai.picovoice.octopus


Octopus

public class 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()

public void delete()

Releases resources acquired by Octopus.


Octopus.getPcmDataSampleRate()

public int getPcmDataSampleRate()

Getter for required audio sample rate for PCM data.

Returns

  • int: Required audio sample rate for PCM data.

Octopus.getVersion()

public String getVersion()

Getter for version.

Returns

  • String: Current Octopus version.

Octopus.indexAudioData()

public OctopusMetadata indexAudioData(short[] pcm) throws OctopusException

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()

public OctopusMetadata indexAudioFile(String path) throws OctopusException

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()

public HashMap<String, OctopusMatch[]> search(
OctopusMetadata metadata,
HashSet<String> phrases
) throws OctopusException

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

public static class Builder { }

Builder for creating an instance of Octopus with a mixture of default arguments.


Octopus.Builder.build()

public Octopus build(Context context) throws OctopusException

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()

public Octopus.Builder setAccessKey(String accessKey)

Sets the AccessKey of the builder.

Parameters

  • accessKey String : AccessKey provided by Picovoice Console.

Returns

  • Octopus.Builder: Modified Octopus.Builder object.

Octopus.Builder.setModelPath()

public Octopus.Builder setModelPath(String modelPath)

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's assets folder or an absolute path to the file on device.

Returns

  • Octopus.Builder: Modified Octopus.Builder object.

OctopusMetadata

public class OctopusMetadata {
public OctopusMetadata(byte[] metadataBytes) { }
}

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()

public byte[] getBytes()

Gets the metadata in the form of a byte array.

Returns

  • byte[]: The metadata in the form of a byte array.

OctopusMetadata.delete()

public void delete()

Releases resources acquired by OctopusMetadata.


OctopusMatch

public class OctopusMatch

Type which contains a search result from a call to .search().


OctopusMatch.getStartSec()

public float getStartSec()

Getter for the start of a match.

Returns

  • float: Start of the matched audio in seconds.

OctopusMatch.getEndSec()

public float getEndSec()

Getter for the end of a match.

Returns

  • float: End of the matched audio in seconds.

OctopusMatch.getProbability()

public float getProbability()

Getter for the probability (confidence) that this matches the search phrase.

Returns

  • float: Probability (confidence) of match in range [0, 1].

OctopusException

public class OctopusException extends Exception { }

Exception thrown if an error occurs within Octopus Speech-to-Index engine.

Exceptions:

public class OctopusActivationException extends OctopusException { }
public class OctopusActivationLimitException extends OctopusException { }
public class OctopusActivationRefusedException extends OctopusException { }
public class OctopusActivationThrottledException extends OctopusException { }
public class OctopusIOException extends OctopusException { }
public class OctopusInvalidArgumentException extends OctopusException { }
public class OctopusInvalidStateException extends OctopusException { }
public class OctopusKeyException extends OctopusException { }
public class OctopusMemoryException extends OctopusException { }
public class OctopusRuntimeException extends OctopusException { }
public class OctopusStopIterationException extends OctopusException { }

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Octopus Speech-to-Index Android API
  • Octopus
  • delete()
  • getPcmDataSampleRate()
  • getVersion()
  • indexAudioData()
  • indexAudioFile()
  • search()
  • Octopus.Builder
  • build()
  • setAccessKey()
  • setModelPath()
  • OctopusMetadata
  • getBytes()
  • delete()
  • OctopusMatch
  • getStartSec()
  • getEndSec()
  • getProbability()
  • OctopusException
Platform
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Octopus Speech-to-Index
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Resources
  • Docs
  • Console
  • Blog
  • Demos
Sales
  • Pricing
  • Starter Tier
  • Enterprise
Company
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • Twitter
  • Medium
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2022 Picovoice Inc.