From 0005d029404a3aa313e1c7226183286f97b067d9 Mon Sep 17 00:00:00 2001 From: James Betker Date: Thu, 12 May 2022 11:24:55 -0600 Subject: [PATCH] read.py: allow user-specified splits --- tortoise/data/layman.txt | 0 tortoise/read.py | 14 ++++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 tortoise/data/layman.txt diff --git a/tortoise/data/layman.txt b/tortoise/data/layman.txt new file mode 100644 index 0000000..e69de29 diff --git a/tortoise/read.py b/tortoise/read.py index 9ee9ad6..e89bbc9 100644 --- a/tortoise/read.py +++ b/tortoise/read.py @@ -48,14 +48,20 @@ if __name__ == '__main__': if regenerate is not None: regenerate = [int(e) for e in regenerate.split(',')] + # Process text + with open(args.textfile, 'r', encoding='utf-8') as f: + text = ' '.join([l for l in f.readlines()]) + if '|' in text: + print("Found the '|' character in your text, which I will use as a cue for where to split it up. If this was not" + "your intent, please remove all '|' characters from the input.") + texts = text.split('|') + else: + texts = split_and_recombine_text(text) + for selected_voice in selected_voices: voice_outpath = os.path.join(outpath, selected_voice) os.makedirs(voice_outpath, exist_ok=True) - with open(args.textfile, 'r', encoding='utf-8') as f: - text = ''.join([l for l in f.readlines()]) - texts = split_and_recombine_text(text) - if '&' in selected_voice: voice_sel = selected_voice.split('&') else: