Add integration test for server package

pull/10/head
Reuben Morais 2019-11-27 17:14:38 +01:00
parent d62234e06e
commit e89d62a772
5 changed files with 39 additions and 4 deletions

View File

@ -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

View File

@ -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()

View File

@ -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.

View File

@ -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!!")

32
tests/test_server_package.sh Executable file
View File

@ -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