OLD | NEW |
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" | 13 #include "gflags/gflags.h" |
14 #include "webrtc/base/logging.h" | 14 #include "webrtc/base/ptr_util.h" |
15 #include "webrtc/modules/audio_processing/test/conversational_speech/config.h" | 15 #include "webrtc/modules/audio_processing/test/conversational_speech/config.h" |
| 16 #include "webrtc/modules/audio_processing/test/conversational_speech/timing.h" |
| 17 #include "webrtc/modules/audio_processing/test/conversational_speech/wavreader_f
actory.h" |
| 18 #include "webrtc/modules/audio_processing/test/conversational_speech/multiend_ca
ll.h" |
| 19 #include "webrtc/modules/audio_processing/test/conversational_speech/simulator.h
" |
16 #include "webrtc/test/testsupport/fileutils.h" | 20 #include "webrtc/test/testsupport/fileutils.h" |
17 | 21 |
18 namespace webrtc { | 22 namespace webrtc { |
19 namespace test { | 23 namespace test { |
20 namespace { | 24 namespace { |
21 | 25 |
22 // Adapting DirExists/FileExists interfaces to DEFINE_validator. | 26 // Adapting DirExists/FileExists interfaces to DEFINE_validator. |
23 auto dir_exists = [](const char* c, const std::string& dirpath) { | 27 auto dir_exists = [](const char* c, const std::string& dirpath) { |
24 return DirExists(dirpath); | 28 return DirExists(dirpath); |
25 }; | 29 }; |
(...skipping 15 matching lines...) Expand all Loading... |
41 DEFINE_string(t, "", "Path to the timing text file"); | 45 DEFINE_string(t, "", "Path to the timing text file"); |
42 DEFINE_validator(t, file_exists); | 46 DEFINE_validator(t, file_exists); |
43 DEFINE_string(o, "", "Output wav files destination path"); | 47 DEFINE_string(o, "", "Output wav files destination path"); |
44 DEFINE_validator(o, dir_exists); | 48 DEFINE_validator(o, dir_exists); |
45 | 49 |
46 } // namespace | 50 } // namespace |
47 | 51 |
48 int main(int argc, char* argv[]) { | 52 int main(int argc, char* argv[]) { |
49 google::SetUsageMessage(kUsageDescription); | 53 google::SetUsageMessage(kUsageDescription); |
50 google::ParseCommandLineFlags(&argc, &argv, true); | 54 google::ParseCommandLineFlags(&argc, &argv, true); |
51 | |
52 conversational_speech::Config config(FLAGS_i, FLAGS_t, FLAGS_o); | 55 conversational_speech::Config config(FLAGS_i, FLAGS_t, FLAGS_o); |
53 | 56 |
54 // TODO(alessiob): remove line below once debugged. | 57 // Load timing. |
55 rtc::LogMessage::LogToDebug(rtc::LS_VERBOSE); | 58 std::vector<conversational_speech::Turn> timing = |
56 LOG(LS_VERBOSE) << "i = " << config.audiotracks_path(); | 59 conversational_speech::LoadTiming(config.timing_filepath()); |
57 LOG(LS_VERBOSE) << "t = " << config.timing_filepath(); | 60 |
58 LOG(LS_VERBOSE) << "o = " << config.output_path(); | 61 // Parse timing and audio tracks. |
| 62 auto wavreader_factory = rtc::MakeUnique< |
| 63 conversational_speech::WavReaderFactory>(); |
| 64 conversational_speech::MultiEndCall multiend_call( |
| 65 timing, config.audiotracks_path(), std::move(wavreader_factory)); |
| 66 |
| 67 // Generate output audio tracks. |
| 68 auto generated_audiotrack_pairs = conversational_speech::Simulate( |
| 69 multiend_call, config.output_path()); |
| 70 |
| 71 // Show paths to created audio tracks. |
| 72 std::cout << "Output files:" << std::endl; |
| 73 for (const auto& output_paths_entry : *generated_audiotrack_pairs) { |
| 74 std::cout << " speaker: " << output_paths_entry.first << std::endl; |
| 75 std::cout << " near end: " << output_paths_entry.second.near_end |
| 76 << std::endl; |
| 77 std::cout << " far end: " << output_paths_entry.second.far_end |
| 78 << std::endl; |
| 79 } |
59 | 80 |
60 return 0; | 81 return 0; |
61 } | 82 } |
62 | 83 |
63 } // namespace test | 84 } // namespace test |
64 } // namespace webrtc | 85 } // namespace webrtc |
65 | 86 |
66 int main(int argc, char* argv[]) { | 87 int main(int argc, char* argv[]) { |
67 return webrtc::test::main(argc, argv); | 88 return webrtc::test::main(argc, argv); |
68 } | 89 } |
OLD | NEW |