msqr1 / Vosklet

A speech recognizer that can run on the browser, inspired by vosk-browser
MIT License
24 stars 1 forks source link

Import via module: Can't find variable window #5

Closed jakespracher closed 1 month ago

jakespracher commented 4 months ago

I've installed the library via NPM and load with import loadVosklet from 'vosklet';

Get the following error running the demo code from the readme

vosklet_demo.js:23 worker sent an error! http://localhost:4000/assets/app.js:2855: Uncaught ReferenceError: window is not define
worker.onerror  @   Vosklet.js:9
error (async)       
(anonymous) @   Vosklet.js:9
loadWasmModuleToWorker  @   Vosklet.js:9
loadWasmModuleToAllWorkers  @   Vosklet.js:9
(anonymous) @   Vosklet.js:9
callRuntimeCallbacks    @   Vosklet.js:9
preRun  @   Vosklet.js:9
run @   Vosklet.js:9
runCaller   @   Vosklet.js:9
removeRunDependency @   Vosklet.js:9
receiveInstance @   Vosklet.js:9
receiveInstantiationResult  @   Vosklet.js:9
Promise.then (async)        
instantiateArrayBuffer  @   Vosklet.js:9
instantiateAsync    @   Vosklet.js:9
createWasm  @   Vosklet.js:9
(anonymous) @   Vosklet.js:9
startRecognition    @   vosklet_demo.js:23
await in startRecognition (async)       
(anonymous) @   vosklet_demo.js:7
Show less
msqr1 commented 4 months ago

The file won't work with es6 import, possibly because I didn't build it to work with es6 modules. I can make you one if you need! This is currently in UMD. Also I'm removing the npm package after realizing you can use jsdelivr with github 😅

msqr1 commented 4 months ago

I unpublish the npm package, please use the jsdelivr from github instead. Do you still need an ES6 build?