Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed crlf to lf unix on app.py, various other important fixes #104

Merged
merged 5 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Use this tool responsibly and in accordance with all applicable laws.
- 🎙️ High-quality text-to-speech with [Coqui XTTSv2](https://huggingface.co/coqui/XTTS-v2) and [Fairseq](https://github.com/facebookresearch/fairseq/tree/main/examples/mms).
- 🗣️ Optional voice cloning with your own voice file.
- 🌍 Supports 1107 languages (English by default). [List of Supported languages](https://dl.fbaipublicfiles.com/mms/tts/all-tts-languages.html)
- 🖥️ Designed to run on 4GB RAM.
- 🖥️ Designed to run on 4GB RAM, CPU OR GPU

## 🤗 [Huggingface space demo](https://huggingface.co/spaces/drewThomasson/ebook2audiobook)
- Huggingface space is running on free cpu tier so expect very slow or timeout lol, just don't give it giant files is all
Expand Down
45 changes: 21 additions & 24 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,21 @@ def main():
if arg.startswith('--') and arg not in options:
print(f'Error: Unrecognized option "{arg}"')
sys.exit(1)
args = parser.parse_args()

args = vars(parser.parse_args())

# Check if the port is already in use to prevent multiple launches
if not args.headless and is_port_in_use(interface_port):
if not args['headless'] and is_port_in_use(interface_port):
print(f'Error: Port {interface_port} is already in use. The web interface may already be running.')
sys.exit(1)
args.script_mode = args.script_mode if args.script_mode else NATIVE
args.share = args.share if args.share else False
if args.script_mode == NATIVE:

args['script_mode'] = args['script_mode'] if args['script_mode'] else NATIVE
args['share'] = args['share'] if args['share'] else False

if args['script_mode'] == NATIVE:
check_pkg = check_and_install_requirements(requirements_file)
if check_pkg:
print('Package requirements ok')
if check_dictionary():
print ('Dictionary ok')
else:
if not check_dictionary():
sys.exit(1)
else:
print('Some packages could not be installed')
Expand All @@ -170,27 +167,27 @@ def main():
from lib.functions import web_interface, convert_ebook

# Conditions based on the --headless flag
if args.headless:
args.is_gui_process = False
args.audiobooks_dir = audiobooks_cli_dir
if args['headless']:
args['is_gui_process'] = False
args['audiobooks_dir'] = audiobooks_cli_dir

# Condition to stop if both --ebook and --ebooks_dir are provided
if args.ebook and args.ebooks_dir:
if args['ebook'] and args['ebooks_dir']:
print('Error: You cannot specify both --ebook and --ebooks_dir in headless mode.')
sys.exit(1)

# Condition 1: If --ebooks_dir exists, check value and set 'ebooks_dir'
if args.ebooks_dir:
if args['ebooks_dir']:
new_ebooks_dir = None
if args.ebooks_dir == 'default':
if args['ebooks_dir'] == 'default':
print(f'Using the default ebooks_dir: {ebooks_dir}')
new_ebooks_dir = os.path.abspath(ebooks_dir)
else:
# Check if the directory exists
if os.path.exists(args.ebooks_dir):
new_ebooks_dir = os.path.abspath(args.ebooks_dir)
if os.path.exists(args['ebooks_dir']):
new_ebooks_dir = os.path.abspath(args['ebooks_dir'])
else:
print(f'Error: The provided --ebooks_dir "{args.ebooks_dir}" does not exist.')
print(f'Error: The provided --ebooks_dir "{args['ebooks_dir']}" does not exist.')
sys.exit(1)

if os.path.exists(new_ebooks_dir):
Expand All @@ -199,7 +196,7 @@ def main():
if any(file.endswith(ext) for ext in ebook_formats):
full_path = os.path.join(new_ebooks_dir, file)
print(f'Processing eBook file: {full_path}')
args.ebook = full_path
args['ebook'] = full_path
progress_status, audiobook_file = convert_ebook(args)
if audiobook_file is None:
print(f'Conversion failed: {progress_status}')
Expand All @@ -208,7 +205,7 @@ def main():
print(f'Error: The directory {new_ebooks_dir} does not exist.')
sys.exit(1)

elif args.ebook:
elif args['ebook']:
progress_status, audiobook_file = convert_ebook(args)
if audiobook_file is None:
print(f'Conversion failed: {progress_status}')
Expand All @@ -218,7 +215,7 @@ def main():
print('Error: In headless mode, you must specify either an ebook file using --ebook or an ebook directory using --ebooks_dir.')
sys.exit(1)
else:
args.is_gui_process = True
args['is_gui_process'] = True
passed_arguments = sys.argv[1:]
allowed_arguments = {'--share', '--script_mode'}
passed_args_set = {arg for arg in passed_arguments if arg.startswith('--')}
Expand Down
Loading