diff --git a/TTS/bin/synthesize.py b/TTS/bin/synthesize.py index da91fbf7..a5066e3d 100755 --- a/TTS/bin/synthesize.py +++ b/TTS/bin/synthesize.py @@ -27,7 +27,7 @@ def main(): parser = argparse.ArgumentParser( description="""Synthesize speech on command line.\n\n""" """You can either use your trained model or choose a model from the provided list.\n\n""" - """If you don't specify any models, then it uses LJSpeech based English models\n\n""" + """If you don't specify any models, then it uses LJSpeech based English model.\n\n""" """ # Example Runs: @@ -180,7 +180,7 @@ def main(): args = parser.parse_args() # print the description if either text or list_models is not set - if args.text is None and not args.list_models: + if args.text is None and not args.list_models and not args.list_speaker_idxs: parser.parse_args(["-h"]) # load model manager diff --git a/tests/__init__.py b/tests/__init__.py index 487a5519..f1445c92 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -14,3 +14,8 @@ def get_tests_input_path(): def get_tests_output_path(): """Returns the path to the directory for test outputs.""" return os.path.join(get_tests_path(), "outputs") + + +def run_cli(command): + exit_status = os.system(command) + assert exit_status == 0, f" [!] command `{command}` failed." diff --git a/tests/test_speaker_manager.py b/tests/test_speaker_manager.py index 8fa68834..b176e353 100644 --- a/tests/test_speaker_manager.py +++ b/tests/test_speaker_manager.py @@ -5,9 +5,9 @@ import numpy as np import torch from tests import get_tests_input_path -from TTS.tts.utils.speakers import SpeakerManager from TTS.speaker_encoder.model import SpeakerEncoder from TTS.speaker_encoder.utils.generic_utils import save_checkpoint +from TTS.tts.utils.speakers import SpeakerManager from TTS.utils.audio import AudioProcessor from TTS.utils.io import load_config diff --git a/tests/test_synthesize.py b/tests/test_synthesize.py new file mode 100644 index 00000000..3626f0df --- /dev/null +++ b/tests/test_synthesize.py @@ -0,0 +1,28 @@ +import os + +from tests import get_tests_output_path, run_cli + + +def test_synthesize(): + """Test synthesize.py with diffent arguments.""" + output_path = os.path.join(get_tests_output_path(), "output.wav") + run_cli("tts --list_models") + + # single speaker model + run_cli(f'tts --text "This is an example." --out_path "{output_path}"') + run_cli( + "tts --model_name tts_models/en/ljspeech/speedy-speech-wn" + f'--text "This is an example." --out_path "{output_path}"' + ) + run_cli( + "tts --model_name tts_models/en/ljspeech/speedy-speech-wn " + "--vocoder_name vocoder_models/en/ljspeech/multiband-melgan " + f'--text "This is an example." --out_path "{output_path}"' + ) + + # multi-speaker model + run_cli("tts --model_name tts_models/en/vctk/sc-glow-tts --list_speaker_idxs") + run_cli( + f'tts --model_name tts_models/en/vctk/sc-glow-tts --speaker_idx "p304"' + f'--text "This is an example." --out_path "{output_path}"' + )