From e4b42be01fc031810160126013833175413ec84c Mon Sep 17 00:00:00 2001 From: historia Date: Thu, 20 Aug 2026 22:38:58 +0000 Subject: feat: prompt for overwrites before connecting to TTS server --- audiobook.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'audiobook.py') diff --git a/audiobook.py b/audiobook.py index b881a12..0b3734c 100755 --- a/audiobook.py +++ b/audiobook.py @@ -227,6 +227,26 @@ Examples: else: voice_mode = VOICE_MODE_CLONE if args.clone else VOICE_MODE_CUSTOM + # Ask every overwrite question up front, before spending time connecting + # to a TTS server: a user who declines (or has nothing to convert) never + # waits on a slow server handshake. Nothing in this step needs the server. + book_files, planned = AudiobookConverter.preflight_overwrites( + backend=args.backend, + voice=args.voice, + voice_mode=voice_mode, + voice_clone_ref_audio=args.clone, + output_format=args.format, + ) + + if not book_files: + print("[INFO] Nothing to convert. Add a .txt, .pdf, or .epub file " + "to the input folder and run again.") + sys.exit(0) + + if not planned: + print("[INFO] Nothing to convert (all books skipped)") + sys.exit(0) + try: converter = AudiobookConverter( voice_mode=voice_mode, @@ -242,6 +262,8 @@ Examples: debug=args.debug, chunk=args.chunk, ) + converter._book_files = book_files + converter._planned = planned ok = converter.run() except KeyboardInterrupt: print("\n[WARNING] Shutdown requested by user") -- cgit v1.2.3