aboutsummaryrefslogtreecommitdiff
path: root/audiobook.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-20 22:38:58 +0000
committerhistoria <historiavg@proton.me>2026-08-20 23:02:09 +0000
commite4b42be01fc031810160126013833175413ec84c (patch)
tree1793b8d060d1272c9f95290599e45e2f1b477ff3 /audiobook.py
parent5ca77f86b70718b4ef1a07299efbd6431268d546 (diff)
downloadtts-audiobook-generator-e4b42be01fc031810160126013833175413ec84c.tar.gz
feat: prompt for overwrites before connecting to TTS server
Diffstat (limited to 'audiobook.py')
-rwxr-xr-xaudiobook.py22
1 files changed, 22 insertions, 0 deletions
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")