Create (but do not load) a new MoonshineModel for inference.
A string (relative to Settings.BASE_ASSET_PATH) where the .onnx
model weights are located.
Creating a MoonshineModel has the side effect of setting the path to the onnxruntime-web
.wasm
to the Settings.BASE_ASSET_PATH
Tests the inference latency of the current environment.
(Optional) The number of samples to use for computing the benchmark
The average inference latency (in ms) over the number of samples taken.
Generate a transcription of the passed audio.
A Float32Array
containing raw audio samples from an audio source (e.g., a wav file, or a user's microphone)
A Promise<string>
that resolves with the generated transcription.
Returns the latency (in ms) of the most recent call to MoonshineModel.generate
A latency reading (in ms)
Returns whether or not the model weights have been loaded.
true
if the model is loaded, false
if not.
Returns whether or not the model is in the process of loading.
true
if the model is currently loading, false
if not.
Load the model weights.
This can be a somewhat long-running (in the tens of seconds) async operation, depending on the user's connection and your choice of model (tiny vs base). To avoid weird async problems that can occur with multiple calls to loadModel, we store and return a single Promise that resolves when the model is loaded.
Implements speech-to-text inferences with Moonshine models.