From 306d1bfec0d3dc11d770a513cff3de941a796553 Mon Sep 17 00:00:00 2001 From: alessiob Date: Fri, 24 Feb 2017 05:32:21 -0800 Subject: [PATCH] Parallel iterator bash script. The Python files are empty ones, just a placeholder for the code they will host. Sample audio files for the APM quality assessment toolbox BUG=webrtc:7218 NOTRY=True Review-Url: https://codereview.webrtc.org/2711923002 Cr-Commit-Position: refs/heads/master@{#16827} --- webrtc/modules/audio_processing/BUILD.gn | 1 + .../test/py_quality_assessment/BUILD.gn | 66 +++++++++++++++++++ .../test/py_quality_assessment/README.md | 10 +++ .../apm_quality_assessment-export.py | 8 +++ .../apm_quality_assessment-gencfgs.py | 8 +++ .../apm_quality_assessment.py | 8 +++ .../apm_quality_assessment.sh | 63 ++++++++++++++++++ .../py_quality_assessment/output/README.md | 1 + .../quality_assessment/__init__.py | 7 ++ .../apm_configs/default.json | 1 + 10 files changed, 173 insertions(+) create mode 100644 webrtc/modules/audio_processing/test/py_quality_assessment/BUILD.gn create mode 100644 webrtc/modules/audio_processing/test/py_quality_assessment/README.md create mode 100644 webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment-export.py create mode 100644 webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment-gencfgs.py create mode 100644 webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment.py create mode 100644 webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment.sh create mode 100644 webrtc/modules/audio_processing/test/py_quality_assessment/output/README.md create mode 100644 webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/__init__.py create mode 100644 webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/apm_configs/default.json diff --git a/webrtc/modules/audio_processing/BUILD.gn b/webrtc/modules/audio_processing/BUILD.gn index c06707aebf..df272ab73f 100644 --- a/webrtc/modules/audio_processing/BUILD.gn +++ b/webrtc/modules/audio_processing/BUILD.gn @@ -469,6 +469,7 @@ if (rtc_include_tests) { ":audioproc_f", ":audioproc_unittest_proto", ":unpack_aecdump", + "test/py_quality_assessment", ] } } diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/BUILD.gn b/webrtc/modules/audio_processing/test/py_quality_assessment/BUILD.gn new file mode 100644 index 0000000000..f191319bfe --- /dev/null +++ b/webrtc/modules/audio_processing/test/py_quality_assessment/BUILD.gn @@ -0,0 +1,66 @@ +# 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") + +copy("py_quality_assessment") { + testonly = true + sources = [ + "README.md", + "apm_quality_assessment-export.py", + "apm_quality_assessment-gencfgs.py", + "apm_quality_assessment.py", + "apm_quality_assessment.sh", + ] + outputs = [ + "$root_build_dir/py_quality_assessment/{{source_file_part}}", + ] + deps = [ + ":apm_configs", + ":lib", + ":output", + "../..:audioproc_f", + "//resources/audio_processing/test/py_quality_assessment:probing_signals", + ] +} # py_quality_assessment + +copy("lib") { + testonly = true + sources = [ + "quality_assessment/__init__.py", + ] + visibility = [ ":*" ] # Only targets in this file can depend on this. + outputs = [ + "$root_build_dir/py_quality_assessment/quality_assessment/{{source_file_part}}", + ] + deps = [ + "//resources/audio_processing/test/py_quality_assessment:noise_tracks", + ] +} # lib + +copy("apm_configs") { + testonly = true + sources = [ + "quality_assessment/apm_configs/default.json", + ] + visibility = [ ":*" ] # Only targets in this file can depend on this. + outputs = [ + "$root_build_dir/py_quality_assessment/apm_configs/{{source_file_part}}", + ] +} # apm_configs + +copy("output") { + testonly = true + sources = [ + "output/README.md", + ] + visibility = [ ":*" ] # Only targets in this file can depend on this. + outputs = [ + "$root_build_dir/py_quality_assessment/output/{{source_file_part}}", + ] +} # output diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/README.md b/webrtc/modules/audio_processing/test/py_quality_assessment/README.md new file mode 100644 index 0000000000..915bcfe315 --- /dev/null +++ b/webrtc/modules/audio_processing/test/py_quality_assessment/README.md @@ -0,0 +1,10 @@ +**APM Quality Assessment tool** + +Python wrapper of audioproc_f with which quality assessment can be automatized. +The tool allows to simulate different noise conditions, input signals, APM +configurations and it computes different scores. +Once the scores are computed, the results can be easily exported to an HTML page +which allows to listen to the APM input and output signals and also the +reference one used for evaluation. + +IMPORTANT: **the whole code has not been landed yet.** diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment-export.py b/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment-export.py new file mode 100644 index 0000000000..1b526c1b05 --- /dev/null +++ b/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment-export.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 +# 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. diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment-gencfgs.py b/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment-gencfgs.py new file mode 100644 index 0000000000..1b526c1b05 --- /dev/null +++ b/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment-gencfgs.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 +# 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. diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment.py b/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment.py new file mode 100644 index 0000000000..1b526c1b05 --- /dev/null +++ b/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 +# 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. diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment.sh b/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment.sh new file mode 100644 index 0000000000..593f03e985 --- /dev/null +++ b/webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# 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. + +# Customize probing signals, noise sources and scores if needed. +PROBING_SIGNALS=(py_quality_assessment/probing_signals/*.wav) +NOISE_SOURCES=( \ + "identity" \ + "white" \ + "environmental" \ + "echo" \ +) +SCORES=( \ + "polqa" \ + "audio_level" \ +) +OUTPUT_PATH=output + +# Generate standard APM config files. +chmod +x apm_quality_assessment-gencfgs.py +./apm_quality_assessment-gencfgs.py + +# Customize APM configurations if needed. +APM_CONFIGS=(py_quality_assessment/apm_configs/*.json) + +# Add output path if missing. +if [ ! -d ${OUTPUT_PATH} ]; then + mkdir ${OUTPUT_PATH} +fi + +# Start one process for each "probing signal"-"noise source" pair. +chmod +x apm_quality_assessment.py +for probing_signal_filepath in "${PROBING_SIGNALS[@]}" ; do + probing_signal_name="$(basename $probing_signal_filepath)" + probing_signal_name="${probing_signal_name%.*}" + for noise_source_name in "${NOISE_SOURCES[@]}" ; do + LOG_FILE="${OUTPUT_PATH}/apm_qa-${probing_signal_name}-"` + `"${noise_source_name}.log" + echo "Starting ${probing_signal_name} ${noise_source_name} "` + `"(see ${LOG_FILE})" + ./apm_quality_assessment.py \ + -i ${probing_signal_filepath}\ + -o ${OUTPUT_PATH} \ + -n ${noise_source_name} \ + -c "${APM_CONFIGS[@]}" \ + -e "${SCORES[@]}" > $LOG_FILE 2>&1 & + done +done + +# Join. +wait + +# Export results. +./apm_quality_assessment-export.py -o ${OUTPUT_PATH} + +# Show results in the browser. +RESULTS_FILE="$(realpath ${OUTPUT_PATH}/results.html)" +sensible-browser "file://${RESULTS_FILE}" > /dev/null 2>&1 & diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/output/README.md b/webrtc/modules/audio_processing/test/py_quality_assessment/output/README.md new file mode 100644 index 0000000000..66e2a1c848 --- /dev/null +++ b/webrtc/modules/audio_processing/test/py_quality_assessment/output/README.md @@ -0,0 +1 @@ +You can use this folder for the output generated by the apm_quality_assessment scripts. diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/__init__.py b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/__init__.py new file mode 100644 index 0000000000..b870dfaef3 --- /dev/null +++ b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/__init__.py @@ -0,0 +1,7 @@ +# 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. diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/apm_configs/default.json b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/apm_configs/default.json new file mode 100644 index 0000000000..5c3277bac0 --- /dev/null +++ b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/apm_configs/default.json @@ -0,0 +1 @@ +{"-all_default": null}