2018-04-17 15:58:40 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_COMMON_H_
|
|
|
|
|
#define MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_COMMON_H_
|
|
|
|
|
|
2019-11-06 14:42:32 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
2018-04-17 15:58:40 +02:00
|
|
|
namespace webrtc {
|
|
|
|
|
namespace rnn_vad {
|
|
|
|
|
|
2018-05-07 16:53:50 +02:00
|
|
|
constexpr double kPi = 3.14159265358979323846;
|
|
|
|
|
|
2020-10-29 20:50:13 +01:00
|
|
|
constexpr int kSampleRate24kHz = 24000;
|
|
|
|
|
constexpr int kFrameSize10ms24kHz = kSampleRate24kHz / 100;
|
|
|
|
|
constexpr int kFrameSize20ms24kHz = kFrameSize10ms24kHz * 2;
|
2018-04-19 17:56:55 +02:00
|
|
|
|
2019-04-02 06:58:45 +00:00
|
|
|
// Pitch buffer.
|
2020-10-29 20:50:13 +01:00
|
|
|
constexpr int kMinPitch24kHz = kSampleRate24kHz / 800; // 0.00125 s.
|
|
|
|
|
constexpr int kMaxPitch24kHz = kSampleRate24kHz / 62.5; // 0.016 s.
|
|
|
|
|
constexpr int kBufSize24kHz = kMaxPitch24kHz + kFrameSize20ms24kHz;
|
2018-04-19 17:56:55 +02:00
|
|
|
static_assert((kBufSize24kHz & 1) == 0, "The buffer size must be even.");
|
2018-04-17 15:58:40 +02:00
|
|
|
|
2019-04-02 06:58:45 +00:00
|
|
|
// 24 kHz analysis.
|
2018-04-27 16:44:11 +02:00
|
|
|
// Define a higher minimum pitch period for the initial search. This is used to
|
|
|
|
|
// avoid searching for very short periods, for which a refinement step is
|
|
|
|
|
// responsible.
|
2020-10-29 20:50:13 +01:00
|
|
|
constexpr int kInitialMinPitch24kHz = 3 * kMinPitch24kHz;
|
2018-04-27 16:44:11 +02:00
|
|
|
static_assert(kMinPitch24kHz < kInitialMinPitch24kHz, "");
|
|
|
|
|
static_assert(kInitialMinPitch24kHz < kMaxPitch24kHz, "");
|
2019-04-02 06:58:45 +00:00
|
|
|
static_assert(kMaxPitch24kHz > kInitialMinPitch24kHz, "");
|
2020-11-11 12:06:09 +01:00
|
|
|
// Number of (inverted) lags during the initial pitch search phase at 24 kHz.
|
|
|
|
|
constexpr int kInitialNumLags24kHz = kMaxPitch24kHz - kInitialMinPitch24kHz;
|
|
|
|
|
// Number of (inverted) lags during the pitch search refinement phase at 24 kHz.
|
|
|
|
|
constexpr int kRefineNumLags24kHz = kMaxPitch24kHz + 1;
|
|
|
|
|
static_assert(
|
|
|
|
|
kRefineNumLags24kHz > kInitialNumLags24kHz,
|
|
|
|
|
"The refinement step must search the pitch in an extended pitch range.");
|
2018-04-27 16:44:11 +02:00
|
|
|
|
|
|
|
|
// 12 kHz analysis.
|
2020-10-29 20:50:13 +01:00
|
|
|
constexpr int kSampleRate12kHz = 12000;
|
|
|
|
|
constexpr int kFrameSize10ms12kHz = kSampleRate12kHz / 100;
|
|
|
|
|
constexpr int kFrameSize20ms12kHz = kFrameSize10ms12kHz * 2;
|
|
|
|
|
constexpr int kBufSize12kHz = kBufSize24kHz / 2;
|
|
|
|
|
constexpr int kInitialMinPitch12kHz = kInitialMinPitch24kHz / 2;
|
|
|
|
|
constexpr int kMaxPitch12kHz = kMaxPitch24kHz / 2;
|
2019-04-02 06:58:45 +00:00
|
|
|
static_assert(kMaxPitch12kHz > kInitialMinPitch12kHz, "");
|
2021-07-28 20:50:03 +02:00
|
|
|
// The inverted lags for the pitch interval [`kInitialMinPitch12kHz`,
|
|
|
|
|
// `kMaxPitch12kHz`] are in the range [0, `kNumLags12kHz`].
|
2020-11-11 12:06:09 +01:00
|
|
|
constexpr int kNumLags12kHz = kMaxPitch12kHz - kInitialMinPitch12kHz;
|
2018-04-27 16:44:11 +02:00
|
|
|
|
|
|
|
|
// 48 kHz constants.
|
2020-10-29 20:50:13 +01:00
|
|
|
constexpr int kMinPitch48kHz = kMinPitch24kHz * 2;
|
|
|
|
|
constexpr int kMaxPitch48kHz = kMaxPitch24kHz * 2;
|
2018-04-27 16:44:11 +02:00
|
|
|
|
2019-04-10 09:36:21 +02:00
|
|
|
// Spectral features.
|
2020-10-29 20:50:13 +01:00
|
|
|
constexpr int kNumBands = 22;
|
|
|
|
|
constexpr int kNumLowerBands = 6;
|
2018-05-09 13:40:38 +02:00
|
|
|
static_assert((0 < kNumLowerBands) && (kNumLowerBands < kNumBands), "");
|
2020-10-29 20:50:13 +01:00
|
|
|
constexpr int kCepstralCoeffsHistorySize = 8;
|
2019-04-10 09:36:21 +02:00
|
|
|
static_assert(kCepstralCoeffsHistorySize > 2,
|
2018-05-09 13:40:38 +02:00
|
|
|
"The history size must at least be 3 to compute first and second "
|
|
|
|
|
"derivatives.");
|
|
|
|
|
|
2020-10-29 20:50:13 +01:00
|
|
|
constexpr int kFeatureVectorSize = 42;
|
Reland "Reland "AGC2 RNN VAD: Recurrent Neural Network impl""
This reverts commit 3c9f47434f0af3b16f1b8f43cd4500be6fd2ac17.
Reason for revert: downstream projects fixed
Original change's description:
> Revert "Reland "AGC2 RNN VAD: Recurrent Neural Network impl""
>
> This reverts commit e0bba68edea74ca33f4c492eba290c089f233f6b.
>
> Reason for revert: <INSERT REASONING HERE>
>
> Original change's description:
> > Reland "AGC2 RNN VAD: Recurrent Neural Network impl"
> >
> > This reverts commit 97e349ace7a3fd64fff270f0d780e02bb708f503.
> >
> > Reason for revert: downstream projects fixed
> >
> > Original change's description:
> > > Revert "AGC2 RNN VAD: Recurrent Neural Network impl"
> > >
> > > This reverts commit 2491cb73820fe82923b848dfcab6772b4b0addb0.
> > >
> > > Reason for revert: broke internal build
> > >
> > > Original change's description:
> > > > AGC2 RNN VAD: Recurrent Neural Network impl
> > > >
> > > > RNN implementation for the AGC2 VAD that includes a fully connected
> > > > layer and a gated recurrent unit layer.
> > > >
> > > > Bug: webrtc:9076
> > > > Change-Id: Ibb8b0b4e9213f09eb9dbe118bbdc94d7e8e4f91b
> > > > Reviewed-on: https://webrtc-review.googlesource.com/72060
> > > > Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
> > > > Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> > > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > > > Cr-Commit-Position: refs/heads/master@{#23101}
> > >
> > > TBR=phoglund@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org
> > >
> > > Change-Id: Ic311c4b7d79094e959d3a2c4a53c398f34c954e2
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: webrtc:9076
> > > Reviewed-on: https://webrtc-review.googlesource.com/74200
> > > Reviewed-by: Sam Zackrisson <saza@webrtc.org>
> > > Commit-Queue: Sam Zackrisson <saza@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#23103}
> >
> > TBR=phoglund@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org
> >
> > Change-Id: I0c7f8e0f59be926322d05b1da1d4d19c0777dab2
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: webrtc:9076
> > Reviewed-on: https://webrtc-review.googlesource.com/74460
> > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#23113}
>
> TBR=phoglund@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org
>
> Change-Id: I3985a6d38df1d4438a50d031bc9f6cf41eb83121
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:9076
> Reviewed-on: https://webrtc-review.googlesource.com/74560
> Reviewed-by: Sam Zackrisson <saza@webrtc.org>
> Commit-Queue: Sam Zackrisson <saza@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#23117}
TBR=phoglund@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:9076
Change-Id: I4d81786837017d4daf0dbb1218306795b977ade5
Reviewed-on: https://webrtc-review.googlesource.com/74760
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23138}
2018-05-07 09:29:54 +00:00
|
|
|
|
2018-04-17 15:58:40 +02:00
|
|
|
} // namespace rnn_vad
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_COMMON_H_
|