Open-source alternative to Opus Clip, Vidyo.ai, Klap & SubMagic. Turn long-form YouTube videos into viral 9:16 shorts using LLM highlight detection, Whisper transcription, and auto vertical cropping — free, no watermarks, no per-clip credits.
Python 2short-ai-alternativeai-clip-generatorai-clippingauto-clipauto-crophighlight-detectionklap-alternativellmopen-sourceopus-clip-alternativereelsshorts-makersubmagic-alternativetiktokvertical-videovideo-editingvidyo-ai-alternativeviral-clipswhisperyoutube-shorts
fix(local): disable VAD by default, fix CUDA fallback, invalidate empty cache
LathissKhumar1e06eedc8c6c
diff --git a/shorts_generator/config.py b/shorts_generator/config.pyindex 3ac68d8..8b695bc 100644--- a/shorts_generator/config.py+++ b/shorts_generator/config.py@@ -20,6 +20,26 @@ LOCAL_WHISPER_MODEL = os.getenv("LOCAL_WHISPER_MODEL", "base")LOCAL_WHISPER_DEVICE = os.getenv("LOCAL_WHISPER_DEVICE", "auto") # auto / cpu / cudaLOCAL_OUTPUT_DIR = os.getenv("LOCAL_OUTPUT_DIR", "output")+# VAD (Voice Activity Detection) settings for faster-whisper+# Default threshold is 0.5; lower = more sensitive, higher = less sensitive+# Default min_speech_duration_ms is 250ms; increase to avoid tiny false positives+# Default min_silence_duration_ms is 2000ms; increase to avoid splitting mid-sentence+# DISABLED by default because VAD is too aggressive on mixed speech/music content+LOCAL_WHISPER_VAD_FILTER = os.getenv("LOCAL_WHISPER_VAD_FILTER", "false").strip().lower() == "true"+_vad_params_env = os.getenv("LOCAL_WHISPER_VAD_PARAMETERS", "")+if _vad_params_env:+ import json+ LOCAL_WHISPER_VAD_PARAMETERS = json.loads(_vad_params_env)+else:+ # Match faster-whisper defaults when VAD is enabled+ LOCAL_WHISPER_VAD_PARAMETERS = {+ "threshold": 0.5,+ "min_speech_duration_ms": 250,+ "max_speech_duration_s": float("inf"),+ "min_silence_duration_ms": 2000,+ "speech_pad_ms": 400,+ }+def require_api_key() -> str:if not MUAPI_API_KEY:diff --git a/shorts_generator/local/transcriber.py b/shorts_generator/local/transcriber.pyindex c167037..1811e3b 100644--- a/shorts_generator/local/transcriber.py+++ b/shorts_generator/local/transcriber.py@@ -86,9 +86,13 @@ def _resolve_device() -> str:return LOCAL_WHISPER_DEVICEtry:import torch # type: ignore- return "cuda" if torch.cuda.is_available() else "cpu"- except ImportError:- return "cpu"+ if torch.cuda.is_available():+ # Test that CUDA actually works (catches missing cuBLAS/cuDNN libs)+ torch.zeros(1, device="cuda")+ return "cuda"+ except (ImportError, OSError, RuntimeError):+ pass+ return "cpu"def transcribe_local(media_path: str, language: Optional[str] = None) -> Dict:@@ -100,12 +104,17 @@ def transcribe_local(media_path: str, language: Optional[str] = None) -> Dict:if cache_mtime >= source_mtime:print(f"[transcribe/local] reusing cached transcript: {cache_path}", flush=True)cached = _load_srt_cache(cache_path)- print(- f"[transcribe/local] {len(cached['segments'])} cached segments, "- f"{cached['duration']:.0f}s of audio",- flush=True,- )- return cached+ # Treat empty cache as invalid (likely from a failed/partial run) — delete and re-transcribe+ if not cached["segments"] or cached["duration"] <= 0.0:+ print(f"[transcribe/local] cache is empty/invalid, deleting: {cache_path}", flush=True)+ cache_path.unlink(missing_ok=True)+ else:+ print(+ f"[transcribe/local] {len(cached['segments'])} cached segments, "+ f"{cached['duration']:.0f}s of audio",+ flush=True,+ )+ return cachedtry:from faster_whisper import WhisperModel # type: ignore@@ -119,14 +128,23 @@ def transcribe_local(media_path: str, language: Optional[str] = None) -> Dict:compute_type = "float16" if device == "cuda" else "int8"print(f"[transcribe/local] faster-whisper model={LOCAL_WHISPER_MODEL} device={device}", flush=True)+ from ..config import LOCAL_WHISPER_VAD_FILTER, LOCAL_WHISPER_VAD_PARAMETERS+model = WhisperModel(LOCAL_WHISPER_MODEL, device=device, compute_type=compute_type)- segments_iter, info = model.transcribe(- media_path,- language=language,- beam_size=5,- vad_filter=True,- condition_on_previous_text=False,- )++ transcribe_kwargs = {+ "audio": media_path,+ "language": language,+ "beam_size": 5,+ "condition_on_previous_text": False,+ }+ if LOCAL_WHISPER_VAD_FILTER:+ transcribe_kwargs["vad_filter"] = True+ transcribe_kwargs["vad_parameters"] = LOCAL_WHISPER_VAD_PARAMETERS+ else:+ transcribe_kwargs["vad_filter"] = False++ segments_iter, info = model.transcribe(**transcribe_kwargs)segments = []for s in segments_iter: