diff --git a/tts.py b/tts.py index 7cadca1..35670f3 100755 --- a/tts.py +++ b/tts.py @@ -18,6 +18,8 @@ from tqdm import tqdm import pyperclip from yaspin import yaspin +import os + # See voices: https://huggingface.co/hexgrad/Kokoro-82M/blob/main/VOICES.md voices = { 'pro': 'af_heart', @@ -40,6 +42,9 @@ prep_texts = [ "All systems green—let's make this a good one." ] +dir_path = os.path.dirname(os.path.realpath(__file__)) +demo_file = f"{dir_path}/demo/tongue-twister.txt" + def parse_args(): parser = argparse.ArgumentParser(description="Simple TTS - machine learning text-to-speech for your terminal", allow_abbrev=False) parser.add_argument( @@ -54,8 +59,8 @@ def parse_args(): "-i", required=False, type=str, - default="demo/tongue-twister.txt", - help="path to the input text file", + default=demo_file, + help = "path to the input text file", ) parser.add_argument( "--clipboard", @@ -162,8 +167,8 @@ def main(): text = pyperclip.paste() name = 'copied' else: - dirname = os.path.dirname(__file__) - file_path = os.path.join(dirname, args.input_file) + cwd = os.getcwd() + file_path = os.path.join(cwd, args.input_file) directory, file_name = os.path.split(file_path) name = '.'.join(file_name.split('.')[:-1]) file = open(file_path, "r")