Sanitize voice_id

This commit is contained in:
Craig Quiter 2024-08-16 15:10:53 -07:00
parent 4560f3b1ae
commit 442f50303a

View File

@ -254,6 +254,13 @@ async def speech(request: Request, user=Depends(get_verified_user)):
raise HTTPException(status_code=400, detail="Invalid JSON payload")
voice_id = payload.get("voice", "")
if voice_id not in get_available_voices():
raise HTTPException(
status_code=400,
detail="Invalid voice id",
)
url = f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}"
headers = {