- stt.py: local + remote (OpenAI-compatible) transcription, TCP reachability status, benchmark. Tested live against faster-whisper-server :8010. - llm.py: LLM engine presets (url/model/key/temperature) + chat + status. Tested live against local Qwen :19001 and llama-swap :28080. - config: [stt]/[[stt_engine]] and [llm]/[[llm_engine]] presets with active selectors; defaults synthesized from legacy [whisper]/[rewrite]. - daemon: transcribe via active STT engine, rewrite via active LLM engine; load local Whisper only when the active STT engine is local. - Rename package entry __main__.py -> blitztext.py (thin __main__ shim keeps `python -m blitztext` working). Remove rewrite.py (folded into llm.py). - App icon extracted from the macOS AppIcon.icns; installed at several hicolor sizes by the .deb and used as the window icon. Drop placeholder SVG. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
"""Blitztext application entry point (CLI + GUI/tray launcher).
|
|
|
|
The thin ``__main__.py`` shim imports ``main()`` from here, so the app's code
|
|
lives in ``blitztext.py`` while ``python -m blitztext`` still works.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from . import __version__
|
|
from .config import CONFIG_PATH, ensure_default, load
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
parser = argparse.ArgumentParser(prog="blitztext", description="Native dictation for Linux.")
|
|
parser.add_argument("--version", action="version", version=f"blitztext {__version__}")
|
|
sub = parser.add_subparsers(dest="cmd")
|
|
|
|
sub.add_parser("tray", help="Run in the system tray with a workflow menu (default).")
|
|
sub.add_parser("gui", help="Open the control panel window.")
|
|
sub.add_parser("run", help="Start the headless hotkey daemon (no window/tray).")
|
|
sub.add_parser("config-path", help="Print the config file path and exit.")
|
|
p_tx = sub.add_parser("transcribe", help="Transcribe a WAV file and print the text (no hotkeys).")
|
|
p_tx.add_argument("audio", type=Path)
|
|
|
|
args = parser.parse_args(argv)
|
|
cmd = args.cmd or "tray"
|
|
|
|
if cmd == "config-path":
|
|
print(ensure_default(CONFIG_PATH))
|
|
return 0
|
|
|
|
if cmd in ("gui", "tray"):
|
|
ensure_default(CONFIG_PATH)
|
|
from .gtkui import run_gui
|
|
|
|
return run_gui(tray_mode=(cmd == "tray"))
|
|
|
|
cfg = load()
|
|
|
|
if cmd == "transcribe":
|
|
from .transcribe import Transcriber
|
|
|
|
tx = Transcriber(cfg.model, cfg.device, cfg.compute_type, cfg.beam_size)
|
|
print(tx.transcribe(args.audio, language=cfg.language))
|
|
return 0
|
|
|
|
# cmd == "run"
|
|
from .daemon import Daemon
|
|
|
|
try:
|
|
Daemon(cfg).run()
|
|
except KeyboardInterrupt:
|
|
print("\n[blitztext] stopped.", file=sys.stderr)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|