{"action":"created","comment":{"url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/comments/62356827","id":62356827,"diff_hunk":"@@ -30,49 +30,88 @@ namespace cobalt\n             }\n             kaldi::BaseFloat energyThreshold = mVadOptions.vad_energy_threshold;\n             int totalFramesSeen = mLogEnergyAllFrames.size();\n+\t    float mLogEnergyMeanCurrFrames = mLogEnergySumAllFrames / totalFramesSeen;\n+            if (mLogEnergyMeanPrevFrames == 100000.0)\n+            {\n+              \tmLogEnergyMeanPrevFrames = mLogEnergyMeanCurrFrames;   \n+            }\n+            else\n+            {\n+            \tmLogEnergyMeanCurrFrames = 0.9*mLogEnergyMeanPrevFrames + 0.1*mLogEnergyMeanCurrFrames;\n+            \tmLogEnergyMeanPrevFrames = mLogEnergyMeanCurrFrames;\n+            }\n             if (mVadOptions.vad_energy_mean_scale != 0.0)\n             {\n                 KALDI_ASSERT(mVadOptions.vad_energy_mean_scale > 0.0);\n-                energyThreshold += mVadOptions.vad_energy_mean_scale * mLogEnergySumAllFrames / totalFramesSeen;\n+                energyThreshold += mVadOptions.vad_energy_mean_scale * mLogEnergyMeanCurrFrames; \n             }\n \n             KALDI_ASSERT(mVadOptions.vad_frames_context >= 0);\n             KALDI_ASSERT(mVadOptions.vad_proportion_threshold > 0.0 &&\n                          mVadOptions.vad_proportion_threshold < 1.0);\n             // iterate over new frames seen.\n-            for (int frame = previousFramesSeen; frame < totalFramesSeen; frame++)\n-            {\n-                int context = mVadOptions.vad_frames_context;\n-                int numFramesAboveThreshold = 0;\n-                int denCount = 0;\n-                // moving window of frames\n-                for (int windowedFrame = frame - context; windowedFrame <= frame + context; windowedFrame++)\n-                {\n-                    // accumulate stats when moving window within range\n-                    if (windowedFrame >= 0 && windowedFrame < totalFramesSeen)\n-                    {\n-                        denCount++;\n-                        if (mLogEnergyAllFrames[frame] > energyThreshold)\n-                        {\n+\t    for (int frame = previousFramesSeen; frame < totalFramesSeen; frame++)\n+\t    {\n+    \t\tint context = mVadOptions.vad_frames_context;\n+    \t\tint numFramesAboveThreshold = 0;\n+\t\tint numFramesBelowThreshold = 0;\n+    \t\tint denCount = 0;\n+    \t\t// moving window of frames\n+    \t\tif (flagInSpeech == 0)   // if current frame is silence event\n+    \t\t{\n+        \t   for (int windowedFrame = frame - context; windowedFrame <= frame + context; windowedFrame++)\n+            \t   {\n+                      // accumulate stats when moving window within range\n+                      if (windowedFrame >= 0 && windowedFrame < totalFramesSeen) \n+                      {\n+                         denCount++;\n+                    \t if (mLogEnergyAllFrames[windowedFrame] > energyThreshold)\n+                    \t {\n                             numFramesAboveThreshold++;\n-                        }\n-                    }\n-                 }\n-                 const bool frameInSpeech = (numFramesAboveThreshold >= denCount * mVadOptions.vad_proportion_threshold);\n-                 outputVoiced->push_back(frameInSpeech);\n-            }\n+                    \t }\n+                      }\n+            \t    }\n+            \t    const bool frameInSpeech = (numFramesAboveThreshold >= denCount * mVadOptions.vad_proportion_threshold);\n+            \t    outputVoiced->push_back(frameInSpeech);\n+            \t    if (frameInSpeech == 1)\n+            \t       \t{\n+                \t    flagInSpeech = 1;\n+            \t\t}\n+                \n+    \t\t}\n+    \t\telse   // if current frame is speech event\n+    \t\t{\n+        \t   for (int windowedFrame = frame - context; windowedFrame <= frame + context; windowedFrame++)\n+            \t   {\n+                       // accumulate stats when moving window within range\n+                       if (windowedFrame >= 0 && windowedFrame < totalFramesSeen) \n+                       {\n+                          denCount++;\n+                    \t  if (mLogEnergyAllFrames[windowedFrame] < energyThreshold)\n+                    \t  {\n+                             numFramesBelowThreshold++;\n+                    \t  }\n+                       }\n+            \t    }\n+            \t    const bool frameInSpeech = (numFramesBelowThreshold <= denCount * mVadOptions.vad_proportion_threshold);","path":"cpp/detector/kaldi_vad_detector.h","position":97,"original_position":97,"commit_id":"17d3920b88ee7ab370c7bb9dbbe0a4468a1e32b3","original_commit_id":"17d3920b88ee7ab370c7bb9dbbe0a4468a1e32b3","user":{"login":"rslish","id":16883437,"avatar_url":"https://avatars.githubusercontent.com/u/16883437?v=3","gravatar_id":"","url":"https://api.github.com/users/rslish","html_url":"https://github.com/rslish","followers_url":"https://api.github.com/users/rslish/followers","following_url":"https://api.github.com/users/rslish/following{/other_user}","gists_url":"https://api.github.com/users/rslish/gists{/gist_id}","starred_url":"https://api.github.com/users/rslish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rslish/subscriptions","organizations_url":"https://api.github.com/users/rslish/orgs","repos_url":"https://api.github.com/users/rslish/repos","events_url":"https://api.github.com/users/rslish/events{/privacy}","received_events_url":"https://api.github.com/users/rslish/received_events","type":"User","site_admin":false},"body":"I may be misunderstanding what's going on here, but does it really make a difference to determine frameInSpeech differently depending on the value of flagInSpeech? If 7/10 frames are above energyThreshold, then 3 are below energyThreshold (unless some are equal to energyThreshold). Suppose denCount * vad_proportion_threshold = 5, then 3 < 5 is the same as 7 > 5. So the only difference is if the numFramesBelowThreshold or numFramesAboveThreshold is equal to 5. Have you tested to see if this part makes an actual difference?","created_at":"2016-05-06T16:50:54Z","updated_at":"2016-05-06T16:50:54Z","html_url":"https://github.com/cobaltspeech/cobalt-vad/pull/11#discussion_r62356827","pull_request_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/comments/62356827"},"html":{"href":"https://github.com/cobaltspeech/cobalt-vad/pull/11#discussion_r62356827"},"pull_request":{"href":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/11","id":68745663,"html_url":"https://github.com/cobaltspeech/cobalt-vad/pull/11","diff_url":"https://github.com/cobaltspeech/cobalt-vad/pull/11.diff","patch_url":"https://github.com/cobaltspeech/cobalt-vad/pull/11.patch","issue_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/issues/11","number":11,"state":"open","locked":false,"title":"changes made to reduce number of speech segments","user":{"login":"arifulhaque","id":16719341,"avatar_url":"https://avatars.githubusercontent.com/u/16719341?v=3","gravatar_id":"","url":"https://api.github.com/users/arifulhaque","html_url":"https://github.com/arifulhaque","followers_url":"https://api.github.com/users/arifulhaque/followers","following_url":"https://api.github.com/users/arifulhaque/following{/other_user}","gists_url":"https://api.github.com/users/arifulhaque/gists{/gist_id}","starred_url":"https://api.github.com/users/arifulhaque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arifulhaque/subscriptions","organizations_url":"https://api.github.com/users/arifulhaque/orgs","repos_url":"https://api.github.com/users/arifulhaque/repos","events_url":"https://api.github.com/users/arifulhaque/events{/privacy}","received_events_url":"https://api.github.com/users/arifulhaque/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-03T17:44:04Z","updated_at":"2016-05-06T16:50:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ddfad8fb754a2808731629ceb76ba6358e9f6782","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/11/commits","review_comments_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/11/comments","review_comment_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/issues/11/comments","statuses_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/statuses/17d3920b88ee7ab370c7bb9dbbe0a4468a1e32b3","head":{"label":"cobaltspeech:arif","ref":"arif","sha":"17d3920b88ee7ab370c7bb9dbbe0a4468a1e32b3","user":{"login":"cobaltspeech","id":15947802,"avatar_url":"https://avatars.githubusercontent.com/u/15947802?v=3","gravatar_id":"","url":"https://api.github.com/users/cobaltspeech","html_url":"https://github.com/cobaltspeech","followers_url":"https://api.github.com/users/cobaltspeech/followers","following_url":"https://api.github.com/users/cobaltspeech/following{/other_user}","gists_url":"https://api.github.com/users/cobaltspeech/gists{/gist_id}","starred_url":"https://api.github.com/users/cobaltspeech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cobaltspeech/subscriptions","organizations_url":"https://api.github.com/users/cobaltspeech/orgs","repos_url":"https://api.github.com/users/cobaltspeech/repos","events_url":"https://api.github.com/users/cobaltspeech/events{/privacy}","received_events_url":"https://api.github.com/users/cobaltspeech/received_events","type":"Organization","site_admin":false},"repo":{"id":52829644,"name":"cobalt-vad","full_name":"cobaltspeech/cobalt-vad","owner":{"login":"cobaltspeech","id":15947802,"avatar_url":"https://avatars.githubusercontent.com/u/15947802?v=3","gravatar_id":"","url":"https://api.github.com/users/cobaltspeech","html_url":"https://github.com/cobaltspeech","followers_url":"https://api.github.com/users/cobaltspeech/followers","following_url":"https://api.github.com/users/cobaltspeech/following{/other_user}","gists_url":"https://api.github.com/users/cobaltspeech/gists{/gist_id}","starred_url":"https://api.github.com/users/cobaltspeech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cobaltspeech/subscriptions","organizations_url":"https://api.github.com/users/cobaltspeech/orgs","repos_url":"https://api.github.com/users/cobaltspeech/repos","events_url":"https://api.github.com/users/cobaltspeech/events{/privacy}","received_events_url":"https://api.github.com/users/cobaltspeech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cobaltspeech/cobalt-vad","description":"Cobalt stand-alone VAD library & tool","fork":false,"url":"https://api.github.com/repos/cobaltspeech/cobalt-vad","forks_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/forks","keys_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/teams","hooks_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/hooks","issue_events_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/issues/events{/number}","events_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/events","assignees_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/assignees{/user}","branches_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/branches{/branch}","tags_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/tags","blobs_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/git/refs{/sha}","trees_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/statuses/{sha}","languages_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/languages","stargazers_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/stargazers","contributors_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/contributors","subscribers_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/subscribers","subscription_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/subscription","commits_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/commits{/sha}","git_commits_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/git/commits{/sha}","comments_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/comments{/number}","issue_comment_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/issues/comments{/number}","contents_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/contents/{+path}","compare_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/merges","archive_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/downloads","issues_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/issues{/number}","pulls_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls{/number}","milestones_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/milestones{/number}","notifications_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/labels{/name}","releases_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/releases{/id}","deployments_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/deployments","created_at":"2016-02-29T22:29:00Z","updated_at":"2016-03-15T17:06:44Z","pushed_at":"2016-05-06T16:44:00Z","git_url":"git://github.com/cobaltspeech/cobalt-vad.git","ssh_url":"git@github.com:cobaltspeech/cobalt-vad.git","clone_url":"https://github.com/cobaltspeech/cobalt-vad.git","svn_url":"https://github.com/cobaltspeech/cobalt-vad","homepage":null,"size":299,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"cobaltspeech:master","ref":"master","sha":"70748ce1ff1b58bff33eb66cd359de98ec08e2bc","user":{"login":"cobaltspeech","id":15947802,"avatar_url":"https://avatars.githubusercontent.com/u/15947802?v=3","gravatar_id":"","url":"https://api.github.com/users/cobaltspeech","html_url":"https://github.com/cobaltspeech","followers_url":"https://api.github.com/users/cobaltspeech/followers","following_url":"https://api.github.com/users/cobaltspeech/following{/other_user}","gists_url":"https://api.github.com/users/cobaltspeech/gists{/gist_id}","starred_url":"https://api.github.com/users/cobaltspeech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cobaltspeech/subscriptions","organizations_url":"https://api.github.com/users/cobaltspeech/orgs","repos_url":"https://api.github.com/users/cobaltspeech/repos","events_url":"https://api.github.com/users/cobaltspeech/events{/privacy}","received_events_url":"https://api.github.com/users/cobaltspeech/received_events","type":"Organization","site_admin":false},"repo":{"id":52829644,"name":"cobalt-vad","full_name":"cobaltspeech/cobalt-vad","owner":{"login":"cobaltspeech","id":15947802,"avatar_url":"https://avatars.githubusercontent.com/u/15947802?v=3","gravatar_id":"","url":"https://api.github.com/users/cobaltspeech","html_url":"https://github.com/cobaltspeech","followers_url":"https://api.github.com/users/cobaltspeech/followers","following_url":"https://api.github.com/users/cobaltspeech/following{/other_user}","gists_url":"https://api.github.com/users/cobaltspeech/gists{/gist_id}","starred_url":"https://api.github.com/users/cobaltspeech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cobaltspeech/subscriptions","organizations_url":"https://api.github.com/users/cobaltspeech/orgs","repos_url":"https://api.github.com/users/cobaltspeech/repos","events_url":"https://api.github.com/users/cobaltspeech/events{/privacy}","received_events_url":"https://api.github.com/users/cobaltspeech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cobaltspeech/cobalt-vad","description":"Cobalt stand-alone VAD library & tool","fork":false,"url":"https://api.github.com/repos/cobaltspeech/cobalt-vad","forks_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/forks","keys_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/teams","hooks_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/hooks","issue_events_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/issues/events{/number}","events_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/events","assignees_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/assignees{/user}","branches_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/branches{/branch}","tags_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/tags","blobs_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/git/refs{/sha}","trees_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/statuses/{sha}","languages_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/languages","stargazers_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/stargazers","contributors_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/contributors","subscribers_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/subscribers","subscription_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/subscription","commits_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/commits{/sha}","git_commits_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/git/commits{/sha}","comments_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/comments{/number}","issue_comment_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/issues/comments{/number}","contents_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/contents/{+path}","compare_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/merges","archive_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/downloads","issues_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/issues{/number}","pulls_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls{/number}","milestones_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/milestones{/number}","notifications_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/labels{/name}","releases_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/releases{/id}","deployments_url":"https://api.github.com/repos/cobaltspeech/cobalt-vad/deployments","created_at":"2016-02-29T22:29:00Z","updated_at":"2016-03-15T17:06:44Z","pushed_at":"2016-05-06T16:44:00Z","git_url":"git://github.com/cobaltspeech/cobalt-vad.git","ssh_url":"git@github.com:cobaltspeech/cobalt-vad.git","clone_url":"https://github.com/cobaltspeech/cobalt-vad.git","svn_url":"https://github.com/cobaltspeech/cobalt-vad","homepage":null,"size":299,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/11"},"html":{"href":"https://github.com/cobaltspeech/cobalt-vad/pull/11"},"issue":{"href":"https://api.github.com/repos/cobaltspeech/cobalt-vad/issues/11"},"comments":{"href":"https://api.github.com/repos/cobaltspeech/cobalt-vad/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cobaltspeech/cobalt-vad/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/cobaltspeech/cobalt-vad/statuses/17d3920b88ee7ab370c7bb9dbbe0a4468a1e32b3"}}}}