refactor: integrate local STT with existing upload flow

- Simplify STT_SERVICE config to local/MODEL_SIZE format
- Remove separate STT routes, integrate with document upload
- Add local STT support to audio file processing pipeline
- Remove React component, use existing upload interface
- Support both local Faster-Whisper and external STT services
- Tested with real speech: 99% accuracy, 2.87s processing
This commit is contained in:
Nabhan 2025-10-12 10:50:55 +05:00
parent bd6b198e20
commit cf0e265107
7 changed files with 47 additions and 238 deletions

View file

@ -12,13 +12,14 @@ from app.config import config
class STTService:
"""Local Speech-to-Text service using Faster-Whisper."""
def __init__(self, model_size: Optional[str] = None):
"""Initialize STT service with specified model size.
Args:
model_size: Whisper model size ("tiny", "base", "small", "medium", "large-v3")
"""
self.model_size = model_size or config.LOCAL_STT_MODEL
def __init__(self):
"""Initialize STT service with model from STT_SERVICE config."""
# Parse model from STT_SERVICE (e.g., "local/base" or "local/tiny")
stt_service = config.STT_SERVICE or "local/base"
if stt_service.startswith("local/"):
self.model_size = stt_service.split("/", 1)[1]
else:
self.model_size = "base" # fallback
self._model: Optional[WhisperModel] = None
def _get_model(self) -> WhisperModel: