Skip to main content

Offline Mode

Offline mode is designed for developers who don’t want or need any additional setup. It allows you to integrate voice controls without relying on any external services or backend configuration.

note

Offline mode sacrifices some transcription accuracy and speed for ease of use. If these are critical for your use case, use online mode

How to use

const voice = new AACVoiceAPI();

await voice.initiate({
mode: 'offline',
modelUrl: 'models/whisper-tiny.bin',
language: 'en'
});
ParametersTypeDescription
modestringTakes in a string of either 'offline' or 'online'
modelUrlstringTwo Options

Local Path such as models/whisper-tiny.bin
Remote URL such as https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny.bin
languagestringThe language that the model was trained in. Uses ISO 639-1 codes

All available models to use and download can be found here

Recommendation

For best real-time speech transcription use the ggml-tiny.bin model

If you would like to find out which mode is currently running during the game in case you have both options available to the user, use the command:

const voice = new AACVoiceAPI();

voice.getMode();

Returns a string containing the word 'online' or 'offline' depending on which one is currently running.

Server Settings Required

To use offline mode, your site must enable cross-origin isolation, which browsers require for features like SharedArrayBuffer.

For example, if yoiu were to use vite, the following code can be added to your vite.config:

  server: {
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
tip

If you do not have access to the server settings, then online exists as an alternative.