Bat Spoken Language Identification
Python API
API Reference for the Bat Python SDK (PyPI).
pvbat.create()
Factory method for Bat Spoken Language Identification engine.
Parameters
access_keystr : AccessKey obtained from Picovoice Console.model_pathOptional[str] : Absolute path to the file containing model parameters (.pv).deviceOptional[str] : 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.library_pathOptional[str] : Absolute path to Bat's dynamic library.voice_thresholdfloat : 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: An instance of Bat Spoken Language Identification engine.
Throws
pvbat.available_devices()
Lists all available devices that Bat can use for inference. Each entry in the list can be the device argument
of create() factory method or Bat constructor.
Parameters
library_pathOptional[str] : Absolute path to Bat's dynamic library. If not set it will be set to the default location.
Returns
- Sequence[str]: List of all available devices that Bat can use for inference.
Throws
pvbat.Bat
Class for the Bat Spoken Language Identification engine.
Bat can be initialized either using the module level create() function
or directly using the class __init__() method.
Resources should be cleaned when you are done using the delete() method.
pvbat.Bat.version
The version string of the Bat library.
pvbat.Bat.__init__()
__init__ method for Bat Spoken Language Identification engine.
Parameters
access_keystr : AccessKey obtained from Picovoice Console.model_pathstr : Absolute path to the file containing model parameters (.pv).devicestr : 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.voice_thresholdfloat : 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.library_pathstr : Absolute path to Bat's dynamic library.
Returns
Bat: An instance of Bat Spoken Language Identification engine.
Throws
pvbat.Bat.delete()
Releases resources acquired by Bat.
pvbat.Bat.process()
Processes a frame of audio and returns detection scores for each supported language.
Parameters
pcmSequence[int] : A frame of audio samples.
Returns
- Optional[Dict[BatLanguages, float]] : Dictionary of language to detection score. The scores are in the range [0, 1] with 1 being maximum confidence in a perfect match. If
Noneis returned, Bat did not detect usable voice in the frame.
Throws
pvbat.Bat.BatLanguages
Bat languages enum.
pvbat.list_hardware_devices()
Lists all available devices that Bat can use for inference. Each entry in the list can be the device argument
of create() factory method or Bat constructor.
Internal method. The higher level pvbat.available_devices() should be used instead.
Parameters
library_pathstr : Absolute path to Bat's dynamic library.
Returns
- Sequence[str]: List of all available devices that Bat can use for inference.
Throws
pvbat.BatError
Error thrown if an error occurs within Bat Spoken Language Identification engine.
Exceptions