Octopus - Python API
API Reference for the Python Octopus SDK (PyPI).
pvoctopus.create()
def create(access_key: str,library_path: Optional[str] = None,model_path: Optional[str] = None) -> Octopus
Factory method for Octopus Speech-to-Index engine.
Parameters
access_key
str : AccessKey obtained from Picovoice Console.library_path
Optional[str] : Absolute path to Octopus's dynamic library.model_path
Optional[str] : Absolute path to the file containing model parameters.
Returns
Octopus
: An instance of Octopus Speech-to-Index engine.
Throws
pvoctopus.Octopus
class Octopus(object)
Class for the Octopus Speech-to-Index engine.
Octopus 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.
pvoctopus.Octopus.Match
Match = namedtuple('Match', ['start_sec', 'end_sec', 'probability'])
The type representing a matched search result.
pvoctopus.Octopus.version
self.version: str
The version string of the Octopus library.
pvoctopus.Octopus.pcm_sample_rate
self.pcm_sample_rate: int
Audio sample rate accepted by Octopus when processing PCM audio data.
pvoctopus.Octopus.__init__()
def __init__(self,access_key: str,library_path: str,model_path: str) -> Octopus
__init__
method for Octopus Speech-to-Index engine.
Parameters
access_key
str : AccessKey obtained from Picovoice Console.library_path
str : Absolute path to Octopus's dynamic library.model_path
str : Absolute path to the file containing model parameters.
Returns
Octopus
: An instance of Octopus Speech-to-Index engine.
Throws
pvoctopus.Octopus.delete()
def delete(self)
Releases resources acquired by Octopus.
pvoctopus.Octopus.index_audio_data()
def index_audio_data(self, pcm: List[int]) -> str
Indexes audio data. The audio needs to have a sample rate equal to .sample_rate
and be 16-bit linearly-encoded. This function operates on single-channel audio.
If you wish to process data in a different sample rate or format consider using .process_file()
.
Parameters
pcm
List[int] : Audio data.
Returns
OctopusMetadata
: An immutable metadata object.
Throws
pvoctopus.Octopus.index_audio_file()
def index_audio_file(self, path: str) -> str
Indexes audio file.
Parameters
audio_path
str : Absolute path to the audio file.
Returns
OctopusMetadata
: An immutable metadata object.
Throws
pvoctopus.Octopus.search()
def search(self, metadata: OctopusMetadata, phrases: List[str]) -> str
Searches metadata for occurrences of a given phrase.
Parameters
metadata
OctopusMetadata : Metadata object.phrases
List[str] : An iterable of phrases to search the index for.
Returns
Dict[str, [
Match
]]
: A dictionary map of found matches.
Throws
pvoctopus.OctopusMetadata
class OctopusMetadata(object)
Python representation of the metadata object.
pvoctopus.OctopusError
class OctopusError(Exception)
Error thrown if an error occurs within Octopus
Speech-to-Index engine.
Exceptions
class OctopusActivationError(OctopusError)class OctopusActivationLimitError(OctopusError)class OctopusActivationRefusedError(OctopusError)class OctopusActivationThrottledError(OctopusError)class OctopusIOError(OctopusError)class OctopusInvalidArgumentError(OctopusError)class OctopusInvalidStateError(OctopusError)class OctopusKeyError(OctopusError)class OctopusMemoryError(OctopusError)class OctopusRuntimeError(OctopusError)class OctopusStopIterationError(OctopusError)