whisper_transcription_api / controllers /transcription_controller.py
Omkar008's picture
adding the code files
9f559c6 verified
raw
history blame
597 Bytes
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))