malek-messaoudii
Add groq apis
2da4544
raw
history blame
550 Bytes
from fastapi import APIRouter, UploadFile, File
from services.stt_service import speech_to_text
from models.stt import STTResponse
import os
import uuid
router = APIRouter(prefix="/stt", tags=["Speech To Text"])
@router.post("/", response_model=STTResponse)
async def convert_stt(file: UploadFile = File(...)):
temp_name = f"audio/temp/{uuid.uuid4()}_{file.filename}"
with open(temp_name, "wb") as f:
f.write(await file.read())
text = speech_to_text(temp_name)
os.remove(temp_name)
return STTResponse(text=text)