File size: 597 Bytes
9f559c6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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)) |