Add default conversational speech file to the .rodata section.
This allow to remove the testonly from the rtc_event_log_visualizer binary and the implicit dependency on the path of the default conversational speech file. The binary size of event_log_visualizer passes from 2.1 MB to 4.0 MB. Bug: b/237526033 Change-Id: I71cf647f039f26f30c792c49c752cff5c5b329a2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267663 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37453}
This commit is contained in:
parent
ea8eff3737
commit
6183a0fe9a
@ -464,14 +464,12 @@ if (rtc_include_tests) {
|
||||
|
||||
if (rtc_enable_protobuf) {
|
||||
rtc_executable("event_log_visualizer") {
|
||||
testonly = true
|
||||
sources = [ "rtc_event_log_visualizer/main.cc" ]
|
||||
data = [
|
||||
# If --wav_filename is not provided, event_log_visualizer uses
|
||||
# EN_script2_F_sp2_B1.wav by default. This is a good default to use
|
||||
# for example with flags --plot=all when there is no need to use a
|
||||
# specific .wav file.
|
||||
"../resources/audio_processing/conversational_speech/EN_script2_F_sp2_B1.wav",
|
||||
# TODO(bugs.webrtc.org/14248): Remove once usage of std::tmpnam
|
||||
# is removed (in favor of in memory InputAudioFile.
|
||||
cflags_cc = [ "-Wno-deprecated-declarations" ]
|
||||
sources = [
|
||||
"rtc_event_log_visualizer/conversational_speech_en.h",
|
||||
"rtc_event_log_visualizer/main.cc",
|
||||
]
|
||||
deps = [
|
||||
":event_log_visualizer_utils",
|
||||
@ -484,7 +482,6 @@ if (rtc_include_tests) {
|
||||
"../rtc_base:logging",
|
||||
"../rtc_base:protobuf_utils",
|
||||
"../system_wrappers:field_trial",
|
||||
"../test:fileutils",
|
||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
"//third_party/abseil-cpp/absl/flags:config",
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
|
||||
169459
rtc_tools/rtc_event_log_visualizer/conversational_speech_en.h
Normal file
169459
rtc_tools/rtc_event_log_visualizer/conversational_speech_en.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -33,9 +35,9 @@
|
||||
#include "rtc_tools/rtc_event_log_visualizer/alerts.h"
|
||||
#include "rtc_tools/rtc_event_log_visualizer/analyze_audio.h"
|
||||
#include "rtc_tools/rtc_event_log_visualizer/analyzer.h"
|
||||
#include "rtc_tools/rtc_event_log_visualizer/conversational_speech_en.h"
|
||||
#include "rtc_tools/rtc_event_log_visualizer/plot_base.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
|
||||
ABSL_FLAG(std::string,
|
||||
plot,
|
||||
@ -464,11 +466,18 @@ int main(int argc, char* argv[]) {
|
||||
});
|
||||
|
||||
std::string wav_path;
|
||||
bool has_generated_wav_file = false;
|
||||
if (!absl::GetFlag(FLAGS_wav_filename).empty()) {
|
||||
wav_path = absl::GetFlag(FLAGS_wav_filename);
|
||||
} else {
|
||||
wav_path = webrtc::test::ResourcePath(
|
||||
"audio_processing/conversational_speech/EN_script2_F_sp2_B1", "wav");
|
||||
// TODO(bugs.webrtc.org/14248): Remove the need to generate a file
|
||||
// and read the file directly from memory.
|
||||
wav_path = std::tmpnam(nullptr);
|
||||
std::ofstream out_wav_file(wav_path);
|
||||
out_wav_file.write(
|
||||
reinterpret_cast<char*>(&webrtc::conversational_speech_en_wav[0]),
|
||||
webrtc::conversational_speech_en_wav_len);
|
||||
has_generated_wav_file = true;
|
||||
}
|
||||
absl::optional<webrtc::NetEqStatsGetterMap> neteq_stats;
|
||||
|
||||
@ -622,5 +631,11 @@ int main(int argc, char* argv[]) {
|
||||
triage_alerts.Print(stderr);
|
||||
}
|
||||
|
||||
// TODO(bugs.webrtc.org/14248): Remove the need to generate a file
|
||||
// and read the file directly from memory.
|
||||
if (has_generated_wav_file) {
|
||||
RTC_CHECK_EQ(std::remove(wav_path.c_str()), 0)
|
||||
<< "Failed to remove " << wav_path;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user