Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: webrtc/modules/audio_processing/test/conversational_speech/generator.cc

Issue 3005483002: Replace remaining gflags usages with rtc_base/flags (Closed)
Patch Set: Rebase Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <iostream> 11 #include <iostream>
12 12
13 #include "gflags/gflags.h"
14 #include "webrtc/modules/audio_processing/test/conversational_speech/config.h" 13 #include "webrtc/modules/audio_processing/test/conversational_speech/config.h"
15 #include "webrtc/modules/audio_processing/test/conversational_speech/multiend_ca ll.h" 14 #include "webrtc/modules/audio_processing/test/conversational_speech/multiend_ca ll.h"
16 #include "webrtc/modules/audio_processing/test/conversational_speech/simulator.h " 15 #include "webrtc/modules/audio_processing/test/conversational_speech/simulator.h "
17 #include "webrtc/modules/audio_processing/test/conversational_speech/timing.h" 16 #include "webrtc/modules/audio_processing/test/conversational_speech/timing.h"
18 #include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_f actory.h" 17 #include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_f actory.h"
18 #include "webrtc/rtc_base/flags.h"
19 #include "webrtc/rtc_base/ptr_util.h" 19 #include "webrtc/rtc_base/ptr_util.h"
20 #include "webrtc/test/testsupport/fileutils.h" 20 #include "webrtc/test/testsupport/fileutils.h"
21 21
22 namespace webrtc { 22 namespace webrtc {
23 namespace test { 23 namespace test {
24 namespace { 24 namespace {
25 25
26 // Adapting DirExists/FileExists interfaces to DEFINE_validator.
27 auto dir_exists = [](const char* c, const std::string& dirpath) {
28 return DirExists(dirpath);
29 };
30 auto file_exists = [](const char* c, const std::string& filepath) {
31 return FileExists(filepath);
32 };
33
34 const char kUsageDescription[] = 26 const char kUsageDescription[] =
35 "Usage: conversational_speech_generator\n" 27 "Usage: conversational_speech_generator\n"
36 " -i <path/to/source/audiotracks>\n" 28 " -i <path/to/source/audiotracks>\n"
37 " -t <path/to/timing_file.txt>\n" 29 " -t <path/to/timing_file.txt>\n"
38 " -o <output/path>\n" 30 " -o <output/path>\n"
39 "\n\n" 31 "\n\n"
40 "Command-line tool to generate multiple-end audio tracks to simulate " 32 "Command-line tool to generate multiple-end audio tracks to simulate "
41 "conversational speech with two or more participants."; 33 "conversational speech with two or more participants.\n";
42 34
43 DEFINE_string(i, "", "Directory containing the speech turn wav files"); 35 DEFINE_string(i, "", "Directory containing the speech turn wav files");
44 DEFINE_validator(i, dir_exists);
45 DEFINE_string(t, "", "Path to the timing text file"); 36 DEFINE_string(t, "", "Path to the timing text file");
46 DEFINE_validator(t, file_exists);
47 DEFINE_string(o, "", "Output wav files destination path"); 37 DEFINE_string(o, "", "Output wav files destination path");
48 DEFINE_validator(o, dir_exists); 38 DEFINE_bool(help, false, "Prints this message");
49 39
50 } // namespace 40 } // namespace
51 41
52 int main(int argc, char* argv[]) { 42 int main(int argc, char* argv[]) {
53 google::SetUsageMessage(kUsageDescription); 43 if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) ||
54 google::ParseCommandLineFlags(&argc, &argv, true); 44 FLAG_help || argc != 1) {
55 conversational_speech::Config config(FLAGS_i, FLAGS_t, FLAGS_o); 45 printf("%s", kUsageDescription);
46 if (FLAG_help) {
47 rtc::FlagList::Print(nullptr, false);
48 return 0;
49 }
50 return 1;
51 }
52 RTC_CHECK(DirExists(FLAG_i));
53 RTC_CHECK(FileExists(FLAG_t));
54 RTC_CHECK(DirExists(FLAG_o));
55
56 conversational_speech::Config config(FLAG_i, FLAG_t, FLAG_o);
56 57
57 // Load timing. 58 // Load timing.
58 std::vector<conversational_speech::Turn> timing = 59 std::vector<conversational_speech::Turn> timing =
59 conversational_speech::LoadTiming(config.timing_filepath()); 60 conversational_speech::LoadTiming(config.timing_filepath());
60 61
61 // Parse timing and audio tracks. 62 // Parse timing and audio tracks.
62 auto wavreader_factory = rtc::MakeUnique< 63 auto wavreader_factory = rtc::MakeUnique<
63 conversational_speech::WavReaderFactory>(); 64 conversational_speech::WavReaderFactory>();
64 conversational_speech::MultiEndCall multiend_call( 65 conversational_speech::MultiEndCall multiend_call(
65 timing, config.audiotracks_path(), std::move(wavreader_factory)); 66 timing, config.audiotracks_path(), std::move(wavreader_factory));
(...skipping 14 matching lines...) Expand all
80 81
81 return 0; 82 return 0;
82 } 83 }
83 84
84 } // namespace test 85 } // namespace test
85 } // namespace webrtc 86 } // namespace webrtc
86 87
87 int main(int argc, char* argv[]) { 88 int main(int argc, char* argv[]) {
88 return webrtc::test::main(argc, argv); 89 return webrtc::test::main(argc, argv);
89 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698