Octopus Speech-to-Index
Web API
API Reference for the Octopus Web SDK (octopus-web)
Octopus
Class for the Octopus Speech-to-Index engine.
Octopus.create()
Creates an instance of Octopus Speech-to-Index engine using .pv
file in public directory. The model size is large, hence it will try to use the existing one if it exists, otherwise saves the model in storage.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.model
OctopusModel : Octopus Model Options.options
OctopusOptions : Optional configuration arguments.
Returns
Octopus
: An instance of the Octopus engine.
Octopus.index()
Processes multiple frames of audio samples. The required sample rate can be retrieved from .sampleRate
. The audio needs to bit 16-bit linearly-encoded. Furthermore, the engine operates on single-channel audio.
Parameters
pcm
Int16Array : Audio data.
Returns
OctopusMetadata
: Octopus metadata object.
Octopus.search()
Searches metadata for a given search phrase.
Parameters
octopusMetadata
OctopusMetadata
: An octopus metadata object.searchPhrase
string : The text phrase to search the metadata (indexed audio) for.
Returns
OctopusMatch[]
: An array ofOctopusMatch
objects.
Octopus.release()
Releases resources acquired by the Octopus Web SDK.
Octopus.sampleRate
Audio sample rate accepted by Octopus.
Octopus.version
Octopus version string.
OctopusModel
Octopus model type.
base64
string: The model file (.pv
) in base64 string to initialize Octopus.publicPath
string: The model file (.pv
) path relative to the public directory.customWritePath
string : Custom path to save the model in storage. Set to a different name to use multiple models acrossoctopus
instances.forceWrite
boolean : Flag to overwrite the model in storage even if it exists.version
number : Version of the model file. Increment to update the model file in storage.
OctopusMetadata
OctopusMetadata
type.
buffer
Uint8Array : Buffer containingOctopusMetadata
information.
OctopusMatch
OctopusMatch type.
startSec
number : Start of the matched audio in seconds.endSec
number : End of the matched audio in seconds.probability
number : Probability (confidence) that this matches the search phrase (between 0 and 1).
OctopusWorker
A class for creating new instances of the OctopusWorker
.
OctopusWorker.fromBase64()
Creates a worker instance of the OctopusWorker
using a base64 string of the model file. The model size is large, hence it will try to use the existing one if it exists, otherwise saves the model in storage.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.modelBase64
string : The model in base64 string to initialize Octopus.options
OctopusOptions : Optional configuration arguments.
Returns
OctopusWorker
: An instance ofOctopusWorker
.
OctopusWorker.fromPublicDirectory()
Creates an instance of OctopusWorker
using '.pv' file in public directory. The model size is large, hence it will try to use the existing one if it exists, otherwise saves the model in storage.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.publicPath
string : The model path relative to the public directory.options
OctopusOptions : Optional configuration arguments.
Returns
OctopusWorker
: An instance ofOctopusWorker
.
OctopusWorker.index()
Processes multiple frames of audio samples. The required sample rate can be retrieved from .sampleRate
. The audio needs to bit 16-bit linearly-encoded. Furthermore, the engine operates on single-channel audio.
Parameters
pcm
Int16Array : Audio data.options
Object : Optional index arguments.options.transfer
boolean : Optional flag to indicate if the buffer should be transferred or not. If set to true, input buffer array will be transferred to the worker.options.transferCallback
(pcm: Int16Array) => void : Optional callback containing a new Int16Array with contents frompcm
. Use this callback to get the input pcm when using transfer.
Returns
OctopusMetadata
: Octopus metadata object.
OctopusWorker.search()
Searches metadata for a given search phrase.
Parameters
octopusMetadata
OctopusMetadata
: An octopus metadata object.searchPhrase
string : The text phrase to search the metadata (indexed audio) for.
Returns
OctopusMatch[]
: An array ofOctopusMatch
objects.
OctopusWorker.release()
Releases resources acquired by the Octopus Web SDK.
OctopusWorker.terminate()
Force terminates the instance of OctopusWorker
.
OctopusWorker.sampleRate
Audio sample rate accepted by Octopus.
OctopusWorker.version
Octopus version string.
OctopusOptions
Octopus optional configuration arguments.