From 7c22f046643102606c5b430770ff0d8d4388f734 Mon Sep 17 00:00:00 2001 From: Justin John <34035011+justinjohn0306@users.noreply.github.com> Date: Thu, 11 Jan 2024 13:53:33 +0530 Subject: [PATCH] Update fakeyou_infer.py --- tts/StyleTTS2/fakeyou_infer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tts/StyleTTS2/fakeyou_infer.py b/tts/StyleTTS2/fakeyou_infer.py index 738185d..c7e210f 100644 --- a/tts/StyleTTS2/fakeyou_infer.py +++ b/tts/StyleTTS2/fakeyou_infer.py @@ -6,7 +6,11 @@ import soundfile as sf from styletts2importable import compute_style, inference from tortoise.utils.text import split_and_recombine_text -def clsynthesize(text, voice_path, vcsteps): +def clsynthesize(text_file_path, voice_path, vcsteps): + # Load the text from the file + with open(text_file_path, 'r', encoding="utf-8") as file: + text = file.read() + # Load the custom voice custom_voice = compute_style(voice_path) @@ -22,16 +26,16 @@ def clsynthesize(text, voice_path, vcsteps): def main(): parser = argparse.ArgumentParser(description='CLI for StyleTTS Voice Synthesis') - parser.add_argument('--text', type=str, required=True, help='Text to synthesize') + parser.add_argument('--input', type=str, required=True, help='Path to the text file') parser.add_argument('--voice', type=str, required=True, help='Path to the custom voice audio file') parser.add_argument('--vcsteps', type=int, required=True, help='Number of diffusion steps') parser.add_argument('--output', type=str, required=True, help='Output path for the synthesized audio file') args = parser.parse_args() - sample_rate, audio = clsynthesize(args.text, args.voice, args.vcsteps) + sample_rate, audio = clsynthesize(args.input, args.voice, args.vcsteps) # Save the synthesized audio to the specified output path sf.write(args.output, audio, sample_rate) if __name__ == "__main__": - main() \ No newline at end of file + main()