From 16603ad31c93d56ced6f4ae7fd05bc4191f8dab7 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Mon, 25 Apr 2022 19:04:00 -0400 Subject: [PATCH] Set no download option for test --- Dockerfile.test | 2 +- test.sh | 2 +- tests/get_sample_hashes.py | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Dockerfile.test b/Dockerfile.test index 3f12b09..2727b1a 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -45,4 +45,4 @@ RUN --mount=type=cache,id=pip-venv,target=/root/.cache/pip \ # Run tests COPY voices/ /usr/share/mimic3/voices/ -RUN ./test.sh +RUN ./test.sh --no-download diff --git a/test.sh b/test.sh index f0f22ad..44f6de5 100755 --- a/test.sh +++ b/test.sh @@ -37,4 +37,4 @@ if [ -d "${venv}" ]; then source "${venv}/bin/activate" fi -diff "${expected_hashes}" <(python3 tests/get_sample_hashes.py) +diff "${expected_hashes}" <(python3 tests/get_sample_hashes.py "$@") diff --git a/tests/get_sample_hashes.py b/tests/get_sample_hashes.py index db04dd0..de1cb98 100644 --- a/tests/get_sample_hashes.py +++ b/tests/get_sample_hashes.py @@ -91,7 +91,9 @@ _LOGGER = logging.getLogger("get_samples") # ----------------------------------------------------------------------------- -def synthesize(output_dir: Path, voice: Voice) -> typing.Iterable[str]: +def synthesize( + output_dir: Path, voice: Voice, args: argparse.Namespace +) -> typing.Iterable[str]: """Generate samples for voice in a separate process""" tts = Mimic3TextToSpeechSystem( Mimic3Settings( @@ -99,6 +101,7 @@ def synthesize(output_dir: Path, voice: Voice) -> typing.Iterable[str]: noise_scale=0.0, noise_w=0.0, use_deterministic_compute=True, + no_download=args.no_download, ) ) @@ -142,6 +145,9 @@ def main(): """Generate WAV samples from Mimic 3 in deterministic mode for testing""" parser = argparse.ArgumentParser() parser.add_argument("--output-dir", help="Directory to write samples") + parser.add_argument( + "--no-download", action="store_true", help="Don't download voices" + ) args = parser.parse_args() logging.basicConfig(level=logging.INFO) @@ -163,7 +169,9 @@ def main(): with temp_dir, Pool() as pool: voices = sorted(tts.get_voices(), key=lambda v: v.key) - for results in pool.map(functools.partial(synthesize, output_dir), voices): + for results in pool.map( + functools.partial(synthesize, output_dir, args), voices + ): for result in results: print(result)