{"id":18247488,"url":"https://github.com/vagr9k/native-voice-command-detector","last_synced_at":"2026-02-17T15:31:09.140Z","repository":{"id":44144763,"uuid":"175993291","full_name":"Vagr9K/native-voice-command-detector","owner":"Vagr9K","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-09T00:40:50.000Z","size":229,"stargazers_count":2,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T14:48:27.493Z","etag":null,"topics":["cplusplus","gcloud","hotword-detection","multithreaded","multithreading","n-api","nodejs","porcupine","speech-recognition","speech-to-text","typescript"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vagr9K.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-16T16:01:46.000Z","updated_at":"2021-05-11T08:19:37.000Z","dependencies_parsed_at":"2023-01-25T10:32:34.470Z","dependency_job_id":null,"html_url":"https://github.com/Vagr9K/native-voice-command-detector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vagr9K%2Fnative-voice-command-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vagr9K%2Fnative-voice-command-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vagr9K%2Fnative-voice-command-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vagr9K%2Fnative-voice-command-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vagr9K","download_url":"https://codeload.github.com/Vagr9K/native-voice-command-detector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247202855,"owners_count":20900851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cplusplus","gcloud","hotword-detection","multithreaded","multithreading","n-api","nodejs","porcupine","speech-recognition","speech-to-text","typescript"],"created_at":"2024-11-05T09:31:23.547Z","updated_at":"2026-02-17T15:31:09.083Z","avatar_url":"https://github.com/Vagr9K.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Native Voice Command Detector\n\nNative voice command detector is a multithreaded N-API based native NodeJS module that can be used to detect voice commands.\n\nThe entire audio processing queue is handled by this module to prevent N-API overhead.\n\nChunks of processing are distributed between worker threads and utilize parallelization for maximum performance.\n\nThe amount of created worker threads is `logical_cpu_cores + 1`, where 1 thread schedules the work.\n\nThe project as of right now supports receiving RAW OPUS frames on Linux X86_64 platforms and invokes a callback with the text of the command whenever it's detected.\nMultiple audio streams are supported via unique IDs.\n\nThe module relies on [Porcupine](https://github.com/Picovoice/Porcupine) for hotword detection and [Google Speech To Text API](https://cloud.google.com/speech-to-text/) for speech recognition.\n\nThis project was primarily created for the [Discord VoiceBot](https://github.com/Vagr9K/VoiceBot), since a NodeJS only solution wouldn't be able to provide the desired performance.\n\n## Demo (based on [Discord VoiceBot](https://github.com/Vagr9K/VoiceBot))\n\n[![Demo](https://img.youtube.com/vi/vRwp--RoJdo/0.jpg)](https://www.youtube.com/watch?v=vRwp--RoJdo)\n\nWhy `Terminator`? It seems to be the most consistently detected hotword.\n\nWhy `Mozart`? It's not copyrighted.\n\n## How does this work\n\nConsult [my blog post](https://vagr9k.me/using-n-api-for-high-performance-voice-command-detection-in-discord) about the design decisions if you're interested.\n\n## Building\n\n- Install the external dependencies by relying on the system package manager:\n\n  * libopus\n  * libopusenc\n  * libcurl\n  * libssl\n  * libcrypto\n\n- Install the internal dependencies by running `git submodule update --init --recursive`\n- Run `yarn` or `npm install` to setup the build environment\n- Run `yarn build` or `npm run build` to build the module\n- The module will be located in `build/Release/detector.node`\n- NOTE: This project is in an alpha state and doesn't have prebuilt binaries ready. TO be able to `require` this module, rely on `yarn link` or `npm link`.\n\n## Usage\n\nFirst, initialize a `Detector` instance with the correct configuration:\n\n```js\nconst Detector = require(\"native-voice-command-detector\");\n\nconst voiceCommandDetector = new Detector(\n    pv_model_path,\n    pv_keyword_path,\n    pv_sensitivity,\n    gcloud_speech_to_text_api_key,\n    max_voice_buffer_ttl,\n    max_command_length,\n    max_command_silence_length_ms,\n    callback\n    );\n```\n\n`pv_model_path` and `pv_keyword_path` specify the hotword to detect. Consult [Porcupine's documentation on how to generate these files](https://github.com/Picovoice/Porcupine/tree/master/tools/optimizer).\n\n`pv_sensitivity` configures the sensitivity and should be a float between `0` (lowest sensitivity) and `1` (highest sensitivity).\n\n`gcloud_speech_to_text_api_key` is the API key that will be used for GCloud based operations. Consult the [GCloud API Key documentation](https://cloud.google.com/docs/authentication/api-keys) for details.\n\n`max_voice_buffer_ttl` is the amount of time in milliseconds a voice data buffer can spend being filled, without being processed by a worker thread.\n\n`max_command_length` specifies the maximum length of a voice command in milliseconds, after which the speech recognition will begin.\n\n`max_command_silence_length_ms` specifies the length of silence (no input) in milliseconds after which the command sequence will be treated as complete and the speech recognition will begin.\n\n`callback` will be called upon a keyword being detected:\n\n```js\n  const callback = (id, command) =\u003e {\n      // ID is a string containing the audio source identification\n      // command is the detected command text\n      console.log(id, command)\n  };\n```\n\nAfter the instance is initialized, submit audio data via:\n\n```js\ncommandDetector.addOpusFrame(id, buf);\n```\n\nWhere `buf` is a `Buffer` containing the binary data of the OPUS frame.\n\n## TypeScript\n\nTypeScript definitions are available out of the box in `lib/index.d.ts`.\n\n## Copyright\n\nCopyright (c) 2019 Ruben Harutyunyan\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvagr9k%2Fnative-voice-command-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvagr9k%2Fnative-voice-command-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvagr9k%2Fnative-voice-command-detector/lists"}