# Cobra Voice Activity Detection engine
Made in Vancouver, Canada by [Picovoice](https://picovoice.ai)
This package contains demos and commandline utilities for processing real-time audio (i.e. microphone) and audio files
using Cobra voice activity detection engine.
## Cobra
Cobra is a highly accurate and lightweight voice activity detection (VAD) engine.
## Compatibility
- Python 3.9+
- Runs on Linux (x86_64), macOS (x86_64 and arm64), Windows (x86_64, arm64), and Raspberry Pi (3, 4, 5).
## AccessKey
Cobra requires a valid Picovoice `AccessKey` at initialization. `AccessKey` acts as your credentials when using Cobra SDKs.
You can get your `AccessKey` for free. Make sure to keep your `AccessKey` secret.
Signup or Login to [Picovoice Console](https://console.picovoice.ai/) to get your `AccessKey`.
## Installation
```console
sudo pip3 install pvcobrademo
```
## Usage
### Microphone Demo
The Microphone demo opens an audio stream from a microphone and detects voice activities. The following opens the default microphone:
```console
cobra_demo_mic --access_key {AccessKey}
```
where `{AccessKey}` is an AccessKey which should be obtained from [Picovoice Console](https://console.picovoice.ai/). It is possible that the default audio input device recognized by `pvrecorder` is not the one being used. There are a couple of debugging facilities baked into the demo application to solve this. First, type the following into the console:
```console
cobra_demo_mic --show_audio_devices
```
It provides information about various audio input devices on the box. On a Linux box, this is the console output:
```
'index': '0', 'name': 'HDA Intel PCH: ALC892 Analog (hw:0,0)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '2'
'index': '1', 'name': 'HDA Intel PCH: ALC892 Alt Analog (hw:0,2)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '2'
'index': '2', 'name': 'HDA NVidia: HDMI 0 (hw:1,3)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '3', 'name': 'HDA NVidia: HDMI 1 (hw:1,7)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '4', 'name': 'HDA NVidia: HDMI 2 (hw:1,8)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '5', 'name': 'HDA NVidia: HDMI 3 (hw:1,9)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '6', 'name': 'HDA NVidia: HDMI 0 (hw:2,3)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '7', 'name': 'HDA NVidia: HDMI 1 (hw:2,7)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '8', 'name': 'HDA NVidia: HDMI 2 (hw:2,8)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '9', 'name': 'HDA NVidia: HDMI 3 (hw:2,9)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '10', 'name': 'Logitech USB Headset: Audio (hw:3,0)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '1'
'index': '11', 'name': 'sysdefault', 'defaultSampleRate': '48000.0', 'maxInputChannels': '128'
'index': '12', 'name': 'front', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '13', 'name': 'surround21', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '14', 'name': 'surround40', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '15', 'name': 'surround41', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '16', 'name': 'surround50', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '17', 'name': 'surround51', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '18', 'name': 'surround71', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'
'index': '19', 'name': 'pulse', 'defaultSampleRate': '44100.0', 'maxInputChannels': '32'
'index': '20', 'name': 'dmix', 'defaultSampleRate': '48000.0', 'maxInputChannels': '0'
'index': '21', 'name': 'default', 'defaultSampleRate': '44100.0', 'maxInputChannels': '32'
```
It can be seen that the last device (index 21) is considered default. But on this machine, a headset is being used as
the input device which has an index of 10. After finding the correct index the demo application can be invoked as below:
```console
cobra_demo_mic --access_key {AccessKey} --audio_device_index 10
```
If the problem persists we suggest storing the recorded audio into a file for inspection. This can be achieved by:
```console
cobra_demo_mic --access_key {AccessKey} --audio_device_index 10 --output_path ~/test.wav
```
If after listening to stored file there is no apparent problem detected please open an issue.
### File Demo
It allows testing Cobra on a corpus of audio files. The demo is mainly useful for quantitative performance
benchmarking. It accepts 16kHz audio files. Cobra processes a single-channel audio stream if a stereo file is
provided it only processes the first (left) channel. The following processes a file looking for voice activities:
```console
cobra_demo_file --access_key {AccessKey} --input_audio_path ${AUDIO_PATH}
```
where `{AccessKey}` is an AccessKey which should be obtained from [Picovoice Console](https://console.picovoice.ai/). The threshold of the engine can be tuned using the `threshold` input argument:
```console
cobra_demo_file --access_key {AccessKey} --input_audio_path ${AUDIO_PATH} \
--threshold 0.9
```
Threshold is a floating point number within `[0, 1]`. A higher threshold reduces the miss rate at the cost of increased false alarm rate.
Raw data
{
"_id": null,
"home_page": "https://github.com/Picovoice/cobra",
"name": "pvcobrademo",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "voice activity detection engine, VAD",
"author": "Picovoice",
"author_email": "hello@picovoice.ai",
"download_url": "https://files.pythonhosted.org/packages/01/f2/455edd40d3d3d53d93af1c9ebb78328969128660ea9b7b2445265228af68/pvcobrademo-2.0.5.tar.gz",
"platform": null,
"description": "# Cobra Voice Activity Detection engine\n\nMade in Vancouver, Canada by [Picovoice](https://picovoice.ai)\n\nThis package contains demos and commandline utilities for processing real-time audio (i.e. microphone) and audio files\nusing Cobra voice activity detection engine.\n\n## Cobra\n\nCobra is a highly accurate and lightweight voice activity detection (VAD) engine.\n\n## Compatibility\n\n- Python 3.9+\n- Runs on Linux (x86_64), macOS (x86_64 and arm64), Windows (x86_64, arm64), and Raspberry Pi (3, 4, 5).\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## Installation\n\n\n```console\nsudo pip3 install pvcobrademo\n```\n\n## Usage\n\n### Microphone Demo\n\nThe Microphone demo opens an audio stream from a microphone and detects voice activities. The following opens the default microphone:\n\n```console\ncobra_demo_mic --access_key {AccessKey}\n```\n\nwhere `{AccessKey}` is an AccessKey which should be obtained from [Picovoice Console](https://console.picovoice.ai/). It is possible that the default audio input device recognized by `pvrecorder` is not the one being used. There are a couple of debugging facilities baked into the demo application to solve this. First, type the following into the console:\n\n```console\ncobra_demo_mic --show_audio_devices\n```\n\nIt provides information about various audio input devices on the box. On a Linux box, this is the console output:\n\n```\n'index': '0', 'name': 'HDA Intel PCH: ALC892 Analog (hw:0,0)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '2'\n'index': '1', 'name': 'HDA Intel PCH: ALC892 Alt Analog (hw:0,2)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '2'\n'index': '2', 'name': 'HDA NVidia: HDMI 0 (hw:1,3)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '3', 'name': 'HDA NVidia: HDMI 1 (hw:1,7)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '4', 'name': 'HDA NVidia: HDMI 2 (hw:1,8)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '5', 'name': 'HDA NVidia: HDMI 3 (hw:1,9)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '6', 'name': 'HDA NVidia: HDMI 0 (hw:2,3)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '7', 'name': 'HDA NVidia: HDMI 1 (hw:2,7)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '8', 'name': 'HDA NVidia: HDMI 2 (hw:2,8)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '9', 'name': 'HDA NVidia: HDMI 3 (hw:2,9)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '10', 'name': 'Logitech USB Headset: Audio (hw:3,0)', 'defaultSampleRate': '44100.0', 'maxInputChannels': '1'\n'index': '11', 'name': 'sysdefault', 'defaultSampleRate': '48000.0', 'maxInputChannels': '128'\n'index': '12', 'name': 'front', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '13', 'name': 'surround21', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '14', 'name': 'surround40', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '15', 'name': 'surround41', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '16', 'name': 'surround50', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '17', 'name': 'surround51', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '18', 'name': 'surround71', 'defaultSampleRate': '44100.0', 'maxInputChannels': '0'\n'index': '19', 'name': 'pulse', 'defaultSampleRate': '44100.0', 'maxInputChannels': '32'\n'index': '20', 'name': 'dmix', 'defaultSampleRate': '48000.0', 'maxInputChannels': '0'\n'index': '21', 'name': 'default', 'defaultSampleRate': '44100.0', 'maxInputChannels': '32'\n``` \n\nIt can be seen that the last device (index 21) is considered default. But on this machine, a headset is being used as \nthe input device which has an index of 10. After finding the correct index the demo application can be invoked as below:\n\n```console\ncobra_demo_mic --access_key {AccessKey} --audio_device_index 10\n```\n\nIf the problem persists we suggest storing the recorded audio into a file for inspection. This can be achieved by:\n\n```console\ncobra_demo_mic --access_key {AccessKey} --audio_device_index 10 --output_path ~/test.wav\n```\n\nIf after listening to stored file there is no apparent problem detected please open an issue.\n\n### File Demo\n\nIt allows testing Cobra on a corpus of audio files. The demo is mainly useful for quantitative performance\nbenchmarking. It accepts 16kHz audio files. Cobra processes a single-channel audio stream if a stereo file is\nprovided it only processes the first (left) channel. The following processes a file looking for voice activities:\n\n```console\ncobra_demo_file --access_key {AccessKey} --input_audio_path ${AUDIO_PATH}\n```\nwhere `{AccessKey}` is an AccessKey which should be obtained from [Picovoice Console](https://console.picovoice.ai/). The threshold of the engine can be tuned using the `threshold` input argument:\n\n```console\ncobra_demo_file --access_key {AccessKey} --input_audio_path ${AUDIO_PATH} \\\n --threshold 0.9\n```\n\nThreshold is a floating point number within `[0, 1]`. A higher threshold reduces the miss rate at the cost of increased false alarm rate.\n",
"bugtrack_url": null,
"license": null,
"summary": "Cobra voice activity detection (VAD) engine demos.",
"version": "2.0.5",
"project_urls": {
"Homepage": "https://github.com/Picovoice/cobra"
},
"split_keywords": [
"voice activity detection engine",
" vad"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "cf335f7c9b1df845604b41ca627843b1164abbef2d20738cf9ac31deba73970d",
"md5": "75100b1bf966daa3076cd5e20532f599",
"sha256": "0793cace0fa65868cbc2e19f88cfbcbb19bfcf11d48bb308118c0ee602c8d2bc"
},
"downloads": -1,
"filename": "pvcobrademo-2.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "75100b1bf966daa3076cd5e20532f599",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 10741,
"upload_time": "2025-02-06T00:00:31",
"upload_time_iso_8601": "2025-02-06T00:00:31.459165Z",
"url": "https://files.pythonhosted.org/packages/cf/33/5f7c9b1df845604b41ca627843b1164abbef2d20738cf9ac31deba73970d/pvcobrademo-2.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "01f2455edd40d3d3d53d93af1c9ebb78328969128660ea9b7b2445265228af68",
"md5": "a4d81ec17c92472b9b15ae8f5c8ab0fd",
"sha256": "b95407952b106ed58b3f000d56372dbd797d63e1a65faae4ae16225389b91ca9"
},
"downloads": -1,
"filename": "pvcobrademo-2.0.5.tar.gz",
"has_sig": false,
"md5_digest": "a4d81ec17c92472b9b15ae8f5c8ab0fd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 11237,
"upload_time": "2025-02-06T00:00:34",
"upload_time_iso_8601": "2025-02-06T00:00:34.638696Z",
"url": "https://files.pythonhosted.org/packages/01/f2/455edd40d3d3d53d93af1c9ebb78328969128660ea9b7b2445265228af68/pvcobrademo-2.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-06 00:00:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Picovoice",
"github_project": "cobra",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pvcobrademo"
}