Skip to content

Commit fcda700

Browse files
committed
Make Python Whisper optional for whisper-cli compatibility
- Add optional imports for torch/whisper/tqdm in engine.py - Show helpful error message when Python Whisper not available - Prepare framework for both whisper-cli and Python Whisper usage - Update CLI to handle missing dependencies gracefully
1 parent c78dc50 commit fcda700

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/transcriber/engine.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
from pathlib import Path
66
from typing import Any, Dict, List, Optional
77

8-
import torch
9-
import whisper
10-
from tqdm import tqdm
8+
try:
9+
import torch
10+
import whisper
11+
from tqdm import tqdm
12+
WHISPER_AVAILABLE = True
13+
except ImportError:
14+
# Fallback when Python Whisper is not installed (using whisper-cli)
15+
WHISPER_AVAILABLE = False
1116

1217

1318
class TranscriptionEngine:
@@ -26,6 +31,13 @@ def __init__(
2631
device: Device to run on (cpu, cuda)
2732
verbose: Enable verbose output
2833
"""
34+
if not WHISPER_AVAILABLE:
35+
raise ImportError(
36+
"Python Whisper is not installed. "
37+
"This project uses whisper-cli for transcription. "
38+
"Install whisper-cli from: https://github.com/ggerganov/whisper.cpp"
39+
)
40+
2941
self.model_name = model
3042
self.device = device
3143
self.verbose = verbose

0 commit comments

Comments
 (0)