mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-06-08 10:47:16 +02:00
This commit add support for language detection in the Whisper Node.js addon example. It also updates the node addon to return an object instead of an array as the results. The motivation for this change is to enable the inclusion of the detected language in the result, in addition to the transcription segments. For example, when using the `detect_language` option, the result will now be: ```console { language: 'en' } ``` And if the `language` option is set to "auto", it will also return: ```console { language: 'en', transcription: [ [ '00:00:00.000', '00:00:07.600', ' And so my fellow Americans, ask not what your country can do for you,' ], [ '00:00:07.600', '00:00:10.600', ' ask what you can do for your country.' ] ] } ```
addon
This is an addon demo that can perform whisper model reasoning in node
and electron
environments, based on cmake-js.
It can be used as a reference for using the whisper.cpp project in other node projects.
Install
npm install
Compile
Make sure it is in the project root directory and compiled with make-js.
npx cmake-js compile -T addon.node -B Release
For Electron addon and cmake-js options, you can see cmake-js and make very few configuration changes.
Such as appointing special cmake path:
npx cmake-js compile -c 'xxx/cmake' -T addon.node -B Release
Run
cd examples/addon.node
node index.js --language='language' --model='model-path' --fname_inp='file-path'
Because this is a simple Demo, only the above parameters are set in the node environment.
Other parameters can also be specified in the node environment.