Skip to content

Commit b0250f0

Browse files
ehlemur-zzCommit Bot
authored andcommitted
Reland "Don't download PESQ and POLQA in the low_bandwidth_audio_test.py script."
This is a reland of f4898a6 Original change's description: > Don't download PESQ and POLQA in the low_bandwidth_audio_test.py script. > > They should've been downloaded already. > > NOTRY=True > > Bug: chromium:755660 > Change-Id: I8ecb355f06026a38bd9377633e2be6c55d7c6452 > Reviewed-on: https://webrtc-review.googlesource.com/5620 > Commit-Queue: Edward Lemur <ehmaldonado@webrtc.org> > Reviewed-by: Oleh Prypin <oprypin@webrtc.org> > Reviewed-by: Henrik Kjellander <kjellander@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20109} No-Try: true Bug: chromium:755660 Change-Id: I391130545eee5d4928101f87ac4a4e0945d665a1 Reviewed-on: https://webrtc-review.googlesource.com/6380 Commit-Queue: Edward Lemur <ehmaldonado@webrtc.org> Reviewed-by: Henrik Kjellander <kjellander@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20140}
1 parent 14fc998 commit b0250f0

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

audio/test/low_bandwidth_audio_test.py

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
2828
SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir))
2929

30+
NO_TOOLS_ERROR_MESSAGE = (
31+
'Could not find PESQ or POLQA at %s.\n'
32+
'\n'
33+
'To fix this run:\n'
34+
' python %s %s\n'
35+
'\n'
36+
'Note that these tools are Google-internal due to licensing, so in order to '
37+
'use them you will have to get your own license and manually put them in the '
38+
'right location.\n'
39+
'See https://cs.chromium.org/chromium/src/third_party/webrtc/tools_webrtc/'
40+
'download_tools.py?rcl=bbceb76f540159e2dba0701ac03c514f01624130&l=13')
41+
3042

3143
def _LogCommand(command):
3244
logging.info('Running %r', command)
@@ -55,17 +67,31 @@ def _GetPlatform():
5567
return 'linux'
5668

5769

58-
def _DownloadTools():
70+
def _GetExtension():
71+
return '.exe' if sys.platform == 'win32' else ''
72+
73+
74+
def _GetPathToTools():
5975
tools_dir = os.path.join(SRC_DIR, 'tools_webrtc')
6076
toolchain_dir = os.path.join(tools_dir, 'audio_quality')
6177

62-
# Download PESQ and POLQA.
63-
download_script = os.path.join(tools_dir, 'download_tools.py')
64-
command = [sys.executable, download_script, toolchain_dir]
65-
subprocess.check_call(_LogCommand(command))
78+
platform = _GetPlatform()
79+
ext = _GetExtension()
80+
81+
pesq_path = os.path.join(toolchain_dir, platform, 'pesq' + ext)
82+
if not os.path.isfile(pesq_path):
83+
pesq_path = None
84+
85+
polqa_path = os.path.join(toolchain_dir, platform, 'PolqaOem64' + ext)
86+
if not os.path.isfile(polqa_path):
87+
polqa_path = None
88+
89+
if (platform != 'mac' and not polqa_path) or not pesq_path:
90+
logging.error(NO_TOOLS_ERROR_MESSAGE,
91+
toolchain_dir,
92+
os.path.join(tools_dir, 'download_tools.py'),
93+
toolchain_dir)
6694

67-
pesq_path = os.path.join(toolchain_dir, _GetPlatform(), 'pesq')
68-
polqa_path = os.path.join(toolchain_dir, _GetPlatform(), 'PolqaOem64')
6995
return pesq_path, polqa_path
7096

7197

@@ -140,15 +166,8 @@ def _RunPolqa(executable_path, reference_file, degraded_file):
140166
# Analyze audio.
141167
command = [executable_path, '-q', '-LC', 'NB',
142168
'-Ref', reference_file, '-Test', degraded_file]
143-
try:
144-
process = subprocess.Popen(_LogCommand(command),
145-
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
146-
except OSError as e:
147-
if e.errno == os.errno.ENOENT:
148-
logging.warning('POLQA executable missing, skipping test.')
149-
return {}
150-
else:
151-
raise
169+
process = subprocess.Popen(_LogCommand(command),
170+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
152171
out, err = process.communicate()
153172

154173
# Find the scores in stdout of POLQA.
@@ -176,7 +195,9 @@ def main():
176195

177196
args = _ParseArgs()
178197

179-
pesq_path, polqa_path = _DownloadTools()
198+
pesq_path, polqa_path = _GetPathToTools()
199+
if pesq_path is None:
200+
return 1
180201

181202
out_dir = os.path.join(args.build_dir, '..')
182203
if args.android:
@@ -189,7 +210,7 @@ def main():
189210
# Check if POLQA can run at all, or skip the 48 kHz tests entirely.
190211
example_path = os.path.join(SRC_DIR, 'resources',
191212
'voice_engine', 'audio_tiny48.wav')
192-
if _RunPolqa(polqa_path, example_path, example_path):
213+
if polqa_path and _RunPolqa(polqa_path, example_path, example_path):
193214
analyzers.append(Analyzer(_RunPolqa, polqa_path, 48000))
194215

195216
for analyzer in analyzers:

0 commit comments

Comments
 (0)