aboutsummaryrefslogtreecommitdiff
path: root/converter
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-20 22:39:04 +0000
committerhistoria <historiavg@proton.me>2026-08-20 23:02:09 +0000
commit0c197324f5444b448c285d2a57bd0a5834c2fc84 (patch)
tree494954b098cb3e74bb8c7c2bcc883ee971ebf574 /converter
parente4b42be01fc031810160126013833175413ec84c (diff)
downloadtts-audiobook-generator-0c197324f5444b448c285d2a57bd0a5834c2fc84.tar.gz
feat: warn on empty transcripts and missing whisper backend in server.json tool
Diffstat (limited to 'converter')
-rw-r--r--converter/tts.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/converter/tts.py b/converter/tts.py
index afb0655..142cf6d 100644
--- a/converter/tts.py
+++ b/converter/tts.py
@@ -179,6 +179,24 @@ def transcribe_reference_audio(audio_path: str, model_name: str = "base") -> Opt
return None
+def whisper_backend_available() -> Optional[str]:
+ """Return the name of an importable Whisper backend, or None.
+
+ Checks faster_whisper first (preferred), then the openai-whisper
+ package, without importing the heavy model code: a bare import probe
+ is enough to tell whether the package is installed in the current
+ environment. Used by the make_audiocpp_server_json tool to warn when
+ neither is present (e.g. the wrong conda environment is active).
+ """
+ for backend in ("faster_whisper", "whisper"):
+ try:
+ __import__(backend)
+ except ImportError:
+ continue
+ return backend
+ return None
+
+
# Duration sanity check: a response whose audio is far shorter than its
# word count implies is treated as silently truncated, fails the request,
# and goes through the normal retry logic. 150 wpm is a typical spoken