C++ porting of the initial python script for conversational speech generation.

This CL removes the Python script and adds its C++ porting.
The former was in its early stage and it has permanently been removed.

BUG=webrtc:7218
NOTRY=True

Review-Url: https://codereview.webrtc.org/2740063004
Cr-Original-Commit-Position: refs/heads/master@{#17254}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 0cf3aa6d0d170365a2dedb57960fbface736f851
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index 84f25b5..b20e3b5 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -475,6 +475,7 @@
         ":audioproc_f",
         ":audioproc_unittest_proto",
         ":unpack_aecdump",
+        "test/conversational_speech",
         "test/py_quality_assessment",
       ]
     }
diff --git a/modules/audio_processing/test/conversational_speech/BUILD.gn b/modules/audio_processing/test/conversational_speech/BUILD.gn
new file mode 100644
index 0000000..09f8a26
--- /dev/null
+++ b/modules/audio_processing/test/conversational_speech/BUILD.gn
@@ -0,0 +1,31 @@
+# Copyright (c) 2017 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.
+
+import("../../../../webrtc.gni")
+
+group("conversational_speech") {
+  testonly = true
+  deps = [
+    ":convspeech_gen",
+  ]
+}
+
+rtc_executable("convspeech_gen") {
+  testonly = true
+  sources = [
+    "convspeech_gen.cc",
+    "settings.cc",
+    "settings.h",
+  ]
+  deps = [
+    "//third_party/gflags",
+    "//webrtc/base:rtc_base_approved",
+    "//webrtc/test:fileutils",
+  ]
+  visibility = [ ":*" ]  # Only targets in this file can depend on this.
+}
diff --git a/modules/audio_processing/test/py_conversational_speech/OWNERS b/modules/audio_processing/test/conversational_speech/OWNERS
similarity index 100%
rename from modules/audio_processing/test/py_conversational_speech/OWNERS
rename to modules/audio_processing/test/conversational_speech/OWNERS
diff --git a/modules/audio_processing/test/py_conversational_speech/README.md b/modules/audio_processing/test/conversational_speech/README.md
similarity index 92%
rename from modules/audio_processing/test/py_conversational_speech/README.md
rename to modules/audio_processing/test/conversational_speech/README.md
index 79d07fd..415c65b 100644
--- a/modules/audio_processing/test/py_conversational_speech/README.md
+++ b/modules/audio_processing/test/conversational_speech/README.md
@@ -1,7 +1,7 @@
-#Conversational Speech generator tool
+# Conversational Speech generator tool
 
-Python tool to generate multiple-end audio tracks to simulate conversational
-speech with two or more participants.
+Tool to generate multiple-end audio tracks to simulate conversational speech
+with two or more participants.
 
 The input to the tool is a directory containing a number of audio tracks and
 a text file indicating how to time the sequence of speech turns (see the Example
@@ -21,7 +21,7 @@
 
 IMPORTANT: **the whole code has not been landed yet.**
 
-###Example
+### Example
 
 For each end, there is a set of audio tracks, e.g., a1, a2 and a3 (speaker A)
 and b1, b2 (speaker B).
diff --git a/modules/audio_processing/test/conversational_speech/convspeech_gen.cc b/modules/audio_processing/test/conversational_speech/convspeech_gen.cc
new file mode 100644
index 0000000..2b88597
--- /dev/null
+++ b/modules/audio_processing/test/conversational_speech/convspeech_gen.cc
@@ -0,0 +1,68 @@
+/*
+ *  Copyright (c) 2017 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 <iostream>
+
+#include "gflags/gflags.h"
+#include "webrtc/base/logging.h"
+#include "webrtc/modules/audio_processing/test/conversational_speech/settings.h"
+#include "webrtc/test/testsupport/fileutils.h"
+
+namespace webrtc {
+namespace test {
+namespace {
+
+// Adapting DirExists/FileExists interfaces to DEFINE_validator.
+auto dir_exists = [](const char* c, const std::string& dirpath) {
+  return DirExists(dirpath);
+};
+auto file_exists = [](const char* c, const std::string& filepath) {
+  return FileExists(filepath);
+};
+
+const char kUsageDescription[] =
+    "Usage: convspeech_gen\n"
+    "          -i <path/to/source/audiotracks>\n"
+    "          -t <path/to/timing_file.txt>\n"
+    "          -o <output/path>\n"
+    "\n\n"
+    "Command-line tool to generate multiple-end audio tracks to simulate "
+    "conversational speech with two or more participants.";
+
+DEFINE_string(i, "", "Directory containing the speech turn wav files");
+DEFINE_validator(i, dir_exists);
+DEFINE_string(t, "", "Path to the timing text file");
+DEFINE_validator(t, file_exists);
+DEFINE_string(o, "", "Output wav files destination path");
+DEFINE_validator(o, dir_exists);
+
+}  // namespace
+
+int main(int argc, char* argv[]) {
+  google::SetUsageMessage(kUsageDescription);
+  google::ParseCommandLineFlags(&argc, &argv, true);
+
+  ConvSpeechGeneratorSettings settings(FLAGS_i, FLAGS_t, FLAGS_o);
+
+  // TODO(alessiob): remove line below once debugged.
+  rtc::LogMessage::LogToDebug(rtc::LS_VERBOSE);
+  LOG(LS_VERBOSE) << "i = " << settings.audiotracks_path();
+  LOG(LS_VERBOSE) << "t = " << settings.timing_filepath();
+  LOG(LS_VERBOSE) << "o = " << settings.output_path();
+
+  return 0;
+}
+
+}  // namespace test
+}  // namespace webrtc
+
+int main(int argc, char* argv[]) {
+  return webrtc::test::main(argc, argv);
+}
diff --git a/modules/audio_processing/test/conversational_speech/settings.cc b/modules/audio_processing/test/conversational_speech/settings.cc
new file mode 100644
index 0000000..8b2e88b
--- /dev/null
+++ b/modules/audio_processing/test/conversational_speech/settings.cc
@@ -0,0 +1,29 @@
+/*
+ *  Copyright (c) 2017 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 "webrtc/modules/audio_processing/test/conversational_speech/settings.h"
+
+namespace webrtc {
+namespace test {
+
+const std::string& ConvSpeechGeneratorSettings::audiotracks_path() const {
+  return audiotracks_path_;
+}
+
+const std::string& ConvSpeechGeneratorSettings::timing_filepath() const {
+  return timing_filepath_;
+}
+
+const std::string& ConvSpeechGeneratorSettings::output_path() const {
+  return output_path_;
+}
+
+}  // namespace test
+}  // namespace webrtc
diff --git a/modules/audio_processing/test/conversational_speech/settings.h b/modules/audio_processing/test/conversational_speech/settings.h
new file mode 100644
index 0000000..ea360b7
--- /dev/null
+++ b/modules/audio_processing/test/conversational_speech/settings.h
@@ -0,0 +1,39 @@
+/*
+ *  Copyright (c) 2017 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.
+ */
+
+#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_SETTINGS_H_
+#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_SETTINGS_H_
+
+#include <string>
+
+namespace webrtc {
+namespace test {
+
+struct ConvSpeechGeneratorSettings {
+  ConvSpeechGeneratorSettings(const std::string& audiotracks_path,
+                              const std::string& timing_filepath,
+                              const std::string& output_path)
+      : audiotracks_path_(audiotracks_path),
+        timing_filepath_(timing_filepath),
+        output_path_(output_path) {}
+
+  const std::string& audiotracks_path() const;
+  const std::string& timing_filepath() const;
+  const std::string& output_path() const;
+
+  const std::string audiotracks_path_;
+  const std::string timing_filepath_;
+  const std::string output_path_;
+};
+
+}  // namespace test
+}  // namespace webrtc
+
+#endif  // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_SETTINGS_H_
diff --git a/modules/audio_processing/test/py_conversational_speech/generate_conversational_tracks.py b/modules/audio_processing/test/py_conversational_speech/generate_conversational_tracks.py
deleted file mode 100644
index 41e3bbd..0000000
--- a/modules/audio_processing/test/py_conversational_speech/generate_conversational_tracks.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2017 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.
-
-"""Generate multiple-end audio tracks to simulate conversational
-   speech with two or more participants.
-
-Usage: generate_conversational_tracks.py
-          -i path/to/source/audiotracks
-          -t path/to/timing_file.txt
-          -o output/path
-"""
-
-import argparse
-import logging
-import sys
-
-def _InstanceArgumentsParser():
-  parser = argparse.ArgumentParser(description=(
-      'Generate multiple-end audio tracks to simulate conversational speech '
-      'with two or more participants.'))
-
-  parser.add_argument('-i', '--input_tracks_path', required=True,
-                      help='directory containing the speech turn wav files')
-
-  parser.add_argument('-t', '--timing_file', required=True,
-                      help='path to the timing text file')
-
-  parser.add_argument('-o', '--output_dir', required=False,
-                      help=('base path to the output directory in which the '
-                            'output wav files are saved'),
-                      default='output')
-
-  return parser
-
-
-def main():
-  # TODO(alessiob): level = logging.INFO once debugged.
-  logging.basicConfig(level=logging.DEBUG)
-
-  parser = _InstanceArgumentsParser()
-  args = parser.parse_args()
-
-  # TODO(alessiob): pass the arguments to the app controller.
-
-  # TODO(alessiob): remove when comment above addressed.
-  logging.debug(args)
-
-  sys.exit(0)
-
-
-if __name__ == '__main__':
-  main()
diff --git a/modules/audio_processing/test/py_conversational_speech/test_generation.py b/modules/audio_processing/test/py_conversational_speech/test_generation.py
deleted file mode 100644
index 3fc34e3..0000000
--- a/modules/audio_processing/test/py_conversational_speech/test_generation.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2017 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.
-
-import unittest
-
-import generate_conversational_tracks
-
-class TestGenerationScript(unittest.TestCase):
-
-  def TestMain(self):
-    # Exit with error code if no arguments are passed.
-    with self.assertRaises(SystemExit) as cm:
-      generate_conversational_tracks.main()
-    self.assertGreater(cm.exception.code, 0)