Commit c8f70fe4 authored by Your Name's avatar Your Name

Fix: Skip faster-whisper for GGUF files

faster-whisper doesn't support GGUF format (it's llama.cpp format).
Now detects GGUF files by extension and goes directly to whispercpp.
parent 11a0fd46
...@@ -2383,7 +2383,15 @@ async def create_transcription( ...@@ -2383,7 +2383,15 @@ async def create_transcription(
tmp_path = tmp.name tmp_path = tmp.name
try: try:
# Try faster-whisper first (requires PyTorch), fall back to whispercpp if it fails # Check if model is a GGUF file - faster-whisper doesn't support GGUF format
is_gguf_model = model_to_use.endswith('.gguf') or 'gguf' in model_to_use.lower()
if is_gguf_model:
# Skip faster-whisper for GGUF files - go directly to whispercpp
print("Detected GGUF model - using whispercpp backend")
faster_whisper_failed = True
else:
# Try faster-whisper first
faster_whisper_failed = False faster_whisper_failed = False
try: try:
from faster_whisper import WhisperModel from faster_whisper import WhisperModel
...@@ -2483,7 +2491,7 @@ async def create_transcription( ...@@ -2483,7 +2491,7 @@ async def create_transcription(
# faster-whisper not available, will try whispercpp below # faster-whisper not available, will try whispercpp below
faster_whisper_failed = True faster_whisper_failed = True
except Exception as e: except Exception as e:
# faster-whisper failed for some other reason (e.g., GGUF file not supported) # faster-whisper failed for some other reason
print(f"Warning: faster-whisper failed to load model: {e}") print(f"Warning: faster-whisper failed to load model: {e}")
faster_whisper_failed = True faster_whisper_failed = True
...@@ -3755,7 +3763,18 @@ def main(): ...@@ -3755,7 +3763,18 @@ def main():
should_preload = load_mode in ("loadall", "loadswap") or (model_name is None and args.audio_model) should_preload = load_mode in ("loadall", "loadswap") or (model_name is None and args.audio_model)
if should_preload: if should_preload:
print(f"Pre-loading audio model...") print(f"Pre-loading audio model...")
# First try faster-whisper, then fall back to whispercpp if it fails
# Check if model is a GGUF file - faster-whisper doesn't support GGUF format
model_to_use = args.audio_model
is_gguf_model = model_to_use.endswith('.gguf') or 'gguf' in model_to_use.lower()
if is_gguf_model:
# Skip faster-whisper for GGUF files - it doesn't support them
# Go directly to whispercpp
print("Detected GGUF model - using whispercpp backend")
faster_whisper_failed = True
else:
# Try faster-whisper first
faster_whisper_failed = False faster_whisper_failed = False
try: try:
# Try faster-whisper first (requires torch) # Try faster-whisper first (requires torch)
...@@ -3802,6 +3821,8 @@ def main(): ...@@ -3802,6 +3821,8 @@ def main():
# If faster-whisper failed (not installed or couldn't load), try whispercpp # If faster-whisper failed (not installed or couldn't load), try whispercpp
if faster_whisper_failed: if faster_whisper_failed:
# Check if model is a GGUF file - whispercpp can handle those
model_is_gguf = model_to_use.endswith('.gguf') or (model_path and model_path.endswith('.gguf'))
try: try:
import whispercpp import whispercpp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment