{"id":24113797,"url":"https://github.com/gkonovalov/android-vad","last_synced_at":"2025-05-16T10:06:42.614Z","repository":{"id":40739292,"uuid":"224550411","full_name":"gkonovalov/android-vad","owner":"gkonovalov","description":"Android Voice Activity Detection (VAD) library. Supports WebRTC VAD GMM, Silero VAD DNN, Yamnet VAD DNN models. ","archived":false,"fork":false,"pushed_at":"2025-01-31T10:52:36.000Z","size":5427,"stargazers_count":323,"open_issues_count":2,"forks_count":69,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-09T06:04:50.261Z","etag":null,"topics":["android","audio-processing","deep-neural-networks","dnn","gmm","neural-networks","offline","on-device-ai","onnx-models","real-time","silero","silero-vad","speech-detection","speech-recoginition","vad","voice-activity-detection","voice-activity-detector","voice-detection","webrtc","yamnet"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gkonovalov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-28T02:00:23.000Z","updated_at":"2025-04-08T12:02:11.000Z","dependencies_parsed_at":"2024-02-12T16:13:43.332Z","dependency_job_id":"26c47c8f-118b-4a2f-a4da-88e4372b336f","html_url":"https://github.com/gkonovalov/android-vad","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkonovalov%2Fandroid-vad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkonovalov%2Fandroid-vad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkonovalov%2Fandroid-vad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkonovalov%2Fandroid-vad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gkonovalov","download_url":"https://codeload.github.com/gkonovalov/android-vad/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509476,"owners_count":22082891,"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":["android","audio-processing","deep-neural-networks","dnn","gmm","neural-networks","offline","on-device-ai","onnx-models","real-time","silero","silero-vad","speech-detection","speech-recoginition","vad","voice-activity-detection","voice-activity-detector","voice-detection","webrtc","yamnet"],"created_at":"2025-01-11T04:40:12.477Z","updated_at":"2025-05-16T10:06:42.595Z","avatar_url":"https://github.com/gkonovalov.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Android Voice Activity Detection (VAD)\nAndroid [VAD](https://en.wikipedia.org/wiki/Voice_activity_detection) library is designed to process audio in \nreal-time and identify presence of human speech in audio samples that contain a mixture of speech \nand noise. The VAD functionality operates offline, performing all processing tasks directly on the mobile device.\n\nThe repository offers three distinct models for voice activity detection:\n\n[WebRTC VAD](https://chromium.googlesource.com/external/webrtc/+/branch-heads/43/webrtc/common_audio/vad/) [[1]](#1)\nis based on a Gaussian Mixture Model [(GMM)](http://en.wikipedia.org/wiki/Mixture_model#Gaussian_mixture_model)\nwhich is known for its exceptional speed and effectiveness in distinguishing between noise and silence.\nHowever, it may demonstrate relatively lower accuracy when it comes to differentiating speech from background noise.\n\n[Silero VAD](https://github.com/snakers4/silero-vad) [[2]](#2) is based on a Deep Neural Networks \n[(DNN)](https://en.wikipedia.org/wiki/Deep_learning) and utilizes the \n[ONNX Runtime Mobile](https://onnxruntime.ai/docs/install/#install-on-web-and-mobile) for execution. \nIt provides exceptional accuracy and achieves processing time that is very close to WebRTC VAD.\n\n[Yamnet VAD](https://github.com/tensorflow/models/tree/master/research/audioset/yamnet) [[3]](#3) is based on a Deep Neural Networks\n[(DNN)](https://en.wikipedia.org/wiki/Deep_learning) and employs the Mobilenet_v1 depthwise-separable \nconvolution architecture. For execution utilizes the [Tensorflow Lite](https://www.tensorflow.org/lite/android) runtime.\nYamnet VAD can predict [521](https://github.com/tensorflow/models/blob/master/research/audioset/yamnet/yamnet_class_map.csv)\naudio event classes (such as speech, music, animal sounds and etc).\nIt was trained on [AudioSet-YouTube](https://research.google.com/audioset/) corpus.\n\nWebRTC VAD is lightweight (only 158 KB) and provides exceptional speed in audio processing, but it may exhibit lower accuracy\ncompared to DNN models. WebRTC VAD can be invaluable in scenarios where a small and fast library is necessary and where sacrificing accuracy is acceptable.\nIn situations where high accuracy is critical, models like Silero VAD and Yamnet VAD are more preferable.\nFor more detailed insights and a comprehensive comparison between DNN and GMM, refer to the following comparison\n[Silero VAD vs WebRTC VAD](https://github.com/snakers4/silero-vad/wiki/Quality-Metrics#vs-other-available-solutions).\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/gkonovalov/android-vad/master/vad-comparison.png\" /\u003e\n\u003c/p\u003e\n\n## WebRTC VAD\n#### Parameters\nWebRTC VAD library only accepts **16-bit Mono PCM audio stream** and can work with next Sample Rates, \nFrame Sizes and Modes.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n| Valid Sample Rate | Valid Frame Size |\n|:-----------------:|:----------------:|\n|      8000Hz       |   80, 160, 240   |\n|      16000Hz      |  160, 320, 480   |\n|      32000Hz      |  320, 640, 960   |\n|      48000Hz      |  480, 960, 1440  |\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n| Valid Mode      |\n|:----------------|\n| NORMAL          |\n| LOW_BITRATE     |\n| AGGRESSIVE      |\n| VERY_AGGRESSIVE |\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nRecommended parameters for WebRTC VAD:\n* Sample Rate (required) - **16KHz** - The sample rate of the audio input.\n* Frame Size (required) - **320** - The frame size of the audio input.\n* Mode (required) - **VERY_AGGRESSIVE** - The confidence mode of the VAD model.\n* Silence Duration (optional) - **300ms** - The minimum duration in milliseconds for silence segments.\n* Speech Duration (optional) - **50ms** - The minimum duration in milliseconds for speech segments.\n\n#### Usage\nWebRTC VAD can identify speech in short audio frames, returning results for each frame.\nBy utilizing parameters such as **silenceDurationMs** and **speechDurationMs**, you can enhance the\ncapability of VAD, enabling the detection of prolonged utterances while minimizing false positive\nresults during pauses between sentences.\n\nJava example:\n```java  \n    VadWebRTC vad = Vad.builder()\n        .setSampleRate(SampleRate.SAMPLE_RATE_16K)\n        .setFrameSize(FrameSize.FRAME_SIZE_320)\n        .setMode(Mode.VERY_AGGRESSIVE)\n        .setSilenceDurationMs(300)\n        .setSpeechDurationMs(50)\n        .build();\n\n    boolean isSpeech = vad.isSpeech(audioData);\n\n    vad.close();\n```\nKotlin example:\n```kotlin\n    VadWebRTC(\n        sampleRate = SampleRate.SAMPLE_RATE_16K,\n        frameSize = FrameSize.FRAME_SIZE_320,\n        mode = Mode.VERY_AGGRESSIVE,\n        silenceDurationMs = 300,\n        speechDurationMs = 50\n    ).use { vad -\u003e\n        val isSpeech = vad.isSpeech(audioData)\n    }\n```\nAn example of how to detect speech in an audio file:\n```kotlin\n    VadWebRTC(\n        sampleRate = SampleRate.SAMPLE_RATE_16K,\n        frameSize = FrameSize.FRAME_SIZE_320,\n        mode = Mode.VERY_AGGRESSIVE,\n        silenceDurationMs = 600,\n        speechDurationMs = 50\n    ).use { vad -\u003e\n        val chunkSize = vad.frameSize.value * 2\n\n        requireContext().assets.open(\"hello.wav\").buffered().use { input -\u003e\n            val audioHeader = ByteArray(44).apply { input.read(this) }\n            var speechData = byteArrayOf()\n\n            while (input.available() \u003e 0) {\n                val frameChunk = ByteArray(chunkSize).apply { input.read(this) }\n\n                if (vad.isSpeech(frameChunk)) {\n                    speechData += frameChunk\n                } else {\n                    if (speechData.isNotEmpty()) {\n                        val speechFile = File(\"/folder/\", \"${nanoTime()}.wav\")\n\n                        FileOutputStream(speechFile).use { output -\u003e\n                            output.write(audioHeader)\n                            output.write(speechData)\n                        }\n                        \n                        speechData = byteArrayOf()\n                    }\n                }\n            }\n        }\n    }\n```\n\n## Silero VAD\n#### Parameters\nSilero VAD library only accepts **16-bit Mono PCM audio stream** and can work with next Sample Rates,\nFrame Sizes and Modes.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n| Valid Sample Rate | Valid Frame Size |\n|:-----------------:|:----------------:|\n|      8000Hz       |  256, 512, 768   |\n|      16000Hz      | 512, 1024, 1536  |\n\u003c/td\u003e\n\u003ctd\u003e\n\n| Valid Mode      |\n|:----------------|\n| OFF             |\n| NORMAL          |\n| AGGRESSIVE      |\n| VERY_AGGRESSIVE |\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nRecommended parameters for Silero VAD:\n* Context (required) - The Context is required to facilitate reading the model file from the Android file system.\n* Sample Rate (required) - **16KHz** - The sample rate of the audio input.\n* Frame Size (required) - **512** - The frame size of the audio input.\n* Mode (required) - **NORMAL** - The confidence mode of the VAD model.\n* Silence Duration (optional) - **300ms** - The minimum duration in milliseconds for silence segments.\n* Speech Duration (optional) - **50ms** - The minimum duration in milliseconds for speech segments.\n\n#### Usage\nSilero VAD can identify speech in short audio frames, returning results for each frame. \nBy utilizing parameters such as **silenceDurationMs** and **speechDurationMs**, you can enhance the \ncapability of VAD, enabling the detection of prolonged utterances while minimizing false positive \nresults during pauses between sentences.\n\nJava example:\n```java  \n    VadSilero vad = Vad.builder()\n        .setContext(requireContext())\n        .setSampleRate(SampleRate.SAMPLE_RATE_16K)\n        .setFrameSize(FrameSize.FRAME_SIZE_512)\n        .setMode(Mode.NORMAL)\n        .setSilenceDurationMs(300)\n        .setSpeechDurationMs(50)\n        .build();\n\n    boolean isSpeech = vad.isSpeech(audioData);\n\n    vad.close();\n```\nKotlin example:\n```kotlin\n    VadSilero(\n        requireContext(),\n        sampleRate = SampleRate.SAMPLE_RATE_16K,\n        frameSize = FrameSize.FRAME_SIZE_512,\n        mode = Mode.NORMAL,\n        silenceDurationMs = 300,\n        speechDurationMs = 50\n    ).use { vad -\u003e\n        val isSpeech = vad.isSpeech(audioData)\n    }\n```\n\n## Yamnet VAD\n#### Parameters\nYamnet VAD library only accepts **16-bit Mono PCM audio stream** and can work with next Sample Rates,\nFrame Sizes and Modes.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n| Valid Sample Rate |  Valid Frame Size  |\n|:-----------------:|:------------------:|\n|      16000Hz      | 243, 487, 731, 975 |\n|                   | 243, 487, 731, 975 |\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n| Valid Mode      |\n|:----------------|\n| OFF             |\n| NORMAL          |\n| AGGRESSIVE      |\n| VERY_AGGRESSIVE |\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nRecommended parameters for Yamnet VAD:\n* Context (required) - The Context is required to facilitate reading the model file from the Android file system.\n* Sample Rate (required) - **16KHz** - The sample rate of the audio input.\n* Frame Size (required) - **243** - The frame size of the audio input.\n* Mode (required) - **NORMAL** - The confidence mode of the VAD model.\n* Silence Duration (optional) - **30ms** - The minimum duration in milliseconds for silence segments.\n* Speech Duration (optional) - **30ms** - The minimum duration in milliseconds for speech segments.\n\n#### Usage\nYamnet VAD can identify [521](https://github.com/tensorflow/models/blob/master/research/audioset/yamnet/yamnet_class_map.csv) \naudio event classes (such as speech, music, animal sounds and etc) in small audio frames.\nBy utilizing parameters such as **silenceDurationMs** and **speechDurationMs** and specifying\nsound category (ex. classifyAudio(**\"Speech\"**, audioData)), you can enhance the capability of VAD, \nenabling the detection of prolonged utterances while minimizing false positive results during \npauses between sentences. \n\nJava example:\n```java  \n    VadYamnet vad = Vad.builder()\n        .setContext(requireContext())\n        .setSampleRate(SampleRate.SAMPLE_RATE_16K)\n        .setFrameSize(FrameSize.FRAME_SIZE_243)\n        .setMode(Mode.NORMAL)\n        .setSilenceDurationMs(30)\n        .setSpeechDurationMs(30)\n        .build();\n\n    SoundCategory sc = vad.classifyAudio(\"Speech\", audioData);\n\n    if (\"Speech\".equals(sc.getLabel())) {\n        System.out.println(\"Speech Detected: \" + sc.getScore());\n    } else {\n        System.out.println(\"Noise Detected: \" + sc.getScore());\n    }\n    \n    vad.close();\n```\nKotlin example:\n```kotlin\n    VadYamnet(\n        requireContext(),\n        sampleRate = SampleRate.SAMPLE_RATE_16K,\n        frameSize = FrameSize.FRAME_SIZE_243,\n        mode = Mode.NORMAL,\n        silenceDurationMs = 30,\n        speechDurationMs = 30\n    ).use { vad -\u003e\n        val sc = vad.classifyAudio(\"Cat\", audioData)\n\n        when (sc.label) {\n            \"Cat\" -\u003e println(\"Cat Detected: \" + sc.score)\n            else -\u003e println(\"Noise Detected: \" + sc.score)\n        }\n    }\n```\n\n## Requirements\n#### Android API\nWebRTC VAD - Android **API 16** and later.  \nSilero VAD - Android **API 21** and later.  \nYamnet VAD - Android **API 23** and later.  \n#### JDK\nJDK **8** or later.\n\n## Download\n[![](https://jitpack.io/v/gkonovalov/android-vad.svg)](https://jitpack.io/#gkonovalov/android-vad)\n\nGradle is the only supported build configuration, so just add the dependency to your project `build.gradle` file:\n1. Add it in your root build.gradle at the end of repositories:\n```groovy\nallprojects {\n   repositories {\n     maven { url 'https://jitpack.io' }\n   }\n}\n```\n\n2. Add one dependency from list below:\n\n#### WebRTC VAD\n```groovy\ndependencies {\n    implementation 'com.github.gkonovalov.android-vad:webrtc:2.0.9'\n}\n```\n\n#### Silero VAD\n```groovy\ndependencies {\n    implementation 'com.github.gkonovalov.android-vad:silero:2.0.9'\n}\n```\n\n#### Yamnet VAD\n```groovy\ndependencies {\n    implementation 'com.github.gkonovalov.android-vad:yamnet:2.0.9'\n}\n```\nYou also can download precompiled AAR library and APK files from GitHub's [releases page](https://github.com/gkonovalov/android-vad/releases).\n\n## References\n\u003ca id=\"1\"\u003e[1]\u003c/a\u003e\n[WebRTC VAD](https://chromium.googlesource.com/external/webrtc/+/branch-heads/43/webrtc/common_audio/vad/) -\nVoice Activity Detector from Google which is reportedly one of the best available: it's fast,\nmodern and free. This algorithm has found wide adoption and has recently become one of the\ngold-standards for delay-sensitive scenarios like web-based interaction.\n\n\u003ca id=\"2\"\u003e[2]\u003c/a\u003e\n[Silero VAD](https://github.com/snakers4/silero-vad) - pre-trained enterprise-grade Voice Activity Detector,\nNumber Detector and Language Classifier \u003ca href=\"mailto:hello@silero.ai\"\u003ehello@silero.ai\u003c/a\u003e.\n\n\u003ca id=\"3\"\u003e[3]\u003c/a\u003e\n[Yamnet VAD](https://github.com/tensorflow/models/tree/master/research/audioset/yamnet) -\nYAMNet is a pretrained deep neural network that can predicts 521 audio event classes based on the AudioSet-YouTube \ncorpus, employing the Mobilenet_v1 depthwise-separable convolution architecture.\n\n------------\nGeorgiy Konovalov 2025 (c) [MIT License](https://opensource.org/licenses/MIT)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgkonovalov%2Fandroid-vad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgkonovalov%2Fandroid-vad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgkonovalov%2Fandroid-vad/lists"}