diff --git a/tts.py b/tts.py index 831903b..aa5ee0c 100644 --- a/tts.py +++ b/tts.py @@ -11,10 +11,21 @@ from fairseq.models.text_to_speech.hub_interface import TTSHubInterface import scipy import numpy as np +def read_input_file(name: str): + """ + Read lines from input file + """ + with open(name, "r", encoding="utf-8") as file: + lines = file.readlines() + return lines + def main(): """ Defined starting point of source code. """ + rate = 44100 + full_wave_file = [] + sentences = [] # Parsing command line arguments parser = argparse.ArgumentParser(description='Convert teext to speech.') @@ -30,13 +41,8 @@ def main(): TTSHubInterface.update_cfg_with_data_cfg(cfg, task.data_cfg) generator = task.build_generator(models, cfg) - full_wave_file = [] - rate = 44100 - sentences = [] - # Read input file - with open(args['input'], "r", encoding="utf-8") as file: - lines = file.readlines() + lines = read_input_file(args['input']) # Convert to sentences for line in lines: