From dbbaa2ad66bd18429c5b4caf2436a61e276971f9 Mon Sep 17 00:00:00 2001 From: alessiob Date: Wed, 15 Mar 2017 08:19:25 -0700 Subject: [PATCH] Revert of C++ porting of the initial python script for conversational speech generation. (patchset #2 id:100001 of https://codereview.webrtc.org/2740063004/ ) Reason for revert: Even if the conversational speech tool is external and not a core part of webrtc, there are too many trybots failing. Original issue's description: > 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-Commit-Position: refs/heads/master@{#17254} > Committed: https://chromium.googlesource.com/external/webrtc/+/0cf3aa6d0d170365a2dedb57960fbface736f851 TBR=henrik.lundin@webrtc.org,kjellander@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:7218 Review-Url: https://codereview.webrtc.org/2753843002 Cr-Commit-Position: refs/heads/master@{#17257} --- webrtc/modules/audio_processing/BUILD.gn | 1 - .../test/conversational_speech/BUILD.gn | 31 --------- .../conversational_speech/convspeech_gen.cc | 68 ------------------- .../test/conversational_speech/settings.cc | 29 -------- .../test/conversational_speech/settings.h | 39 ----------- .../OWNERS | 0 .../README.md | 8 +-- .../generate_conversational_tracks.py | 58 ++++++++++++++++ .../test_generation.py | 20 ++++++ 9 files changed, 82 insertions(+), 172 deletions(-) delete mode 100644 webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn delete mode 100644 webrtc/modules/audio_processing/test/conversational_speech/convspeech_gen.cc delete mode 100644 webrtc/modules/audio_processing/test/conversational_speech/settings.cc delete mode 100644 webrtc/modules/audio_processing/test/conversational_speech/settings.h rename webrtc/modules/audio_processing/test/{conversational_speech => py_conversational_speech}/OWNERS (100%) rename webrtc/modules/audio_processing/test/{conversational_speech => py_conversational_speech}/README.md (92%) create mode 100644 webrtc/modules/audio_processing/test/py_conversational_speech/generate_conversational_tracks.py create mode 100644 webrtc/modules/audio_processing/test/py_conversational_speech/test_generation.py diff --git a/webrtc/modules/audio_processing/BUILD.gn b/webrtc/modules/audio_processing/BUILD.gn index b20e3b5ad1..84f25b5e8e 100644 --- a/webrtc/modules/audio_processing/BUILD.gn +++ b/webrtc/modules/audio_processing/BUILD.gn @@ -475,7 +475,6 @@ if (rtc_include_tests) { ":audioproc_f", ":audioproc_unittest_proto", ":unpack_aecdump", - "test/conversational_speech", "test/py_quality_assessment", ] } diff --git a/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn b/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn deleted file mode 100644 index 09f8a2625e..0000000000 --- a/webrtc/modules/audio_processing/test/conversational_speech/BUILD.gn +++ /dev/null @@ -1,31 +0,0 @@ -# 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/webrtc/modules/audio_processing/test/conversational_speech/convspeech_gen.cc b/webrtc/modules/audio_processing/test/conversational_speech/convspeech_gen.cc deleted file mode 100644 index 2b88597987..0000000000 --- a/webrtc/modules/audio_processing/test/conversational_speech/convspeech_gen.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 - -#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 \n" - " -t \n" - " -o \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/webrtc/modules/audio_processing/test/conversational_speech/settings.cc b/webrtc/modules/audio_processing/test/conversational_speech/settings.cc deleted file mode 100644 index 8b2e88b493..0000000000 --- a/webrtc/modules/audio_processing/test/conversational_speech/settings.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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/webrtc/modules/audio_processing/test/conversational_speech/settings.h b/webrtc/modules/audio_processing/test/conversational_speech/settings.h deleted file mode 100644 index ea360b7952..0000000000 --- a/webrtc/modules/audio_processing/test/conversational_speech/settings.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 - -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/webrtc/modules/audio_processing/test/conversational_speech/OWNERS b/webrtc/modules/audio_processing/test/py_conversational_speech/OWNERS similarity index 100% rename from webrtc/modules/audio_processing/test/conversational_speech/OWNERS rename to webrtc/modules/audio_processing/test/py_conversational_speech/OWNERS diff --git a/webrtc/modules/audio_processing/test/conversational_speech/README.md b/webrtc/modules/audio_processing/test/py_conversational_speech/README.md similarity index 92% rename from webrtc/modules/audio_processing/test/conversational_speech/README.md rename to webrtc/modules/audio_processing/test/py_conversational_speech/README.md index 415c65b027..79d07fdf08 100644 --- a/webrtc/modules/audio_processing/test/conversational_speech/README.md +++ b/webrtc/modules/audio_processing/test/py_conversational_speech/README.md @@ -1,7 +1,7 @@ -# Conversational Speech generator tool +#Conversational Speech generator tool -Tool to generate multiple-end audio tracks to simulate conversational speech -with two or more participants. +Python 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 @@ and silence in the conversation. 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/webrtc/modules/audio_processing/test/py_conversational_speech/generate_conversational_tracks.py b/webrtc/modules/audio_processing/test/py_conversational_speech/generate_conversational_tracks.py new file mode 100644 index 0000000000..41e3bbdc6b --- /dev/null +++ b/webrtc/modules/audio_processing/test/py_conversational_speech/generate_conversational_tracks.py @@ -0,0 +1,58 @@ +#!/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/webrtc/modules/audio_processing/test/py_conversational_speech/test_generation.py b/webrtc/modules/audio_processing/test/py_conversational_speech/test_generation.py new file mode 100644 index 0000000000..3fc34e399d --- /dev/null +++ b/webrtc/modules/audio_processing/test/py_conversational_speech/test_generation.py @@ -0,0 +1,20 @@ +#!/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)