|
37 | 37 |
|
38 | 38 | from open_webui.constants import ERROR_MESSAGES |
39 | 39 | from open_webui.env import ( |
| 40 | + AIOHTTP_CLIENT_TIMEOUT, |
40 | 41 | ENV, |
41 | 42 | SRC_LOG_LEVELS, |
42 | 43 | DEVICE_TYPE, |
@@ -266,7 +267,8 @@ async def speech(request: Request, user=Depends(get_verified_user)): |
266 | 267 |
|
267 | 268 | try: |
268 | 269 | # print(payload) |
269 | | - async with aiohttp.ClientSession() as session: |
| 270 | + timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT) |
| 271 | + async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session: |
270 | 272 | async with session.post( |
271 | 273 | url=f"{request.app.state.config.TTS_OPENAI_API_BASE_URL}/audio/speech", |
272 | 274 | json=payload, |
@@ -323,7 +325,8 @@ async def speech(request: Request, user=Depends(get_verified_user)): |
323 | 325 | ) |
324 | 326 |
|
325 | 327 | try: |
326 | | - async with aiohttp.ClientSession() as session: |
| 328 | + timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT) |
| 329 | + async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session: |
327 | 330 | async with session.post( |
328 | 331 | f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}", |
329 | 332 | json={ |
@@ -380,7 +383,8 @@ async def speech(request: Request, user=Depends(get_verified_user)): |
380 | 383 | data = f"""<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="{locale}"> |
381 | 384 | <voice name="{language}">{payload["input"]}</voice> |
382 | 385 | </speak>""" |
383 | | - async with aiohttp.ClientSession() as session: |
| 386 | + timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT) |
| 387 | + async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session: |
384 | 388 | async with session.post( |
385 | 389 | f"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1", |
386 | 390 | headers={ |
|
0 commit comments