File size: 584 Bytes
eca9834
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 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}