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}
This commit is contained in:
alessiob 2017-03-15 07:56:26 -07:00 committed by Commit bot
parent 2549ad4fef
commit 0cf3aa6d0d
9 changed files with 172 additions and 82 deletions

View File

@ -475,6 +475,7 @@ if (rtc_include_tests) {
":audioproc_f",
":audioproc_unittest_proto",
":unpack_aecdump",
"test/conversational_speech",
"test/py_quality_assessment",
]
}

View File

@ -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.
}

View File

@ -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 @@ 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).

View File

@ -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);
}

View File

@ -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

View File

@ -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_

View File

@ -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()

View File

@ -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)