Update TextGen/router.py
Browse files- TextGen/router.py +6 -1
TextGen/router.py
CHANGED
@@ -208,7 +208,7 @@ def determine_elevenLav_voice_from_npc(npc, genre):
|
|
208 |
else:
|
209 |
return "TX3LPaxmHKxFdv7VOQHJ"
|
210 |
|
211 |
-
@app.post("/generate_wav"
|
212 |
async def generate_wav(message: VoiceMessage):
|
213 |
try:
|
214 |
voice = determine_vocie_from_npc(message.npc, message.genre)
|
@@ -234,6 +234,11 @@ async def generate_wav(message: VoiceMessage):
|
|
234 |
# Return the generated audio as a streaming response
|
235 |
return StreamingResponse(audio_stream(), media_type="audio/wav")
|
236 |
|
|
|
|
|
|
|
|
|
|
|
237 |
except Exception as e:
|
238 |
raise HTTPException(status_code=500, detail=str(e))
|
239 |
|
|
|
208 |
else:
|
209 |
return "TX3LPaxmHKxFdv7VOQHJ"
|
210 |
|
211 |
+
@app.post("/generate_wav")
|
212 |
async def generate_wav(message: VoiceMessage):
|
213 |
try:
|
214 |
voice = determine_vocie_from_npc(message.npc, message.genre)
|
|
|
234 |
# Return the generated audio as a streaming response
|
235 |
return StreamingResponse(audio_stream(), media_type="audio/wav")
|
236 |
|
237 |
+
except httpx.HTTPStatusError as e:
|
238 |
+
if e.response.status_code == 403:
|
239 |
+
raise HTTPException(status_code=403, detail="Access to the file is forbidden. Please check the file permissions and try again.")
|
240 |
+
else:
|
241 |
+
raise HTTPException(status_code=500, detail=str(e))
|
242 |
except Exception as e:
|
243 |
raise HTTPException(status_code=500, detail=str(e))
|
244 |
|