test for synthesize.py

pull/441/head
Eren Gölge 2021-04-27 14:10:45 +02:00
parent 19d9f58009
commit 1235e54738
4 changed files with 36 additions and 3 deletions

View File

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

View File

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

View File

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

28
tests/test_synthesize.py Normal file
View File

@ -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}"'
)