{"_id":"@andyprevalsky/cobra-web","name":"@andyprevalsky/cobra-web","dist-tags":{"latest":"2.0.3"},"versions":{"2.0.3":{"name":"@andyprevalsky/cobra-web","description":"Cobra VAD engine for web browsers (via WebAssembly)","author":{"name":"Picovoice Inc"},"license":"Apache-2.0","version":"2.0.3","keywords":["cobra","web","voice","speech","recognition","voice activity detection","ai","VAD","offline","hooks"],"type":"module","entry":"src/index.ts","module":"dist/esm/index.js","iife":"dist/iife/index.js","types":"dist/types/index.d.ts","scripts":{"build:all":"","build:types":"tsc --declaration --declarationMap --emitDeclarationOnly --outDir ./dist/types","build":"npm-run-all --parallel build:**","lint":"eslint . --ext .js,.ts","prepack":"npm-run-all build","start":"cross-env TARGET='debug' rollup --config --watch","watch":"rollup --config --watch","format":"prettier --write \"**/*.{js,ts,json}\"","copywasm":"node scripts/copy_wasm.js","setup-test":"node scripts/setup_test.js","test":"cypress run --spec test/cobra.test.ts","test-perf":"cypress run --spec test/cobra_perf.test.ts"},"dependencies":{"@andyprevalsky/cobra-web":"^2.0.3","@picovoice/web-utils":"=1.3.1","@picovoice/web-voice-processor":"^4.0.9"},"devDependencies":{"@babel/core":"^7.21.3","@babel/plugin-transform-runtime":"^7.21.0","@babel/preset-env":"^7.20.2","@babel/runtime":"^7.21.0","@rollup/plugin-babel":"^6.0.3","@rollup/plugin-commonjs":"^24.0.1","@rollup/plugin-node-resolve":"^15.0.1","@rollup/plugin-terser":"^0.4.0","@rollup/pluginutils":"^5.0.2","@typescript-eslint/eslint-plugin":"^5.51.0","@typescript-eslint/parser":"^5.51.0","async-mutex":"^0.4.0","cross-env":"^7.0.3","cypress":"~12.8.1","eslint":"^8.22.0","eslint-plugin-cypress":"^2.12.1","npm-run-all":"^4.1.5","prettier":"^2.8.3","rollup":"^2.79.1","rollup-plugin-typescript2":"^0.34.1","rollup-plugin-web-worker-loader":"^1.6.1","tslib":"^2.5.0","typescript":"^4.9.5","wasm-feature-detect":"^1.5.0"},"engines":{"node":">=16"},"_id":"@andyprevalsky/cobra-web@2.0.3","gitHead":"3d8fd664d433a5304d082cf9f7ef8477b75a1bb9","_nodeVersion":"21.6.2","_npmVersion":"10.2.4","dist":{"integrity":"sha512-rt7FlFMGz+GezEtmO/B0i/P5nDq1NSz478QpsaK8SGTXrBgjfBE/lNmhdEEej4VzUOrin48MYCby0zA8U8/Chw==","shasum":"5dd070274acd8d5bfe018fb41c6095898f3c83c7","tarball":"https://registry.npmjs.org/@andyprevalsky/cobra-web/-/cobra-web-2.0.3.tgz","fileCount":40,"unpackedSize":3516926,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEEvn9+61QeF95GqEpJ+qs276jLGcv6Xj8lNshayf1S8AiATPJO4xdjrmE2RAGqz7UwXvv8gNs24Z0aYLSNOtbdhHg=="}]},"_npmUser":{"name":"andyprevalsky","email":"andyprevalsky@yahoo.com"},"directories":{},"maintainers":[{"name":"andyprevalsky","email":"andyprevalsky@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cobra-web_2.0.3_1714964110453_0.1479895846531576"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-06T02:55:10.292Z","2.0.3":"2024-05-06T02:55:10.628Z","modified":"2024-05-06T02:55:10.976Z"},"maintainers":[{"name":"andyprevalsky","email":"andyprevalsky@yahoo.com"}],"description":"Cobra VAD engine for web browsers (via WebAssembly)","keywords":["cobra","web","voice","speech","recognition","voice activity detection","ai","VAD","offline","hooks"],"author":{"name":"Picovoice Inc"},"license":"Apache-2.0","readme":"# Cobra Binding for Web\n\n## Cobra Voice Activity Detection Engine\n\nMade in Vancouver, Canada by [Picovoice](https://picovoice.ai)\n\nCobra is a highly accurate and lightweight voice activity detection (VAD) engine.\n\n## Compatibility\n\n- Chrome / Edge\n- Firefox\n- Safari\n\n### Restrictions\n\nIndexedDB is required to use `Cobra` in a worker thread. Browsers without IndexedDB support\n(i.e. Firefox Incognito Mode) should use `Cobra` in the main thread.\n\n## Installation\n\nUsing `yarn`:\n\n```console\nyarn add @picovoice/cobra-web\n```\n\nor using `npm`:\n\n```console\nnpm install --save @picovoice/cobra-web\n```\n\n### AccessKey\n\nCobra requires a valid Picovoice `AccessKey` at initialization. `AccessKey` acts as your credentials when using Cobra SDKs.\nYou can get your `AccessKey` for free. Make sure to keep your `AccessKey` secret.\nSignup or Login to [Picovoice Console](https://console.picovoice.ai/) to get your `AccessKey`.\n\n### Usage\n\n#### Initialization\n\nCreate a `voiceProbabilityCallback` function to get voice probability results\nfrom the engine:\n\n```typescript\n\nfunction voiceProbabilityCallback(voiceProbability: number) {\n\n}\n```\n\nAdd a `processErrorCallback` function to the `options` object if you would like\nto catch errors that occur while processing audio:\n\n```typescript\nfunction processErrorCallback(error: string) {\n\n}\n\noptions.processErrorCallback = processErrorCallback;\n```\n\nUse `Cobra` to initialize the engine on the main thread:\n\n```typescript\nconst cobra = await Cobra.create(\n    ${ACCESS_KEY},\n    voiceProbabilityCallback,\n    options\n);\n```\n\nUse `CobraWorker` to initialize the engine on a worker thread:\n\n```typescript\nconst cobra = await CobraWorker.create(\n  ${ACCESS_KEY},\n  voiceProbabilityCallback,\n  options\n);\n```\n\n#### Process Audio\n\nThe `process` function will send the input frames to the engine.\nThe engine results are received via the `voiceProbabilityCallback` that's passed in during initialization.\n\n```typescript\nfunction getAudioData(): Int16Array {\n  ... // function to get audio data\n  return new Int16Array();\n}\n\nfor (;;) {\n  cobra.process(getAudioData());\n  // break on some condition\n}\n```\n\n#### Clean Up\n\nClean up used resources by `Cobra` or `CobraWorker`:\n\n```typescript\nawait cobra.release();\n```\n\n#### Terminate (Worker only)\n\nTerminate `CobraWorker` instance:\n\n```typescript\nawait cobra.terminate();\n```\n\n## Demo\n\nFor example usage refer to our [Web demo application](https://github.com/Picovoice/cobra/tree/master/demo/web).\n","readmeFilename":"README.md"}