fix: input file directories
This commit is contained in:
parent
b7d4b1ac5e
commit
aa03f6ed21
1 changed files with 9 additions and 4 deletions
13
tts.py
13
tts.py
|
|
@ -18,6 +18,8 @@ from tqdm import tqdm
|
||||||
import pyperclip
|
import pyperclip
|
||||||
from yaspin import yaspin
|
from yaspin import yaspin
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
# See voices: https://huggingface.co/hexgrad/Kokoro-82M/blob/main/VOICES.md
|
# See voices: https://huggingface.co/hexgrad/Kokoro-82M/blob/main/VOICES.md
|
||||||
voices = {
|
voices = {
|
||||||
'pro': 'af_heart',
|
'pro': 'af_heart',
|
||||||
|
|
@ -40,6 +42,9 @@ prep_texts = [
|
||||||
"All systems green—let's make this a good one."
|
"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():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(description="Simple TTS - machine learning text-to-speech for your terminal", allow_abbrev=False)
|
parser = argparse.ArgumentParser(description="Simple TTS - machine learning text-to-speech for your terminal", allow_abbrev=False)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|
@ -54,8 +59,8 @@ def parse_args():
|
||||||
"-i",
|
"-i",
|
||||||
required=False,
|
required=False,
|
||||||
type=str,
|
type=str,
|
||||||
default="demo/tongue-twister.txt",
|
default=demo_file,
|
||||||
help="path to the input text file",
|
help = "path to the input text file",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--clipboard",
|
"--clipboard",
|
||||||
|
|
@ -162,8 +167,8 @@ def main():
|
||||||
text = pyperclip.paste()
|
text = pyperclip.paste()
|
||||||
name = 'copied'
|
name = 'copied'
|
||||||
else:
|
else:
|
||||||
dirname = os.path.dirname(__file__)
|
cwd = os.getcwd()
|
||||||
file_path = os.path.join(dirname, args.input_file)
|
file_path = os.path.join(cwd, args.input_file)
|
||||||
directory, file_name = os.path.split(file_path)
|
directory, file_name = os.path.split(file_path)
|
||||||
name = '.'.join(file_name.split('.')[:-1])
|
name = '.'.join(file_name.split('.')[:-1])
|
||||||
file = open(file_path, "r")
|
file = open(file_path, "r")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue