"git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "58d627aed61ab1780667526da2cf1c1aa27948ad"
Unverified Commit db8f2bf3 authored by moto's avatar moto Committed by GitHub
Browse files

Do not use SoxEffectsChain in sox compatibility test (#781)

This PR replaces `torchaudio.sox_effects.SoxEffectsChain` in `test_sox_compatibility` with bare `sox` command.

The parity of `torchaudio.sox_effects.SoxEffectsChain` against `sox` command is not tested and it has known issues https://github.com/pytorch/audio/issues/771, therefore it is not appropriate to use this class for testing other functions.
parent 131e48b6
...@@ -77,3 +77,24 @@ def convert_audio_file( ...@@ -77,3 +77,24 @@ def convert_audio_file(
command += [dst_path] command += [dst_path]
print(' '.join(command)) print(' '.join(command))
subprocess.run(command, check=True) subprocess.run(command, check=True)
def _flattern(effects):
if not effects:
return effects
if isinstance(effects[0], str):
return effects
return [item for sublist in effects for item in sublist]
def run_sox_effect(input_file, output_file, effect, *, output_sample_rate=None, output_bitdepth=None):
"""Run sox effects"""
effect = _flattern(effect)
command = ['sox', '-V', '--no-dither', input_file]
if output_bitdepth:
command += ['--bits', str(output_bitdepth)]
command += [output_file] + effect
if output_sample_rate:
command += ['rate', str(output_sample_rate)]
print(' '.join(command))
subprocess.run(command, check=True)
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment