whisper.cpp
whisper.cpp copied to clipboard
Nodejs Addon blocking main thread. Implemented Napi::AsyncWorker
This pull request aims to modify the code for the Whisper Node.js addon to avoid running in a blocking manner. Previously, even though you could import it in Node.js and use a queuing system to prevent blocking the main thread, the Whisper addon would still block the entire execution of Node.js, preventing any other task from running until the transcription was complete.
For example, if you use a queue package like Bull and expect to receive three requests and execute three transcriptions in parallel, the current version of the Whisper addon would only process one request and block the main thread until the transcription is finished.
I have implemented a fix in my personal project, which allows me to execute numerous Whisper tasks simultaneously while receiving and registering new jobs to execute when threads become available. This modification will greatly enhance the efficiency and usability of the Whisper Node.js addon.
Now you can import the addon and invoke on different jobs like this:
