alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
7.72k stars 1.08k forks source link

VOSK not compatible with newer NodeJS Versions because of ffi-napi dependency #1613

Open johnseabird opened 1 month ago

johnseabird commented 1 month ago

I do have the issue that VOSK will only run in older NodeJS versions, since ffi-napi package seems to be incompatible with newer node versions 18.7^ .

This was tested on multiple windows 11 machines as well as within Debian Bookworm (Docker Dev Container)

Reproduce:

nvm install 18.7 nvm use 18.7 npm install vosk -> ERRORs

nvm install 18.4 nvm use 18.4 npm install vosk -> SUCCESS

nvm install 18.7 nvm use 18.7 npm install ffi-napi -> ERRORs

nvm install 18.4

nvm use 18.4 npm install ffi-napi -> SUCCESS

To isolate this: If I try to install ffi-napi without vosk in for example Node 18.7^ , I already get errors and ffi-napi can not be installed anymore. Since VOSK depends on ffi-napi, VOSK will fail to install on those versions.

Is there anyway to use a maintained dependency instead of ffi-napi? ffi-napi isn't maintained in years. Would ffi-rs be an alternative to use here?

2024-07-26T09_04_45_570Z-debug-0.log

nshmyrev commented 1 month ago

We need to write direct bindings for node. I think ff-napi is hopeless.

Fyphen1223 commented 1 month ago

Are there any solutions for this :(

I really need to use VOSK with Node.js v21.

johnseabird commented 1 month ago

We need to write direct bindings for node. I think ff-napi is hopeless.

Is there a roadmap for when this might happen? We currently develop a server application at work and VOSK is an important part in our pipeline to stay in the area of acceptable delays.

johnseabird commented 1 month ago

Are there any solutions for this :(

I really need to use VOSK with Node.js v21.

What seems to work is, install VOSK with an older node version and switch to a high node version afterwards.

So: nvm install 18.4 nvm use 18.4 npm install vosk (with node 18.4 for example) nvm install 21 nvm use 21 npm start

Not sure if that might have any other issues later on. but so far it works. it is pretty inconvenient for deployment but does the trick during development.

Fyphen1223 commented 1 month ago

Actually, I'm depending on pnpm - which is not compatible with version <18.12.

johnseabird commented 1 month ago

Actually, I'm depending on pnpm - which is not compatible with version <18.12.

I see - what might be an option is to use an old version of node with npm to just install vosk in an empty folder and copy the contents of the node_module into the pnpm contents folder somehow? Since the issue is the binding step with ffi-napi. so if vosk package is once installed and bindings / c++ are successfull, it works by copy pasting (in theory)

Fyphen1223 commented 1 month ago

Actually, I'm depending on pnpm - which is not compatible with version <18.12.

I see - what might be an option is to use an old version of node with npm to just install vosk in an empty folder and copy the contents of the node_module into the pnpm contents folder somehow? Since the issue is the binding step with ffi-napi. so if vosk package is once installed and bindings / c++ are successfull, it works by copy pasting (in theory)

Oh, that was not in my mind - let me have a minute and try it.

Fyphen1223 commented 1 month ago

Well, I think it's working! Thanks for the solution!

(for just a reference, I created a new folder and nvm to use the older node and npm. Then used them to install vosk, and using cp command copied everything into the working node_modules. The problem is that now it requires weird steps to use lmao)