diff --git a/transcribe.py b/transcribe.py index feee197..96198dd 100644 --- a/transcribe.py +++ b/transcribe.py @@ -279,6 +279,9 @@ def post_correct_with_local_llm(text, args, llm_state, context_hint=""): if not args.post_correct_llm or not llm_state.get("available", True): return text + if args.post_correct_debug: + print(f"[POST-LLM][PRE]: {text}") + prompt = ( "You correct live English captions.\n" "Rules:\n" @@ -306,13 +309,21 @@ def post_correct_with_local_llm(text, args, llm_state, context_hint=""): response.raise_for_status() raw = response.json().get("response", "").strip() cleaned = normalize_english_caption(raw) + if args.post_correct_debug: + print(f"[POST-LLM][RAW]: {raw}") if cleaned: + if args.post_correct_debug: + print(f"[POST-LLM][POST]: {cleaned}") return cleaned + if args.post_correct_debug: + print("[POST-LLM][POST]: ") except Exception as exc: if not llm_state.get("warned", False): print(f"\n[SYSTEM]: Local post-correct LLM unavailable ({exc}). Falling back to rules-only.") llm_state["warned"] = True llm_state["available"] = False + if args.post_correct_debug: + print(f"[POST-LLM][ERROR]: {exc}") return text def maybe_merge_recent_caption(recent_en_lines, current_text, now_ts, window_sec): @@ -522,9 +533,10 @@ def main(): parser.add_argument("--post-correct-llm", action="store_true", help="Use local LLM for post-correction (fallback to rules on failure)") parser.add_argument("--post-correct-model", type=str, default="llama3.1:8b-instruct", help="Local Ollama model for post-correction") parser.add_argument("--post-correct-ollama-url", type=str, default="http://127.0.0.1:11434/api/generate", help="Ollama generate endpoint for local post-correction") - parser.add_argument("--post-correct-llm-timeout", type=float, default=3.0, help="Timeout seconds for local LLM post-correction (default: 3.0)") + parser.add_argument("--post-correct-llm-timeout", type=float, default=8.0, help="Timeout seconds for local LLM post-correction (default: 8.0)") + parser.add_argument("--post-correct-debug", action="store_true", help="Print pre/post LLM correction text for debugging") parser.add_argument("--llm-merge-decider", action="store_true", help="Use local LLM to validate/refine smart-correct line merges") - parser.add_argument("--llm-merge-timeout", type=float, default=0.7, help="Timeout seconds for LLM merge decision (default: 0.7)") + parser.add_argument("--llm-merge-timeout", type=float, default=1.5, help="Timeout seconds for LLM merge decision (default: 1.5)") parser.add_argument("--speaker-change-detect", action="store_true", help="Enable lightweight speaker-change detection to force caption line cuts") parser.add_argument("--speaker-sim-threshold", type=float, default=0.72, help="Cosine similarity threshold below which a speaker change is assumed (default: 0.72)") parser.add_argument("--speaker-min-buffer", type=float, default=1.6, help="Minimum buffered speech seconds before speaker-change checks (default: 1.6)") @@ -542,6 +554,8 @@ def main(): print("Post-correct mode: rules enabled.") if args.post_correct_llm: print(f"Post-correct LLM: {args.post_correct_model} via {args.post_correct_ollama_url}") + if args.post_correct_debug: + print("Post-correct debug logging enabled.") if args.llm_merge_decider and not args.post_correct_llm: print("[SYSTEM]: --llm-merge-decider requires --post-correct-llm. Falling back to heuristic merge.") args.llm_merge_decider = False