Sanitize voice_id
This commit is contained in:
1 parent
4560f3b1ae
commit
442f50303a
1 file changed
+7
@@ -254,6 +254,13 @@ async def speech(request: Request, user=Depends(get_verified_user)):
|
|||||||
raise HTTPException(status_code=400, detail="Invalid JSON payload")
|
raise HTTPException(status_code=400, detail="Invalid JSON payload")
|
||||||
|
|
||||||
voice_id = payload.get("voice", "")
|
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}"
|
url = f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}"
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
|
|||||||
Reference in new issue
Block a user