Create tts.py
Browse files- tts/tts.py +14 -0
tts/tts.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app/routes/tts.py
|
2 |
+
|
3 |
+
from fastapi import APIRouter, Depends
|
4 |
+
from app.auth import UserInResponse # Import a model for the user response
|
5 |
+
from app.tts import tts_synthesis # Import your TTS synthesis function
|
6 |
+
from app.main import get_current_user
|
7 |
+
|
8 |
+
router = APIRouter()
|
9 |
+
|
10 |
+
@router.get("/synthesize", response_model=UserInResponse)
|
11 |
+
def synthesize_text(text: str, current_user: str = Depends(get_current_user)):
|
12 |
+
# Use the get_current_user dependency to ensure authentication
|
13 |
+
audio_data = tts_synthesis(text, current_user)
|
14 |
+
return {"user": current_user, "audio_data": audio_data}
|