-
Notifications
You must be signed in to change notification settings - Fork 36
feat: Added libfvad library and integrated Voice Activity Detection #457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
srikaranth
wants to merge
4
commits into
main
Choose a base branch
from
feat/VADTransform
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ea44260
feat: Added libfvad library and integrated Voice Activity Detection
Srishtiiiiiiiiii 240d443
changes in CMakelist
Srishtiiiiiiiiii 2f60f6b
worked on pr comments:
srikaranth 85781d9
added the speechOnlyMode bool to get the .raw file with only speeh
srikaranth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #pragma once | ||
|
|
||
| #include "Module.h" | ||
|
|
||
| class VADTransformProps : public ModuleProps | ||
| { | ||
| public: | ||
| enum AggressivenessMode { | ||
| QUALITY = 0, // Least aggressive (best quality, catches more speech) | ||
| LOW_BITRATE = 1, // Moderate | ||
| AGGRESSIVE = 2, // More aggressive | ||
| VERY_AGGRESSIVE = 3 // Most aggressive (best bandwidth saving, only clear speech) | ||
| }; | ||
|
|
||
| enum FrameLength { | ||
| FRAME_10MS = 10, | ||
| FRAME_20MS = 20, | ||
| FRAME_30MS = 30 | ||
| }; | ||
|
|
||
| VADTransformProps( | ||
| int _sampleRate = 16000, | ||
| AggressivenessMode _mode = QUALITY, | ||
| FrameLength _frameLength = FRAME_10MS | ||
| ); | ||
|
|
||
| int sampleRate; | ||
| AggressivenessMode mode; | ||
| FrameLength frameLength; | ||
|
|
||
| size_t getSerializeSize(); | ||
|
|
||
| private: | ||
| friend class boost::serialization::access; | ||
|
|
||
| template <class Archive> | ||
| void serialize(Archive& ar, const unsigned int version); | ||
| }; | ||
|
|
||
| class VADTransform : public Module | ||
| { | ||
| public: | ||
| VADTransform(VADTransformProps _props); | ||
| virtual ~VADTransform(); | ||
|
|
||
| bool init(); | ||
| bool term(); | ||
| void setProps(VADTransformProps& props); | ||
| VADTransformProps getProps(); | ||
|
|
||
| protected: | ||
| bool process(frame_container& frames); | ||
| bool processSOS(frame_sp& frame); | ||
| bool validateInputPins(); | ||
| bool validateOutputPins(); | ||
| void addInputPin(framemetadata_sp& metadata, string& pinId); | ||
| bool handlePropsChange(frame_sp& frame); | ||
| bool processEOS(string& pinId); | ||
|
|
||
| private: | ||
| void setMetadata(framemetadata_sp& metadata); | ||
| class Detail; | ||
| boost::shared_ptr<Detail> mDetail; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #pragma once | ||
|
|
||
| #include "Module.h" | ||
|
|
||
| class VoiceActivityDetectorProps : public ModuleProps | ||
| { | ||
| public: | ||
|
|
||
| //decides speech vs no-speech | ||
| enum AggressivenessMode { | ||
| QUALITY = 0, // Least aggressive (best quality, catches more speech) | ||
| LOW_BITRATE = 1, // Moderate | ||
| AGGRESSIVE = 2, // More aggressive | ||
| VERY_AGGRESSIVE = 3 // Most aggressive (best bandwidth saving, only clear speech) | ||
| }; | ||
|
|
||
| // audio time the VAD analyzes at once | ||
| // default sample rate is 16 kHz (16,000 samples/sec) | ||
| // 10ms - 160 samples 20ms - 320 samples 30ms - 480 samples | ||
| enum FrameLength { | ||
| FRAME_10MS = 10, // Lowest latency | ||
| FRAME_20MS = 20, // Balanced | ||
| FRAME_30MS = 30 // Best accuracy | ||
| }; | ||
|
|
||
| VoiceActivityDetectorProps( | ||
| int _sampleRate = 16000, | ||
| AggressivenessMode _mode = QUALITY, | ||
| FrameLength _frameLength = FRAME_10MS, | ||
| bool _speechOnly = false // When true, only outputs audio when speech is detected | ||
| ); | ||
|
|
||
| int sampleRate; | ||
| AggressivenessMode mode; | ||
| FrameLength frameLength; | ||
| bool speechOnly; // If true, audio passthrough only sends frames with speech | ||
|
|
||
| size_t getSerializeSize(); | ||
|
|
||
| private: | ||
| friend class boost::serialization::access; | ||
|
|
||
| template <class Archive> | ||
| void serialize(Archive& ar, const unsigned int version); | ||
| }; | ||
|
|
||
| class VoiceActivityDetector : public Module | ||
| { | ||
| public: | ||
| VoiceActivityDetector(VoiceActivityDetectorProps _props); | ||
| virtual ~VoiceActivityDetector(); | ||
|
|
||
| bool init(); | ||
| bool term(); | ||
| void setProps(VoiceActivityDetectorProps& props); | ||
| VoiceActivityDetectorProps getProps(); | ||
|
|
||
| protected: | ||
| bool process(frame_container& frames); | ||
| bool processSOS(frame_sp& frame); | ||
| bool validateInputPins(); | ||
| bool validateOutputPins(); | ||
| void addInputPin(framemetadata_sp& metadata, string& pinId); | ||
| bool handlePropsChange(frame_sp& frame); | ||
| bool processEOS(string& pinId); | ||
|
|
||
| private: | ||
| void setMetadata(framemetadata_sp& metadata); | ||
| class Detail; | ||
| boost::shared_ptr<Detail> mDetail; | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comments to describe this modes, as in effects of setting frame length