From e89d62a7726064c5fa153fbdb64d7d9529d9eea9 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Wed, 27 Nov 2019 17:14:38 +0100 Subject: [PATCH] Add integration test for server package --- .travis/script | 2 ++ setup.py | 2 +- tests/inputs/server_config.json | 3 +-- tests/test_demo_server.py | 4 +++- tests/test_server_package.sh | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100755 tests/test_server_package.sh diff --git a/.travis/script b/.travis/script index 41a17a4c..ca6f4cd3 100755 --- a/.travis/script +++ b/.travis/script @@ -14,4 +14,6 @@ if [[ "$TEST_SUITE" == "unittest" ]]; then pushd tts_namespace python -m unittest popd + # Test server package + ./tests/test_server_package.sh fi diff --git a/setup.py b/setup.py index ae630a1c..3cb7827a 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ import setuptools.command.develop import setuptools.command.build_py -parser = argparse.ArgumentParser(add_help=False) +parser = argparse.ArgumentParser(add_help=False, allow_abbrev=False) parser.add_argument('--checkpoint', type=str, help='Path to checkpoint file to embed in wheel.') parser.add_argument('--model_config', type=str, help='Path to model configuration file to embed in wheel.') args, unknown_args = parser.parse_known_args() diff --git a/tests/inputs/server_config.json b/tests/inputs/server_config.json index 8ac266bd..3988db4c 100644 --- a/tests/inputs/server_config.json +++ b/tests/inputs/server_config.json @@ -1,6 +1,5 @@ { - "tts_path":"TTS/tests/outputs/", // tts model root folder - "tts_file":"checkpoint_10.pth.tar", // tts checkpoint file + "tts_checkpoint":"checkpoint_10.pth.tar", // tts checkpoint file "tts_config":"dummy_model_config.json", // tts config.json file "tts_speakers": null, // json file listing speaker ids. null if no speaker embedding. "wavernn_lib_path": null, // Rootpath to wavernn project folder to be imported. If this is null, model uses GL for speech synthesis. diff --git a/tests/test_demo_server.py b/tests/test_demo_server.py index 5eb3c01c..c343a6a4 100644 --- a/tests/test_demo_server.py +++ b/tests/test_demo_server.py @@ -20,6 +20,8 @@ class DemoServerTest(unittest.TestCase): def test_in_out(self): self._create_random_model() config = load_config(os.path.join(get_tests_input_path(), 'server_config.json')) - config['tts_path'] = get_tests_output_path() + tts_root_path = get_tests_output_path() + config['tts_checkpoint'] = os.path.join(tts_root_path, config['tts_checkpoint']) + config['tts_config'] = os.path.join(tts_root_path, config['tts_config']) synthesizer = Synthesizer(config) synthesizer.tts("Better this test works!!") diff --git a/tests/test_server_package.sh b/tests/test_server_package.sh new file mode 100755 index 00000000..01e42843 --- /dev/null +++ b/tests/test_server_package.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -xe + +if [[ ! -f tests/outputs/checkpoint_10.pth.tar ]]; then + echo "Missing dummy model in tests/outputs. This test needs to run after the Python unittests have been run." + exit 1 +fi + +python -m venv /tmp/venv +source /tmp/venv/bin/activate +pip install --quiet --upgrade pip setuptools wheel + +rm -f dist/*.whl +python setup.py bdist_wheel --checkpoint tests/outputs/checkpoint_10.pth.tar --model_config tests/outputs/dummy_model_config.json +pip install --quiet dist/TTS*.whl + +python -m TTS.server.server & +SERVER_PID=$! + +echo 'Waiting for server...' +sleep 30 + +curl -o /tmp/audio.wav "http://localhost:5002/api/tts?text=synthesis%20schmynthesis" +python -c 'import sys; import wave; print(wave.open(sys.argv[1]).getnframes())' /tmp/audio.wav + +kill $SERVER_PID + +deactivate +rm -rf /tmp/venv + +rm /tmp/audio.wav +rm dist/*.whl