diff options
| author | historia <historiavg@proton.me> | 2026-08-20 22:39:04 +0000 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-20 23:02:09 +0000 |
| commit | 0c197324f5444b448c285d2a57bd0a5834c2fc84 (patch) | |
| tree | 494954b098cb3e74bb8c7c2bcc883ee971ebf574 /tools/make_audiocpp_server_json.py | |
| parent | e4b42be01fc031810160126013833175413ec84c (diff) | |
| download | tts-audiobook-generator-0c197324f5444b448c285d2a57bd0a5834c2fc84.tar.gz | |
feat: warn on empty transcripts and missing whisper backend in server.json tool
Diffstat (limited to 'tools/make_audiocpp_server_json.py')
| -rwxr-xr-x | tools/make_audiocpp_server_json.py | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tools/make_audiocpp_server_json.py b/tools/make_audiocpp_server_json.py index 40354eb..c999f49 100755 --- a/tools/make_audiocpp_server_json.py +++ b/tools/make_audiocpp_server_json.py @@ -38,7 +38,7 @@ from typing import Dict, Optional sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from converter import config -from converter.tts import transcribe_reference_audio +from converter.tts import transcribe_reference_audio, whisper_backend_available DEFAULT_HOST = "127.0.0.1" FALLBACK_PORT = 8080 @@ -307,6 +307,33 @@ def _print_next_steps(output_path: Path, include_custom: bool, "since speaker mode needs the CustomVoice model.") +def print_empty_transcript_warning(voice_presets: Dict[str, dict]) -> None: + """Print a loud, final warning for voices whose transcript is empty. + + A cloning preset with an empty ``reference_text`` will not produce a + usable voice (the server has nothing to match the reference audio + against for in-context cloning), so the user must edit server.json by + hand. This is printed last, after the next-steps, so it is the last + thing seen and hardest to miss. + """ + empty = sorted(name for name, preset in voice_presets.items() + if not preset.get("reference_text")) + if not empty: + return + bar = "=" * 70 + print() + print(bar) + print("[WARNING] MANUAL TRANSCRIPTION REQUIRED") + print(bar) + listing = " - " + "\n - ".join(empty) if len(empty) > 1 else f" - {empty[0]}" + print(f"The following voice preset(s) have an EMPTY reference_text in " + f"server.json:\n{listing}") + print("Those voices will NOT work until you add a manual transcription.") + print('Edit server.json and fill in the "reference_text" field for each ' + "voice above with an accurate transcript of its reference .wav.") + print(bar) + + def main() -> int: parser = argparse.ArgumentParser( description="Generate a server.json for the audio.cpp audiocpp_server " @@ -404,6 +431,12 @@ def main() -> int: if wav_dir is not None: wav_files = find_wav_files(wav_dir) if wav_files: + if whisper_backend_available() is None: + print("[WARNING] Neither faster_whisper nor whisper was found, so " + "reference .wav files cannot be transcribed automatically and " + "every reference_text will be empty.") + print(' Did you remember to "conda activate qwen3-tts"? ' + "Transcripts must be added by hand (see the warning at the end).") voice_presets = build_voice_presets(wav_files, args.whisper_model) else: print(f"[WARNING] No .wav files found in {wav_dir}; writing the " @@ -436,6 +469,7 @@ def main() -> int: print(f"\n[OK] Wrote {args.output} with {len(server_config['models'])} " f"model(s) and {len(voice_presets)} voice preset(s)") _print_next_steps(args.output, include_custom, include_clone, voice_presets) + print_empty_transcript_warning(voice_presets) return 0 |
