From c4a5a2398532b8f6c79b0571c24bfde353ee4ddd Mon Sep 17 00:00:00 2001 From: James Betker Date: Thu, 12 May 2022 20:15:22 -0600 Subject: [PATCH] add eval script for testing --- tortoise/eval.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tortoise/eval.py diff --git a/tortoise/eval.py b/tortoise/eval.py new file mode 100644 index 0000000..312b162 --- /dev/null +++ b/tortoise/eval.py @@ -0,0 +1,27 @@ +import argparse +import os + +import torchaudio + +from api import TextToSpeech +from tortoise.utils.audio import load_audio + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('--eval_path', type=str, help='Path to TSV test file', default="D:\\tmp\\tortoise-tts-eval\\test.tsv") + parser.add_argument('--output_path', type=str, help='Where to put results', default="D:\\tmp\\tortoise-tts-eval\\baseline") + parser.add_argument('--preset', type=str, help='Rendering preset.', default="standard") + args = parser.parse_args() + os.makedirs(args.output_path, exist_ok=True) + + tts = TextToSpeech() + + with open(args.eval_path, 'r', encoding='utf-8') as f: + lines = f.readlines() + + for line in lines: + text, real = line.strip().split('\t') + conds = [load_audio(real, 22050)] + gen = tts.tts_with_preset(text, voice_samples=conds, conditioning_latents=None, preset=args.preset) + torchaudio.save(os.path.join(args.output_path, os.path.basename(real)), gen.squeeze(0).cpu(), 24000) +