whisper.cpp/examples/whisper.wasm
Jhen-Jie Hong 0463028bc2
whisper : add context param to disable gpu (#1293)
* whisper : check state->ctx_metal not null

* whisper : add whisper_context_params { use_gpu }

* whisper : new API with params & deprecate old API

* examples : use no-gpu param && whisper_init_from_file_with_params

* whisper.objc : enable metal & disable on simulator

* whisper.swiftui, metal : enable metal & support load default.metallib

* whisper.android : use new API

* bindings : use new API

* addon.node : fix build & test

* bindings : updata java binding

* bindings : add missing whisper_context_default_params_by_ref WHISPER_API for java

* metal : use SWIFTPM_MODULE_BUNDLE for GGML_SWIFT and reuse library load

* metal : move bundle var into block

* metal : use SWIFT_PACKAGE instead of GGML_SWIFT

* style : minor updates

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
2023-11-06 11:04:24 +02:00
..
CMakeLists.txt whisper : add integer quantization support (#540) 2023-04-30 18:51:57 +03:00
README.md whisper : add memory sizes for Q8_0 (close #846) 2023-05-01 10:03:56 +03:00
emscripten.cpp whisper : add context param to disable gpu (#1293) 2023-11-06 11:04:24 +02:00
index-tmpl.html whisper : add integer quantization support (#540) 2023-04-30 18:51:57 +03:00

README.md

whisper.wasm

Inference of OpenAI's Whisper ASR model inside the browser

This example uses a WebAssembly (WASM) port of the whisper.cpp implementation of the transformer to run the inference inside a web page. The audio data does not leave your computer - it is processed locally on your machine. The performance is not great but you should be able to achieve x2 or x3 real-time for the tiny and base models on a modern CPU and browser (i.e. transcribe a 60 seconds audio in about ~20-30 seconds).

This WASM port utilizes WASM SIMD 128-bit intrinsics so you have to make sure that your browser supports them.

The example is capable of running all models up to size small inclusive. Beyond that, the memory requirements and performance are unsatisfactory. The implementation currently support only the Greedy sampling strategy. Both transcription and translation are supported.

Since the model data is quite big (74MB for the tiny model) you need to manually load the model into the web-page.

The example supports both loading audio from a file and recording audio from the microphone. The maximum length of the audio is limited to 120 seconds.

Live demo

Link: https://whisper.ggerganov.com

image

Build instructions

# build using Emscripten
git clone https://github.com/ggerganov/whisper.cpp
cd whisper.cpp
mkdir build-em && cd build-em
emcmake cmake ..
make -j

# copy the produced page to your HTTP path
cp bin/whisper.wasm/*    /path/to/html/
cp bin/libmain.worker.js /path/to/html/