|
from fastapi import HTTPException |
|
from services.whisper_service import WhisperService |
|
from models.schema import TranscriptionResponse |
|
|
|
|
|
class TranscriptionController: |
|
def __init__(self): |
|
self.whisper_service = WhisperService() |
|
|
|
async def transcribe_audio(self, audio_file: bytes, output_language: str = None) -> TranscriptionResponse: |
|
try: |
|
result = await self.whisper_service.transcribe(audio_file, output_language) |
|
return TranscriptionResponse(**result) |
|
except Exception as e: |
|
raise HTTPException(status_code=500, detail=str(e)) |