Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Module not loading (whisper.wasm) #88

Closed
erkkimon opened this issue Oct 25, 2022 · 5 comments
Closed

[Bug] Module not loading (whisper.wasm) #88

erkkimon opened this issue Oct 25, 2022 · 5 comments

Comments

@erkkimon
Copy link

ERROR
I get two errors out of the whisper.wasm when running locally an instance compiled myself: "Uncaught TypeError: Module.FS_createDataFile is not a function at reader.onload (index.html:280:28)" and "Uncaught TypeError: Module.init is not a function at onProcess (index.html:449:39) at HTMLButtonElement.onclick (index.html:157:61)". The problem seems to lie in loading Module but I couldn't figure out how to fix it.

REPRODUCTION & SYMPTOMS
I compiled the web version using Mac OS X Monterey 12.6. All went fine with the compilation. Then I copied index.html, whisper.js and libwhisper.worker.js in same folder. All files are in the root of the same folder. But when I I choose file for Model or Audio file inputs, I get the errors mentioned above (and in the screenshot). Is this a potential bug or am I doing something wrong?

DIAGNOSABLE
module-error

@erkkimon erkkimon changed the title [Bug] [Bug] Module not loading (whisper.wasm) Oct 25, 2022
@ggerganov
Copy link
Owner

ggerganov commented Oct 25, 2022

In general, it is a bit tricky to run multi-threaded WebAssembly code nowadays. In short, sometime in 2018 it was decided to disable shared memory in the browser due to Spectre attack [0, see section "Security Requirements"]. Later, it became possible to use shared memory again, but your http server has to provide CORS response headers when serving the page.

For my WebAssembly projects, I have an NGINX server configured to serve the correct headers and have been using it ever since:

server {
    listen              443 ssl;
    server_name         whisper.ggerganov.com;

    client_max_body_size 10M;
    large_client_header_buffers 4 512k;

    ssl_certificate     /etc/letsencrypt/live/ggerganov.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/ggerganov.com/privkey.pem;

    add_header Cross-Origin-Embedder-Policy 'require-corp' always;
    add_header Cross-Origin-Opener-Policy   'same-origin' always;

    root                /var/www/html/whisper;
    index               index.html;
}

I haven't tried to make it work on localhost, but a quick google search suggests the following solution:

https://stackoverflow.com/questions/70535752/enable-sharedarraybuffer-on-localhost

Maybe you can give it a try and see if it helps.

@erkkimon
Copy link
Author

I got it, thanks! I will try to work around this in localhost for the sake of science, but usually HTML is sitting on a server anyway and it's not a problem to run a local server in any case. Good to know that this is kind of s CORS issue/feature so I know where to look into.

@hbarnard
Copy link

Thanks for whisper.cpp, using it successfully on command line. Now trying web stream, compiles successfully, apparently.
But I have this (same?) problem on Linux Mint + Chrome:

Uncaught TypeError: Module.FS_createDataFile is not a function
    at storeFS ((index):149:24)
    at rq.onsuccess (helpers.js:153:33)

I couldn't get the models to download into IndexDB, cors problem, so I downloaded by hand and put them on localhost. Hope this helps someone else:

loadRemote: storage quota: 141090508800 bytes
loadRemote: storage usage: 3070 bytes
loadRemote: "http://localhost/models/ggml-model-whisper-tiny.en.bin" is not in the IndexedDB
loadRemote: storage quota: 141090508800 bytes
loadRemote: storage usage: 3524 bytes
loadRemote: created IndexedDB whisper.ggerganov.com version 1
loadRemote: "http://localhost/models/ggml-model-whisper-tiny.en.bin" is not in the IndexedDB
fetchRemote: downloading with fetch()...
fetchRemote: fetching 0% ...
fetchRemote: fetching 10% ...
fetchRemote: fetching 20% ...
fetchRemote: fetching 30% ...
fetchRemote: fetching 40% ...
fetchRemote: fetching 50% ...
fetchRemote: fetching 60% ...
fetchRemote: fetching 70% ...
fetchRemote: fetching 80% ...
fetchRemote: fetching 90% ...
fetchRemote: fetching 100% ...
loadRemote: "http://localhost/models/ggml-model-whisper-tiny.en.bin" stored in the IndexedDB

Thanks again.

@andreineamtu
Copy link

Hello,
Yes I have the same problem when trying to run the "stream.wasm" locally in the browser.
I would like to use the example and adjust it for my project.
Was anyone able to run it and deploy to a server?

@damoncrockett
Copy link

Hello, Yes I have the same problem when trying to run the "stream.wasm" locally in the browser. I would like to use the example and adjust it for my project. Was anyone able to run it and deploy to a server?

#533 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants