Bat Spoken Language Identification
Android API
API Reference for the Bat Android SDK (bat-android)
package: ai.picovoice.bat
Bat
Class for the Bat Spoken Language Identification engine.
Bat must be initialized using the Builder() Class. Resources should be cleaned when you are done using the delete() function.
Bat.getAvailableDevices()
Lists all available devices that Bat can use for inference.
Each entry in the list can be used as the device argument when initializing Bat.
Returns
String[]: Array of all available devices thatBatcan be used for inference.
Throws
BatException: If an error occurs while getting available devices.
Bat.delete()
Releases resources acquired by Bat.
Bat.getFrameLength()
Getter for required number of audio samples per frame.
Returns
int: Required number of audio samples per frame.
Bat.getSampleRate()
Getter for required audio sample rate for PCM data.
Returns
int: Required audio sample rate for PCM data.
Bat.getVersion()
Getter for version.
Returns
String: CurrentBatversion.
Bat.process()
Processes given audio data and returns language detection scores.
Parameters
pcmshort[] : A frame of audio samples.
Returns
- HashMap<BatLanguages, Float>: Inferred Language detection scores.
Throws
BatException: If there is an error while processing.
Bat.Builder
Builder for creating an instance of Bat.
Bat.Builder.build()
Creates an instance of Bat Spoken Language Identification engine.
Parameters
contextContext : The Android app context.
Returns
Bat: An instance of Bat Spoken Language Identification engine.
Throws
BatException: If an error occurs while creating an instance of Bat Spoken Language Identification engine.
Bat.Builder.setAccessKey()
Sets the AccessKey of the builder.
Parameters
accessKeyString : AccessKey obtained from Picovoice Console.
Returns
Bat.Builder: Modified Bat.Builder object.
Bat.Builder.setModelPath()
Sets the model path of the builder.
Parameters
modelPathString : Path to the file containing model parameters (.pv). Can be either a path that is relative to the project'sassetsfolder or an absolute path to the file on device.
Returns
Bat.Builder: Modified Bat.Builder object.
Bat.Builder.setDevice()
Sets the device of the builder. If not set it will be set to the default device.
Parameters
deviceString : String representation of the device (e.g., CPU or GPU) to use. If set tobest, the most suitable device is selected automatically. If set togpu, the engine uses the first available GPU device. To select a specific GPU device, set this argument togpu:${GPU_INDEX}, where${GPU_INDEX}is the index of the target GPU. If set tocpu, the engine will run on the CPU with the default number of threads. To specify the number of threads, set this argument tocpu:${NUM_THREADS}, where${NUM_THREADS}is the desired number of threads.
Returns
Bat.Builder: Modified Bat.Builder object.
Bat.Builder.setVoiceThreshold()
Setter for the voice threshold. If not set it will be set to the default value.
Parameters
voiceThresholdfloat : Sensitivity threshold for detecting voice. The value should be a number within [0, 1]. A higher threshold increases detection confidence at the cost of potentially missing frames of voice.
Returns
Bat.Builder: Modified Bat.Builder object.
BatLanguages
Enum containing languages for the Bat Spoken Language Identification engine.
BatLanguages.numLanguages
Number of languages in BatLanguages.
BatLanguages.fromValue()
Returns an instance of BatLanguages given the integer value of the enumeration.
Parameters
_valueint : Enum integer value.
Returns
- BatLanguages: Corresponding
BatLanguagesenum.
BatException
Exception thrown if an error occurs within Bat Spoken Language Identification engine.
Exceptions: