Migrate WebRTC test infra to ABSL_FLAG.
This is the last CL required to migrate WebRTC to ABSL_FLAG, rtc::Flag will be removed soon after this one lands. Bug: webrtc:10616 Change-Id: I2807cec39e28a2737d2c49e2dc23f2a6f98d08f0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145727 Reviewed-by: Tommi <tommi@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28606}
This commit is contained in:
committed by
Commit Bot
parent
63741c7fa1
commit
2ab97f6f8e
@ -641,6 +641,8 @@ if (rtc_include_tests) {
|
||||
"aec_dump",
|
||||
"aec_dump:aec_dump_impl",
|
||||
"//testing/gtest",
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/flags:parse",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
@ -713,6 +715,8 @@ if (rtc_include_tests) {
|
||||
"../../test:test_support",
|
||||
"agc:level_estimation",
|
||||
"//testing/gtest",
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/flags:parse",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -18,21 +18,253 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/parse.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "modules/audio_processing/include/audio_processing.h"
|
||||
#include "modules/audio_processing/test/aec_dump_based_simulator.h"
|
||||
#include "modules/audio_processing/test/audio_processing_simulator.h"
|
||||
#include "modules/audio_processing/test/wav_based_simulator.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/flags.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
|
||||
constexpr int kParameterNotSpecifiedValue = -10000;
|
||||
|
||||
ABSL_FLAG(std::string, dump_input, "", "Aec dump input filename");
|
||||
ABSL_FLAG(std::string, dump_output, "", "Aec dump output filename");
|
||||
ABSL_FLAG(std::string, i, "", "Forward stream input wav filename");
|
||||
ABSL_FLAG(std::string, o, "", "Forward stream output wav filename");
|
||||
ABSL_FLAG(std::string, ri, "", "Reverse stream input wav filename");
|
||||
ABSL_FLAG(std::string, ro, "", "Reverse stream output wav filename");
|
||||
ABSL_FLAG(std::string,
|
||||
artificial_nearend,
|
||||
"",
|
||||
"Artificial nearend wav filename");
|
||||
ABSL_FLAG(int,
|
||||
output_num_channels,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Number of forward stream output channels");
|
||||
ABSL_FLAG(int,
|
||||
reverse_output_num_channels,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Number of Reverse stream output channels");
|
||||
ABSL_FLAG(int,
|
||||
output_sample_rate_hz,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Forward stream output sample rate in Hz");
|
||||
ABSL_FLAG(int,
|
||||
reverse_output_sample_rate_hz,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Reverse stream output sample rate in Hz");
|
||||
ABSL_FLAG(bool,
|
||||
fixed_interface,
|
||||
false,
|
||||
"Use the fixed interface when operating on wav files");
|
||||
ABSL_FLAG(int,
|
||||
aec,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the echo canceller");
|
||||
ABSL_FLAG(int,
|
||||
aecm,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the mobile echo controller");
|
||||
ABSL_FLAG(int,
|
||||
ed,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate (0) the residual echo detector");
|
||||
ABSL_FLAG(std::string,
|
||||
ed_graph,
|
||||
"",
|
||||
"Output filename for graph of echo likelihood");
|
||||
ABSL_FLAG(int,
|
||||
agc,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AGC");
|
||||
ABSL_FLAG(int,
|
||||
agc2,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AGC2");
|
||||
ABSL_FLAG(int,
|
||||
pre_amplifier,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the pre amplifier");
|
||||
ABSL_FLAG(int,
|
||||
hpf,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the high-pass filter");
|
||||
ABSL_FLAG(int,
|
||||
ns,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the noise suppressor");
|
||||
ABSL_FLAG(int,
|
||||
ts,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the transient suppressor");
|
||||
ABSL_FLAG(int,
|
||||
vad,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the voice activity detector");
|
||||
ABSL_FLAG(int,
|
||||
le,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the level estimator");
|
||||
ABSL_FLAG(bool,
|
||||
all_default,
|
||||
false,
|
||||
"Activate all of the default components (will be overridden by any "
|
||||
"other settings)");
|
||||
ABSL_FLAG(int,
|
||||
aec_suppression_level,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Set the aec suppression level (0-2)");
|
||||
ABSL_FLAG(int,
|
||||
delay_agnostic,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AEC delay agnostic mode");
|
||||
ABSL_FLAG(int,
|
||||
extended_filter,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AEC extended filter mode");
|
||||
ABSL_FLAG(int,
|
||||
use_legacy_aec,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the legacy AEC");
|
||||
ABSL_FLAG(int,
|
||||
experimental_agc,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the experimental AGC");
|
||||
ABSL_FLAG(int,
|
||||
experimental_agc_disable_digital_adaptive,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Force-deactivate (1) digital adaptation in "
|
||||
"experimental AGC. Digital adaptation is active by default (0).");
|
||||
ABSL_FLAG(int,
|
||||
experimental_agc_analyze_before_aec,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Make level estimation happen before AEC"
|
||||
" in the experimental AGC. After AEC is the default (0)");
|
||||
ABSL_FLAG(int,
|
||||
experimental_agc_agc2_level_estimator,
|
||||
kParameterNotSpecifiedValue,
|
||||
"AGC2 level estimation"
|
||||
" in the experimental AGC. AGC1 level estimation is the default (0)");
|
||||
ABSL_FLAG(
|
||||
int,
|
||||
refined_adaptive_filter,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the refined adaptive filter functionality");
|
||||
ABSL_FLAG(int,
|
||||
agc_mode,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the AGC mode (0-2)");
|
||||
ABSL_FLAG(int,
|
||||
agc_target_level,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the AGC target level (0-31)");
|
||||
ABSL_FLAG(int,
|
||||
agc_limiter,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the level estimator");
|
||||
ABSL_FLAG(int,
|
||||
agc_compression_gain,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the AGC compression gain (0-90)");
|
||||
ABSL_FLAG(int,
|
||||
agc2_enable_adaptive_gain,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AGC2 adaptive gain");
|
||||
ABSL_FLAG(float,
|
||||
agc2_fixed_gain_db,
|
||||
kParameterNotSpecifiedValue,
|
||||
"AGC2 fixed gain (dB) to apply");
|
||||
ABSL_FLAG(std::string,
|
||||
agc2_adaptive_level_estimator,
|
||||
"RMS",
|
||||
"AGC2 adaptive digital level estimator to use [RMS, peak]");
|
||||
ABSL_FLAG(float,
|
||||
pre_amplifier_gain_factor,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Pre-amplifier gain factor (linear) to apply");
|
||||
ABSL_FLAG(int,
|
||||
vad_likelihood,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the VAD likelihood (0-3)");
|
||||
ABSL_FLAG(int,
|
||||
ns_level,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the NS level (0-3)");
|
||||
ABSL_FLAG(int,
|
||||
stream_delay,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the stream delay in ms to use");
|
||||
ABSL_FLAG(int,
|
||||
use_stream_delay,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) reporting the stream delay");
|
||||
ABSL_FLAG(int,
|
||||
stream_drift_samples,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the number of stream drift samples to use");
|
||||
ABSL_FLAG(int, initial_mic_level, 100, "Initial mic level (0-255)");
|
||||
ABSL_FLAG(int,
|
||||
simulate_mic_gain,
|
||||
0,
|
||||
"Activate (1) or deactivate(0) the analog mic gain simulation");
|
||||
ABSL_FLAG(int,
|
||||
simulated_mic_kind,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify which microphone kind to use for microphone simulation");
|
||||
ABSL_FLAG(bool, performance_report, false, "Report the APM performance ");
|
||||
ABSL_FLAG(std::string,
|
||||
performance_report_output_file,
|
||||
"",
|
||||
"Generate a CSV file with the API call durations");
|
||||
ABSL_FLAG(bool, verbose, false, "Produce verbose output");
|
||||
ABSL_FLAG(bool,
|
||||
quiet,
|
||||
false,
|
||||
"Avoid producing information about the progress.");
|
||||
ABSL_FLAG(bool,
|
||||
bitexactness_report,
|
||||
false,
|
||||
"Report bitexactness for aec dump result reproduction");
|
||||
ABSL_FLAG(bool,
|
||||
discard_settings_in_aecdump,
|
||||
false,
|
||||
"Discard any config settings specified in the aec dump");
|
||||
ABSL_FLAG(bool,
|
||||
store_intermediate_output,
|
||||
false,
|
||||
"Creates new output files after each init");
|
||||
ABSL_FLAG(std::string,
|
||||
custom_call_order_file,
|
||||
"",
|
||||
"Custom process API call order file");
|
||||
ABSL_FLAG(std::string,
|
||||
output_custom_call_order_file,
|
||||
"",
|
||||
"Generate custom process API call order file from AEC dump");
|
||||
ABSL_FLAG(bool,
|
||||
print_aec_parameter_values,
|
||||
false,
|
||||
"Print parameter values used in AEC in JSON-format");
|
||||
ABSL_FLAG(std::string,
|
||||
aec_settings,
|
||||
"",
|
||||
"File in JSON-format with custom AEC settings");
|
||||
ABSL_FLAG(bool,
|
||||
dump_data,
|
||||
false,
|
||||
"Dump internal data during the call (requires build flag)");
|
||||
ABSL_FLAG(std::string,
|
||||
dump_data_output_dir,
|
||||
"",
|
||||
"Internal data dump output directory");
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
namespace {
|
||||
|
||||
const int kParameterNotSpecifiedValue = -10000;
|
||||
|
||||
const char kUsageDescription[] =
|
||||
"Usage: audioproc_f [options] -i <input.wav>\n"
|
||||
" or\n"
|
||||
@ -42,194 +274,9 @@ const char kUsageDescription[] =
|
||||
"processing module, either based on wav files or "
|
||||
"protobuf debug dump recordings.\n";
|
||||
|
||||
WEBRTC_DEFINE_string(dump_input, "", "Aec dump input filename");
|
||||
WEBRTC_DEFINE_string(dump_output, "", "Aec dump output filename");
|
||||
WEBRTC_DEFINE_string(i, "", "Forward stream input wav filename");
|
||||
WEBRTC_DEFINE_string(o, "", "Forward stream output wav filename");
|
||||
WEBRTC_DEFINE_string(ri, "", "Reverse stream input wav filename");
|
||||
WEBRTC_DEFINE_string(ro, "", "Reverse stream output wav filename");
|
||||
WEBRTC_DEFINE_string(artificial_nearend, "", "Artificial nearend wav filename");
|
||||
WEBRTC_DEFINE_int(output_num_channels,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Number of forward stream output channels");
|
||||
WEBRTC_DEFINE_int(reverse_output_num_channels,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Number of Reverse stream output channels");
|
||||
WEBRTC_DEFINE_int(output_sample_rate_hz,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Forward stream output sample rate in Hz");
|
||||
WEBRTC_DEFINE_int(reverse_output_sample_rate_hz,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Reverse stream output sample rate in Hz");
|
||||
WEBRTC_DEFINE_bool(fixed_interface,
|
||||
false,
|
||||
"Use the fixed interface when operating on wav files");
|
||||
WEBRTC_DEFINE_int(aec,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the echo canceller");
|
||||
WEBRTC_DEFINE_int(aecm,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the mobile echo controller");
|
||||
WEBRTC_DEFINE_int(ed,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate (0) the residual echo detector");
|
||||
WEBRTC_DEFINE_string(ed_graph,
|
||||
"",
|
||||
"Output filename for graph of echo likelihood");
|
||||
WEBRTC_DEFINE_int(agc,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AGC");
|
||||
WEBRTC_DEFINE_int(agc2,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AGC2");
|
||||
WEBRTC_DEFINE_int(pre_amplifier,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the pre amplifier");
|
||||
WEBRTC_DEFINE_int(hpf,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the high-pass filter");
|
||||
WEBRTC_DEFINE_int(ns,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the noise suppressor");
|
||||
WEBRTC_DEFINE_int(ts,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the transient suppressor");
|
||||
WEBRTC_DEFINE_int(vad,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the voice activity detector");
|
||||
WEBRTC_DEFINE_int(le,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the level estimator");
|
||||
WEBRTC_DEFINE_bool(
|
||||
all_default,
|
||||
false,
|
||||
"Activate all of the default components (will be overridden by any "
|
||||
"other settings)");
|
||||
WEBRTC_DEFINE_int(aec_suppression_level,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Set the aec suppression level (0-2)");
|
||||
WEBRTC_DEFINE_int(delay_agnostic,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AEC delay agnostic mode");
|
||||
WEBRTC_DEFINE_int(extended_filter,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AEC extended filter mode");
|
||||
WEBRTC_DEFINE_int(use_legacy_aec,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the legacy AEC");
|
||||
WEBRTC_DEFINE_int(experimental_agc,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the experimental AGC");
|
||||
WEBRTC_DEFINE_int(
|
||||
experimental_agc_disable_digital_adaptive,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Force-deactivate (1) digital adaptation in "
|
||||
"experimental AGC. Digital adaptation is active by default (0).");
|
||||
WEBRTC_DEFINE_int(experimental_agc_analyze_before_aec,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Make level estimation happen before AEC"
|
||||
" in the experimental AGC. After AEC is the default (0)");
|
||||
WEBRTC_DEFINE_int(
|
||||
experimental_agc_agc2_level_estimator,
|
||||
kParameterNotSpecifiedValue,
|
||||
"AGC2 level estimation"
|
||||
" in the experimental AGC. AGC1 level estimation is the default (0)");
|
||||
WEBRTC_DEFINE_int(
|
||||
refined_adaptive_filter,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the refined adaptive filter functionality");
|
||||
WEBRTC_DEFINE_int(agc_mode,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the AGC mode (0-2)");
|
||||
WEBRTC_DEFINE_int(agc_target_level,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the AGC target level (0-31)");
|
||||
WEBRTC_DEFINE_int(agc_limiter,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the level estimator");
|
||||
WEBRTC_DEFINE_int(agc_compression_gain,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the AGC compression gain (0-90)");
|
||||
WEBRTC_DEFINE_int(agc2_enable_adaptive_gain,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AGC2 adaptive gain");
|
||||
WEBRTC_DEFINE_float(agc2_fixed_gain_db,
|
||||
kParameterNotSpecifiedValue,
|
||||
"AGC2 fixed gain (dB) to apply");
|
||||
|
||||
std::vector<std::string> GetAgc2AdaptiveLevelEstimatorNames() {
|
||||
return {"RMS", "peak"};
|
||||
}
|
||||
WEBRTC_DEFINE_string(
|
||||
agc2_adaptive_level_estimator,
|
||||
"RMS",
|
||||
"AGC2 adaptive digital level estimator to use [RMS, peak]");
|
||||
|
||||
WEBRTC_DEFINE_float(pre_amplifier_gain_factor,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Pre-amplifier gain factor (linear) to apply");
|
||||
WEBRTC_DEFINE_int(vad_likelihood,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the VAD likelihood (0-3)");
|
||||
WEBRTC_DEFINE_int(ns_level,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the NS level (0-3)");
|
||||
WEBRTC_DEFINE_int(stream_delay,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the stream delay in ms to use");
|
||||
WEBRTC_DEFINE_int(use_stream_delay,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) reporting the stream delay");
|
||||
WEBRTC_DEFINE_int(stream_drift_samples,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the number of stream drift samples to use");
|
||||
WEBRTC_DEFINE_int(initial_mic_level, 100, "Initial mic level (0-255)");
|
||||
WEBRTC_DEFINE_int(
|
||||
simulate_mic_gain,
|
||||
0,
|
||||
"Activate (1) or deactivate(0) the analog mic gain simulation");
|
||||
WEBRTC_DEFINE_int(
|
||||
simulated_mic_kind,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify which microphone kind to use for microphone simulation");
|
||||
WEBRTC_DEFINE_bool(performance_report, false, "Report the APM performance ");
|
||||
WEBRTC_DEFINE_string(performance_report_output_file,
|
||||
"",
|
||||
"Generate a CSV file with the API call durations");
|
||||
|
||||
WEBRTC_DEFINE_bool(verbose, false, "Produce verbose output");
|
||||
WEBRTC_DEFINE_bool(quiet,
|
||||
false,
|
||||
"Avoid producing information about the progress.");
|
||||
WEBRTC_DEFINE_bool(bitexactness_report,
|
||||
false,
|
||||
"Report bitexactness for aec dump result reproduction");
|
||||
WEBRTC_DEFINE_bool(discard_settings_in_aecdump,
|
||||
false,
|
||||
"Discard any config settings specified in the aec dump");
|
||||
WEBRTC_DEFINE_bool(store_intermediate_output,
|
||||
false,
|
||||
"Creates new output files after each init");
|
||||
WEBRTC_DEFINE_string(custom_call_order_file,
|
||||
"",
|
||||
"Custom process API call order file");
|
||||
WEBRTC_DEFINE_string(
|
||||
output_custom_call_order_file,
|
||||
"",
|
||||
"Generate custom process API call order file from AEC dump");
|
||||
WEBRTC_DEFINE_bool(print_aec_parameter_values,
|
||||
false,
|
||||
"Print parameter values used in AEC in JSON-format");
|
||||
WEBRTC_DEFINE_string(aec_settings,
|
||||
"",
|
||||
"File in JSON-format with custom AEC settings");
|
||||
WEBRTC_DEFINE_bool(dump_data,
|
||||
false,
|
||||
"Dump internal data during the call (requires build flag)");
|
||||
WEBRTC_DEFINE_string(dump_data_output_dir,
|
||||
"",
|
||||
"Internal data dump output directory");
|
||||
WEBRTC_DEFINE_bool(help, false, "Print this message");
|
||||
|
||||
void SetSettingIfSpecified(const std::string& value,
|
||||
absl::optional<std::string>* parameter) {
|
||||
@ -283,7 +330,7 @@ MapAgc2AdaptiveLevelEstimator(absl::string_view name) {
|
||||
|
||||
SimulationSettings CreateSettings() {
|
||||
SimulationSettings settings;
|
||||
if (FLAG_all_default) {
|
||||
if (absl::GetFlag(FLAGS_all_default)) {
|
||||
settings.use_le = true;
|
||||
settings.use_vad = true;
|
||||
settings.use_ie = false;
|
||||
@ -297,87 +344,110 @@ SimulationSettings CreateSettings() {
|
||||
settings.use_aecm = false;
|
||||
settings.use_ed = false;
|
||||
}
|
||||
SetSettingIfSpecified(FLAG_dump_input, &settings.aec_dump_input_filename);
|
||||
SetSettingIfSpecified(FLAG_dump_output, &settings.aec_dump_output_filename);
|
||||
SetSettingIfSpecified(FLAG_i, &settings.input_filename);
|
||||
SetSettingIfSpecified(FLAG_o, &settings.output_filename);
|
||||
SetSettingIfSpecified(FLAG_ri, &settings.reverse_input_filename);
|
||||
SetSettingIfSpecified(FLAG_ro, &settings.reverse_output_filename);
|
||||
SetSettingIfSpecified(FLAG_artificial_nearend,
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_dump_input),
|
||||
&settings.aec_dump_input_filename);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_dump_output),
|
||||
&settings.aec_dump_output_filename);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_i), &settings.input_filename);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_o), &settings.output_filename);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_ri),
|
||||
&settings.reverse_input_filename);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_ro),
|
||||
&settings.reverse_output_filename);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_artificial_nearend),
|
||||
&settings.artificial_nearend_filename);
|
||||
SetSettingIfSpecified(FLAG_output_num_channels,
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_output_num_channels),
|
||||
&settings.output_num_channels);
|
||||
SetSettingIfSpecified(FLAG_reverse_output_num_channels,
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_reverse_output_num_channels),
|
||||
&settings.reverse_output_num_channels);
|
||||
SetSettingIfSpecified(FLAG_output_sample_rate_hz,
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_output_sample_rate_hz),
|
||||
&settings.output_sample_rate_hz);
|
||||
SetSettingIfSpecified(FLAG_reverse_output_sample_rate_hz,
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_reverse_output_sample_rate_hz),
|
||||
&settings.reverse_output_sample_rate_hz);
|
||||
SetSettingIfFlagSet(FLAG_aec, &settings.use_aec);
|
||||
SetSettingIfFlagSet(FLAG_aecm, &settings.use_aecm);
|
||||
SetSettingIfFlagSet(FLAG_ed, &settings.use_ed);
|
||||
SetSettingIfSpecified(FLAG_ed_graph, &settings.ed_graph_output_filename);
|
||||
SetSettingIfFlagSet(FLAG_agc, &settings.use_agc);
|
||||
SetSettingIfFlagSet(FLAG_agc2, &settings.use_agc2);
|
||||
SetSettingIfFlagSet(FLAG_pre_amplifier, &settings.use_pre_amplifier);
|
||||
SetSettingIfFlagSet(FLAG_hpf, &settings.use_hpf);
|
||||
SetSettingIfFlagSet(FLAG_ns, &settings.use_ns);
|
||||
SetSettingIfFlagSet(FLAG_ts, &settings.use_ts);
|
||||
SetSettingIfFlagSet(FLAG_vad, &settings.use_vad);
|
||||
SetSettingIfFlagSet(FLAG_le, &settings.use_le);
|
||||
SetSettingIfSpecified(FLAG_aec_suppression_level,
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_aec), &settings.use_aec);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_aecm), &settings.use_aecm);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_ed), &settings.use_ed);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_ed_graph),
|
||||
&settings.ed_graph_output_filename);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc), &settings.use_agc);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc2), &settings.use_agc2);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_pre_amplifier),
|
||||
&settings.use_pre_amplifier);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_hpf), &settings.use_hpf);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_ns), &settings.use_ns);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_ts), &settings.use_ts);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_vad), &settings.use_vad);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_le), &settings.use_le);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_aec_suppression_level),
|
||||
&settings.aec_suppression_level);
|
||||
SetSettingIfFlagSet(FLAG_delay_agnostic, &settings.use_delay_agnostic);
|
||||
SetSettingIfFlagSet(FLAG_extended_filter, &settings.use_extended_filter);
|
||||
SetSettingIfFlagSet(FLAG_refined_adaptive_filter,
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_delay_agnostic),
|
||||
&settings.use_delay_agnostic);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_extended_filter),
|
||||
&settings.use_extended_filter);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_refined_adaptive_filter),
|
||||
&settings.use_refined_adaptive_filter);
|
||||
|
||||
SetSettingIfFlagSet(FLAG_use_legacy_aec, &settings.use_legacy_aec);
|
||||
SetSettingIfFlagSet(FLAG_experimental_agc, &settings.use_experimental_agc);
|
||||
SetSettingIfFlagSet(FLAG_experimental_agc_disable_digital_adaptive,
|
||||
&settings.experimental_agc_disable_digital_adaptive);
|
||||
SetSettingIfFlagSet(FLAG_experimental_agc_analyze_before_aec,
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_use_legacy_aec),
|
||||
&settings.use_legacy_aec);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_experimental_agc),
|
||||
&settings.use_experimental_agc);
|
||||
SetSettingIfFlagSet(
|
||||
absl::GetFlag(FLAGS_experimental_agc_disable_digital_adaptive),
|
||||
&settings.experimental_agc_disable_digital_adaptive);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_experimental_agc_analyze_before_aec),
|
||||
&settings.experimental_agc_analyze_before_aec);
|
||||
SetSettingIfFlagSet(FLAG_experimental_agc_agc2_level_estimator,
|
||||
&settings.use_experimental_agc_agc2_level_estimator);
|
||||
SetSettingIfSpecified(FLAG_agc_mode, &settings.agc_mode);
|
||||
SetSettingIfSpecified(FLAG_agc_target_level, &settings.agc_target_level);
|
||||
SetSettingIfFlagSet(FLAG_agc_limiter, &settings.use_agc_limiter);
|
||||
SetSettingIfSpecified(FLAG_agc_compression_gain,
|
||||
SetSettingIfFlagSet(
|
||||
absl::GetFlag(FLAGS_experimental_agc_agc2_level_estimator),
|
||||
&settings.use_experimental_agc_agc2_level_estimator);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_agc_mode), &settings.agc_mode);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_agc_target_level),
|
||||
&settings.agc_target_level);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc_limiter),
|
||||
&settings.use_agc_limiter);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_agc_compression_gain),
|
||||
&settings.agc_compression_gain);
|
||||
SetSettingIfFlagSet(FLAG_agc2_enable_adaptive_gain,
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc2_enable_adaptive_gain),
|
||||
&settings.agc2_use_adaptive_gain);
|
||||
SetSettingIfSpecified(FLAG_agc2_fixed_gain_db, &settings.agc2_fixed_gain_db);
|
||||
settings.agc2_adaptive_level_estimator =
|
||||
MapAgc2AdaptiveLevelEstimator(FLAG_agc2_adaptive_level_estimator);
|
||||
SetSettingIfSpecified(FLAG_pre_amplifier_gain_factor,
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_agc2_fixed_gain_db),
|
||||
&settings.agc2_fixed_gain_db);
|
||||
settings.agc2_adaptive_level_estimator = MapAgc2AdaptiveLevelEstimator(
|
||||
absl::GetFlag(FLAGS_agc2_adaptive_level_estimator));
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_pre_amplifier_gain_factor),
|
||||
&settings.pre_amplifier_gain_factor);
|
||||
SetSettingIfSpecified(FLAG_vad_likelihood, &settings.vad_likelihood);
|
||||
SetSettingIfSpecified(FLAG_ns_level, &settings.ns_level);
|
||||
SetSettingIfSpecified(FLAG_stream_delay, &settings.stream_delay);
|
||||
SetSettingIfFlagSet(FLAG_use_stream_delay, &settings.use_stream_delay);
|
||||
SetSettingIfSpecified(FLAG_stream_drift_samples,
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_vad_likelihood),
|
||||
&settings.vad_likelihood);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_ns_level), &settings.ns_level);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_stream_delay),
|
||||
&settings.stream_delay);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_use_stream_delay),
|
||||
&settings.use_stream_delay);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_stream_drift_samples),
|
||||
&settings.stream_drift_samples);
|
||||
SetSettingIfSpecified(FLAG_custom_call_order_file,
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_custom_call_order_file),
|
||||
&settings.call_order_input_filename);
|
||||
SetSettingIfSpecified(FLAG_output_custom_call_order_file,
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_output_custom_call_order_file),
|
||||
&settings.call_order_output_filename);
|
||||
SetSettingIfSpecified(FLAG_aec_settings, &settings.aec_settings_filename);
|
||||
settings.initial_mic_level = FLAG_initial_mic_level;
|
||||
settings.simulate_mic_gain = FLAG_simulate_mic_gain;
|
||||
SetSettingIfSpecified(FLAG_simulated_mic_kind, &settings.simulated_mic_kind);
|
||||
settings.report_performance = FLAG_performance_report;
|
||||
SetSettingIfSpecified(FLAG_performance_report_output_file,
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_aec_settings),
|
||||
&settings.aec_settings_filename);
|
||||
settings.initial_mic_level = absl::GetFlag(FLAGS_initial_mic_level);
|
||||
settings.simulate_mic_gain = absl::GetFlag(FLAGS_simulate_mic_gain);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_simulated_mic_kind),
|
||||
&settings.simulated_mic_kind);
|
||||
settings.report_performance = absl::GetFlag(FLAGS_performance_report);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_performance_report_output_file),
|
||||
&settings.performance_report_output_filename);
|
||||
settings.use_verbose_logging = FLAG_verbose;
|
||||
settings.use_quiet_output = FLAG_quiet;
|
||||
settings.report_bitexactness = FLAG_bitexactness_report;
|
||||
settings.discard_all_settings_in_aecdump = FLAG_discard_settings_in_aecdump;
|
||||
settings.fixed_interface = FLAG_fixed_interface;
|
||||
settings.store_intermediate_output = FLAG_store_intermediate_output;
|
||||
settings.print_aec_parameter_values = FLAG_print_aec_parameter_values;
|
||||
settings.dump_internal_data = FLAG_dump_data;
|
||||
SetSettingIfSpecified(FLAG_dump_data_output_dir,
|
||||
settings.use_verbose_logging = absl::GetFlag(FLAGS_verbose);
|
||||
settings.use_quiet_output = absl::GetFlag(FLAGS_quiet);
|
||||
settings.report_bitexactness = absl::GetFlag(FLAGS_bitexactness_report);
|
||||
settings.discard_all_settings_in_aecdump =
|
||||
absl::GetFlag(FLAGS_discard_settings_in_aecdump);
|
||||
settings.fixed_interface = absl::GetFlag(FLAGS_fixed_interface);
|
||||
settings.store_intermediate_output =
|
||||
absl::GetFlag(FLAGS_store_intermediate_output);
|
||||
settings.print_aec_parameter_values =
|
||||
absl::GetFlag(FLAGS_print_aec_parameter_values);
|
||||
settings.dump_internal_data = absl::GetFlag(FLAGS_dump_data);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_dump_data_output_dir),
|
||||
&settings.dump_internal_data_output_dir);
|
||||
|
||||
return settings;
|
||||
@ -555,13 +625,9 @@ void PerformBasicParameterSanityChecks(const SimulationSettings& settings) {
|
||||
int AudioprocFloatImpl(std::unique_ptr<AudioProcessingBuilder> ap_builder,
|
||||
int argc,
|
||||
char* argv[]) {
|
||||
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
|
||||
argc != 1) {
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
if (args.size() != 1) {
|
||||
printf("%s", kUsageDescription);
|
||||
if (FLAG_help) {
|
||||
rtc::FlagList::Print(nullptr, false);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -22,9 +22,10 @@ rtc_executable("conversational_speech_generator") {
|
||||
]
|
||||
deps = [
|
||||
":lib",
|
||||
"../../../../rtc_base:rtc_base_approved",
|
||||
"../../../../test:fileutils",
|
||||
"../../../../test:test_support",
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/flags:parse",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
]
|
||||
}
|
||||
|
||||
@ -9,16 +9,22 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/parse.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "modules/audio_processing/test/conversational_speech/config.h"
|
||||
#include "modules/audio_processing/test/conversational_speech/multiend_call.h"
|
||||
#include "modules/audio_processing/test/conversational_speech/simulator.h"
|
||||
#include "modules/audio_processing/test/conversational_speech/timing.h"
|
||||
#include "modules/audio_processing/test/conversational_speech/wavreader_factory.h"
|
||||
#include "rtc_base/flags.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
|
||||
ABSL_FLAG(std::string, i, "", "Directory containing the speech turn wav files");
|
||||
ABSL_FLAG(std::string, t, "", "Path to the timing text file");
|
||||
ABSL_FLAG(std::string, o, "", "Output wav files destination path");
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
namespace {
|
||||
@ -32,28 +38,20 @@ const char kUsageDescription[] =
|
||||
"Command-line tool to generate multiple-end audio tracks to simulate "
|
||||
"conversational speech with two or more participants.\n";
|
||||
|
||||
WEBRTC_DEFINE_string(i, "", "Directory containing the speech turn wav files");
|
||||
WEBRTC_DEFINE_string(t, "", "Path to the timing text file");
|
||||
WEBRTC_DEFINE_string(o, "", "Output wav files destination path");
|
||||
WEBRTC_DEFINE_bool(help, false, "Prints this message");
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
|
||||
argc != 1) {
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
if (args.size() != 1) {
|
||||
printf("%s", kUsageDescription);
|
||||
if (FLAG_help) {
|
||||
rtc::FlagList::Print(nullptr, false);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
RTC_CHECK(DirExists(FLAG_i));
|
||||
RTC_CHECK(FileExists(FLAG_t));
|
||||
RTC_CHECK(DirExists(FLAG_o));
|
||||
RTC_CHECK(DirExists(absl::GetFlag(FLAGS_i)));
|
||||
RTC_CHECK(FileExists(absl::GetFlag(FLAGS_t)));
|
||||
RTC_CHECK(DirExists(absl::GetFlag(FLAGS_o)));
|
||||
|
||||
conversational_speech::Config config(FLAG_i, FLAG_t, FLAG_o);
|
||||
conversational_speech::Config config(
|
||||
absl::GetFlag(FLAGS_i), absl::GetFlag(FLAGS_t), absl::GetFlag(FLAGS_o));
|
||||
|
||||
// Load timing.
|
||||
std::vector<conversational_speech::Turn> timing =
|
||||
|
||||
@ -14,36 +14,41 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/parse.h"
|
||||
#include "common_audio/include/audio_util.h"
|
||||
#include "modules/audio_processing/agc/agc.h"
|
||||
#include "modules/audio_processing/transient/transient_suppressor.h"
|
||||
#include "rtc_base/flags.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
|
||||
WEBRTC_DEFINE_string(in_file_name, "", "PCM file that contains the signal.");
|
||||
WEBRTC_DEFINE_string(detection_file_name,
|
||||
"",
|
||||
"PCM file that contains the detection signal.");
|
||||
WEBRTC_DEFINE_string(reference_file_name,
|
||||
"",
|
||||
"PCM file that contains the reference signal.");
|
||||
ABSL_FLAG(std::string, in_file_name, "", "PCM file that contains the signal.");
|
||||
ABSL_FLAG(std::string,
|
||||
detection_file_name,
|
||||
"",
|
||||
"PCM file that contains the detection signal.");
|
||||
ABSL_FLAG(std::string,
|
||||
reference_file_name,
|
||||
"",
|
||||
"PCM file that contains the reference signal.");
|
||||
|
||||
WEBRTC_DEFINE_int(chunk_size_ms,
|
||||
10,
|
||||
"Time between each chunk of samples in milliseconds.");
|
||||
ABSL_FLAG(int,
|
||||
chunk_size_ms,
|
||||
10,
|
||||
"Time between each chunk of samples in milliseconds.");
|
||||
|
||||
WEBRTC_DEFINE_int(sample_rate_hz,
|
||||
16000,
|
||||
"Sampling frequency of the signal in Hertz.");
|
||||
WEBRTC_DEFINE_int(detection_rate_hz,
|
||||
0,
|
||||
"Sampling frequency of the detection signal in Hertz.");
|
||||
ABSL_FLAG(int,
|
||||
sample_rate_hz,
|
||||
16000,
|
||||
"Sampling frequency of the signal in Hertz.");
|
||||
ABSL_FLAG(int,
|
||||
detection_rate_hz,
|
||||
0,
|
||||
"Sampling frequency of the detection signal in Hertz.");
|
||||
|
||||
WEBRTC_DEFINE_int(num_channels, 1, "Number of channels.");
|
||||
|
||||
WEBRTC_DEFINE_bool(help, false, "Print this message.");
|
||||
ABSL_FLAG(int, num_channels, 1, "Number of channels.");
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -131,19 +136,21 @@ static void WritePCM(FILE* f,
|
||||
void void_main() {
|
||||
// TODO(aluebs): Remove all FileWrappers.
|
||||
// Prepare the input file.
|
||||
FILE* in_file = fopen(FLAG_in_file_name, "rb");
|
||||
FILE* in_file = fopen(absl::GetFlag(FLAGS_in_file_name).c_str(), "rb");
|
||||
ASSERT_TRUE(in_file != NULL);
|
||||
|
||||
// Prepare the detection file.
|
||||
FILE* detection_file = NULL;
|
||||
if (strlen(FLAG_detection_file_name) > 0) {
|
||||
detection_file = fopen(FLAG_detection_file_name, "rb");
|
||||
if (!absl::GetFlag(FLAGS_detection_file_name).empty()) {
|
||||
detection_file =
|
||||
fopen(absl::GetFlag(FLAGS_detection_file_name).c_str(), "rb");
|
||||
}
|
||||
|
||||
// Prepare the reference file.
|
||||
FILE* reference_file = NULL;
|
||||
if (strlen(FLAG_reference_file_name) > 0) {
|
||||
reference_file = fopen(FLAG_reference_file_name, "rb");
|
||||
if (!absl::GetFlag(FLAGS_reference_file_name).empty()) {
|
||||
reference_file =
|
||||
fopen(absl::GetFlag(FLAGS_reference_file_name).c_str(), "rb");
|
||||
}
|
||||
|
||||
// Prepare the output file.
|
||||
@ -151,27 +158,27 @@ void void_main() {
|
||||
FILE* out_file = fopen(out_file_name.c_str(), "wb");
|
||||
ASSERT_TRUE(out_file != NULL);
|
||||
|
||||
int detection_rate_hz = FLAG_detection_rate_hz;
|
||||
int detection_rate_hz = absl::GetFlag(FLAGS_detection_rate_hz);
|
||||
if (detection_rate_hz == 0) {
|
||||
detection_rate_hz = FLAG_sample_rate_hz;
|
||||
detection_rate_hz = absl::GetFlag(FLAGS_sample_rate_hz);
|
||||
}
|
||||
|
||||
Agc agc;
|
||||
|
||||
TransientSuppressor suppressor;
|
||||
suppressor.Initialize(FLAG_sample_rate_hz, detection_rate_hz,
|
||||
FLAG_num_channels);
|
||||
suppressor.Initialize(absl::GetFlag(FLAGS_sample_rate_hz), detection_rate_hz,
|
||||
absl::GetFlag(FLAGS_num_channels));
|
||||
|
||||
const size_t audio_buffer_size =
|
||||
FLAG_chunk_size_ms * FLAG_sample_rate_hz / 1000;
|
||||
const size_t audio_buffer_size = absl::GetFlag(FLAGS_chunk_size_ms) *
|
||||
absl::GetFlag(FLAGS_sample_rate_hz) / 1000;
|
||||
const size_t detection_buffer_size =
|
||||
FLAG_chunk_size_ms * detection_rate_hz / 1000;
|
||||
absl::GetFlag(FLAGS_chunk_size_ms) * detection_rate_hz / 1000;
|
||||
|
||||
// int16 and float variants of the same data.
|
||||
std::unique_ptr<int16_t[]> audio_buffer_i(
|
||||
new int16_t[FLAG_num_channels * audio_buffer_size]);
|
||||
new int16_t[absl::GetFlag(FLAGS_num_channels) * audio_buffer_size]);
|
||||
std::unique_ptr<float[]> audio_buffer_f(
|
||||
new float[FLAG_num_channels * audio_buffer_size]);
|
||||
new float[absl::GetFlag(FLAGS_num_channels) * audio_buffer_size]);
|
||||
|
||||
std::unique_ptr<float[]> detection_buffer, reference_buffer;
|
||||
|
||||
@ -180,26 +187,27 @@ void void_main() {
|
||||
if (reference_file)
|
||||
reference_buffer.reset(new float[audio_buffer_size]);
|
||||
|
||||
while (ReadBuffers(in_file, audio_buffer_size, FLAG_num_channels,
|
||||
audio_buffer_i.get(), detection_file,
|
||||
detection_buffer_size, detection_buffer.get(),
|
||||
reference_file, reference_buffer.get())) {
|
||||
while (ReadBuffers(
|
||||
in_file, audio_buffer_size, absl::GetFlag(FLAGS_num_channels),
|
||||
audio_buffer_i.get(), detection_file, detection_buffer_size,
|
||||
detection_buffer.get(), reference_file, reference_buffer.get())) {
|
||||
agc.Process(audio_buffer_i.get(), static_cast<int>(audio_buffer_size),
|
||||
FLAG_sample_rate_hz);
|
||||
absl::GetFlag(FLAGS_sample_rate_hz));
|
||||
|
||||
for (size_t i = 0; i < FLAG_num_channels * audio_buffer_size; ++i) {
|
||||
for (size_t i = 0;
|
||||
i < absl::GetFlag(FLAGS_num_channels) * audio_buffer_size; ++i) {
|
||||
audio_buffer_f[i] = audio_buffer_i[i];
|
||||
}
|
||||
|
||||
ASSERT_EQ(0, suppressor.Suppress(audio_buffer_f.get(), audio_buffer_size,
|
||||
FLAG_num_channels, detection_buffer.get(),
|
||||
detection_buffer_size,
|
||||
reference_buffer.get(), audio_buffer_size,
|
||||
agc.voice_probability(), true))
|
||||
ASSERT_EQ(0, suppressor.Suppress(
|
||||
audio_buffer_f.get(), audio_buffer_size,
|
||||
absl::GetFlag(FLAGS_num_channels), detection_buffer.get(),
|
||||
detection_buffer_size, reference_buffer.get(),
|
||||
audio_buffer_size, agc.voice_probability(), true))
|
||||
<< "The transient suppressor could not suppress the frame";
|
||||
|
||||
// Write result to out file.
|
||||
WritePCM(out_file, audio_buffer_size, FLAG_num_channels,
|
||||
WritePCM(out_file, audio_buffer_size, absl::GetFlag(FLAGS_num_channels),
|
||||
audio_buffer_f.get());
|
||||
}
|
||||
|
||||
@ -216,18 +224,14 @@ void void_main() {
|
||||
} // namespace webrtc
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
|
||||
argc != 1) {
|
||||
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
|
||||
if (args.size() != 1) {
|
||||
printf("%s", webrtc::kUsage);
|
||||
if (FLAG_help) {
|
||||
rtc::FlagList::Print(nullptr, false);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
RTC_CHECK_GT(FLAG_chunk_size_ms, 0);
|
||||
RTC_CHECK_GT(FLAG_sample_rate_hz, 0);
|
||||
RTC_CHECK_GT(FLAG_num_channels, 0);
|
||||
RTC_CHECK_GT(absl::GetFlag(FLAGS_chunk_size_ms), 0);
|
||||
RTC_CHECK_GT(absl::GetFlag(FLAGS_sample_rate_hz), 0);
|
||||
RTC_CHECK_GT(absl::GetFlag(FLAGS_num_channels), 0);
|
||||
|
||||
webrtc::void_main();
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user