ccoreilly / vosk-browser

A speech recognition library running in the browser thanks to a WebAssembly build of Vosk
Apache License 2.0
364 stars 60 forks source link

react example process undefined #73

Open Altamimi-Dev opened 1 year ago

Altamimi-Dev commented 1 year ago

when trying to run the react example i get an error from the _stream_readable process undefined .

function maybeReadMore(stream, state) { if (!state.readingMore) { state.readingMore = true; process.nextTick(maybeReadMore_, stream, state); } }

how can i fix this?

erikh2000 commented 1 year ago

Just making a quick guess from vague memories of handling the same/similar issue...

I think maybe it's something related to a newer version of WebPack causing process to be undefined. I forget the exact cause - see https://stackoverflow.com/questions/70368760/react-uncaught-referenceerror-process-is-not-defined

You might double-check that you're building the unmodified example. E.g., no updates to package.json.

When I wrote my own web app that uses vosk-browser, I wrote a different Microphone class that doesn't have the same dependencies. This allowed me to use the newer version of create-react-app/WebPack.

-Erik

damian87x commented 6 months ago

I tried using webpack and Vite and no success with adding polyfill Added temp solution. If anyone finds a better way, please share window.process = { ...window.process, nextTick: (callback, ...args) => new Promise((resolve) => { setTimeout(() => { callback(...args); resolve(null); }, 0); }) };