diff options
| author | historia <historiavg@proton.me> | 2026-08-27 15:53:22 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-27 15:53:22 -0400 |
| commit | 2252a0e4ae86fcc71a58af99d63750adab54cabd (patch) | |
| tree | 489a5e5d2124a831be31a69ee740ec4c260661e1 /app/ui | |
| parent | 5b98993b13dafe9a85495e4c68ad9b42863ef2bf (diff) | |
| download | tts-audiobook-generator-2252a0e4ae86fcc71a58af99d63750adab54cabd.tar.gz | |
feat: menu for language options
Diffstat (limited to 'app/ui')
| -rw-r--r-- | app/ui/hub.py | 22 | ||||
| -rw-r--r-- | app/ui/tui.py | 1 |
2 files changed, 17 insertions, 6 deletions
diff --git a/app/ui/hub.py b/app/ui/hub.py index 230def3..7ac938e 100644 --- a/app/ui/hub.py +++ b/app/ui/hub.py @@ -58,6 +58,7 @@ from converter.clients import ( BACKEND_AUDIOCPP, BACKEND_FASTER, BACKEND_QWEN, + LANGUAGE_CHOICES, QWEN3_TTS_SPEAKERS, audiocpp_entry_voice_capability, normalize_language, @@ -908,22 +909,29 @@ def _field_value(fields, key: str, default=None): return default +# Dim hint shown while editing a Language field (Settings and Generate +# audiobooks): which languages a model accepts varies by backend/model. +_LANGUAGE_EDIT_HINT = ["Check model documentation for supported languages."] + + def _common_fields() -> list: """Field dicts for output format, language, speed, single-file, debug. The single-file field is hidden for m4b (always a single file with embedded chapter markers), so its "visible" callable reads the live output-format value from the field list. The per-run Language field - mirrors the CLI's --language and is hidden for faster entries (the - faster server owns the language). + mirrors the CLI's --language (a static audio.cpp-menu picker) and is + hidden for faster entries (the faster server owns the language). """ fmt_default = config.AUDIO_FORMAT \ if config.AUDIO_FORMAT in AUDIO_FORMATS else AUDIO_FORMATS[0] return [ {"key": "output_format", "label": "Output format", "kind": "choice", "value": fmt_default, "choices": list(AUDIO_FORMATS)}, - {"key": "language", "label": "Language", "kind": "text", - "value": config.LANGUAGE, "validate": _validate_language, + {"key": "language", "label": "Language", "kind": "choice", + "value": config.LANGUAGE, "choices": list(LANGUAGE_CHOICES), + "help": _LANGUAGE_EDIT_HINT, + "validate": _validate_language, "visible": lambda fs: not str(_field_value(fs, "backend") or "") .startswith("faster")}, {"key": "speed", "label": "Speed", "kind": "text", "value": "1.0", @@ -1437,8 +1445,10 @@ def _settings_fields() -> list: {"key": "audio_bitrate", "label": "Audio bitrate", "kind": "text", "value": config.AUDIO_BITRATE, "validate": _validate_bitrate}, - {"key": "language", "label": "Language", "kind": "text", - "value": config.LANGUAGE, "validate": _validate_language}, + {"key": "language", "label": "Default Language", "kind": "choice", + "value": config.LANGUAGE, "choices": list(LANGUAGE_CHOICES), + "help": _LANGUAGE_EDIT_HINT, + "validate": _validate_language}, {"key": "chunk_size", "label": "Chunk size (words)", "kind": "text", "value": str(config.CHUNK_SIZE), "validate": _validate_chunk_size}, {"key": "stop_and_exit", "label": "Default stop server and exit", diff --git a/app/ui/tui.py b/app/ui/tui.py index 319c123..a647444 100644 --- a/app/ui/tui.py +++ b/app/ui/tui.py @@ -1114,6 +1114,7 @@ def form(scr, title: str, fields: Sequence[dict], if field["value"] in values else 0 chosen = menu(scr, field_label(field), pairs, default_index=default, + help_lines=field_help(field), back_value=edit_cancel) if chosen is not edit_cancel: field["value"] = chosen |
