Loginauth / routes /tts.py
Gregniuki's picture
Rename tts/tts.py to routes/tts.py
339ea6e
raw
history blame
584 Bytes
# app/routes/tts.py
from fastapi import APIRouter, Depends
from app.auth import UserInResponse # Import a model for the user response
from app.tts import tts_synthesis # Import your TTS synthesis function
from app.main import get_current_user
router = APIRouter()
@router.get("/synthesize", response_model=UserInResponse)
def synthesize_text(text: str, current_user: str = Depends(get_current_user)):
# Use the get_current_user dependency to ensure authentication
audio_data = tts_synthesis(text, current_user)
return {"user": current_user, "audio_data": audio_data}