Skip to content

Commit

Permalink
Add integration test for server package
Browse files Browse the repository at this point in the history
  • Loading branch information
reuben committed Nov 27, 2019
1 parent d62234e commit e89d62a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .travis/script
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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()
Expand Down
3 changes: 1 addition & 2 deletions tests/inputs/server_config.json
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 3 additions & 1 deletion tests/test_demo_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def _create_random_model(self):
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 changes: 32 additions & 0 deletions tests/test_server_package.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e89d62a

Please sign in to comment.