[pulseaudio-commits] [Git][pulseaudio/webrtc-audio-processing][master] Remove rnn_vad_tool.cc that contains main().
Tanu Kaskinen (@tanuk)
gitlab at gitlab.freedesktop.org
Wed Sep 8 12:21:52 UTC 2021
Tanu Kaskinen pushed to branch master at PulseAudio / webrtc-audio-processing
Commits:
57ec282d by Ryo Kawaguchi at 2021-09-08T12:21:50+00:00
Remove rnn_vad_tool.cc that contains main().
- - - - -
3 changed files:
- webrtc/modules/audio_processing/agc2/rnn_vad/BUILD.gn
- − webrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_tool.cc
- webrtc/modules/audio_processing/meson.build
Changes:
=====================================
webrtc/modules/audio_processing/agc2/rnn_vad/BUILD.gn
=====================================
@@ -215,19 +215,4 @@ if (rtc_include_tests) {
deps += [ ":unittests_bundle_data" ]
}
}
-
- rtc_executable("rnn_vad_tool") {
- testonly = true
- sources = [ "rnn_vad_tool.cc" ]
- deps = [
- ":rnn_vad",
- ":rnn_vad_common",
- "../../../../api:array_view",
- "../../../../common_audio",
- "../../../../rtc_base:rtc_base_approved",
- "../../../../test:test_support",
- "//third_party/abseil-cpp/absl/flags:flag",
- "//third_party/abseil-cpp/absl/flags:parse",
- ]
- }
}
=====================================
webrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_tool.cc deleted
=====================================
@@ -1,120 +0,0 @@
-/*
- * 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.
- */
-
-#include <array>
-#include <string>
-#include <vector>
-
-#include "absl/flags/flag.h"
-#include "absl/flags/parse.h"
-#include "common_audio/resampler/push_sinc_resampler.h"
-#include "common_audio/wav_file.h"
-#include "modules/audio_processing/agc2/rnn_vad/common.h"
-#include "modules/audio_processing/agc2/rnn_vad/features_extraction.h"
-#include "modules/audio_processing/agc2/rnn_vad/rnn.h"
-#include "rtc_base/logging.h"
-
-ABSL_FLAG(std::string, i, "", "Path to the input wav file");
-ABSL_FLAG(std::string, f, "", "Path to the output features file");
-ABSL_FLAG(std::string, o, "", "Path to the output VAD probabilities file");
-
-namespace webrtc {
-namespace rnn_vad {
-namespace test {
-
-int main(int argc, char* argv[]) {
- absl::ParseCommandLine(argc, argv);
- rtc::LogMessage::LogToDebug(rtc::LS_INFO);
-
- // Open wav input file and check properties.
- const std::string input_wav_file = absl::GetFlag(FLAGS_i);
- WavReader wav_reader(input_wav_file);
- if (wav_reader.num_channels() != 1) {
- RTC_LOG(LS_ERROR) << "Only mono wav files are supported";
- return 1;
- }
- if (wav_reader.sample_rate() % 100 != 0) {
- RTC_LOG(LS_ERROR) << "The sample rate rate must allow 10 ms frames.";
- return 1;
- }
- RTC_LOG(LS_INFO) << "Input sample rate: " << wav_reader.sample_rate();
-
- // Init output files.
- const std::string output_vad_probs_file = absl::GetFlag(FLAGS_o);
- FILE* vad_probs_file = fopen(output_vad_probs_file.c_str(), "wb");
- FILE* features_file = nullptr;
- const std::string output_feature_file = absl::GetFlag(FLAGS_f);
- if (!output_feature_file.empty()) {
- features_file = fopen(output_feature_file.c_str(), "wb");
- }
-
- // Initialize.
- const size_t frame_size_10ms =
- rtc::CheckedDivExact(wav_reader.sample_rate(), 100);
- std::vector<float> samples_10ms;
- samples_10ms.resize(frame_size_10ms);
- std::array<float, kFrameSize10ms24kHz> samples_10ms_24kHz;
- PushSincResampler resampler(frame_size_10ms, kFrameSize10ms24kHz);
- FeaturesExtractor features_extractor;
- std::array<float, kFeatureVectorSize> feature_vector;
- RnnBasedVad rnn_vad;
-
- // Compute VAD probabilities.
- while (true) {
- // Read frame at the input sample rate.
- const auto read_samples =
- wav_reader.ReadSamples(frame_size_10ms, samples_10ms.data());
- if (read_samples < frame_size_10ms) {
- break; // EOF.
- }
- // Resample input.
- resampler.Resample(samples_10ms.data(), samples_10ms.size(),
- samples_10ms_24kHz.data(), samples_10ms_24kHz.size());
-
- // Extract features and feed the RNN.
- bool is_silence = features_extractor.CheckSilenceComputeFeatures(
- samples_10ms_24kHz, feature_vector);
- float vad_probability =
- rnn_vad.ComputeVadProbability(feature_vector, is_silence);
- // Write voice probability.
- RTC_DCHECK_GE(vad_probability, 0.f);
- RTC_DCHECK_GE(1.f, vad_probability);
- fwrite(&vad_probability, sizeof(float), 1, vad_probs_file);
- // Write features.
- if (features_file) {
- const float float_is_silence = is_silence ? 1.f : 0.f;
- fwrite(&float_is_silence, sizeof(float), 1, features_file);
- if (is_silence) {
- // Do not write uninitialized values.
- feature_vector.fill(0.f);
- }
- fwrite(feature_vector.data(), sizeof(float), kFeatureVectorSize,
- features_file);
- }
- }
-
- // Close output file(s).
- fclose(vad_probs_file);
- RTC_LOG(LS_INFO) << "VAD probabilities written to " << output_vad_probs_file;
- if (features_file) {
- fclose(features_file);
- RTC_LOG(LS_INFO) << "features written to " << output_feature_file;
- }
-
- return 0;
-}
-
-} // namespace test
-} // namespace rnn_vad
-} // namespace webrtc
-
-int main(int argc, char* argv[]) {
- return webrtc::rnn_vad::test::main(argc, argv);
-}
=====================================
webrtc/modules/audio_processing/meson.build
=====================================
@@ -88,7 +88,6 @@ webrtc_audio_processing_sources = [
'agc2/rnn_vad/pitch_search.cc',
'agc2/rnn_vad/pitch_search_internal.cc',
'agc2/rnn_vad/rnn.cc',
- 'agc2/rnn_vad/rnn_vad_tool.cc',
'agc2/rnn_vad/spectral_features.cc',
'agc2/rnn_vad/spectral_features_internal.cc',
'agc2/saturation_protector.cc',
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/commit/57ec282d4ff225baef20562e4212392925295ed0
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/commit/57ec282d4ff225baef20562e4212392925295ed0
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20210908/1f627bf0/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list