Skip to content

Commit e1cc104

Browse files
authored
Merge pull request open-webui#10408 from hangxingliu/liu/fix-proxy
fix: respect proxy and timeout settings in audio-related aiohttp requests
2 parents 13e58c1 + 90d9cda commit e1cc104

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

backend/open_webui/routers/audio.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
from open_webui.constants import ERROR_MESSAGES
3939
from open_webui.env import (
40+
AIOHTTP_CLIENT_TIMEOUT,
4041
ENV,
4142
SRC_LOG_LEVELS,
4243
DEVICE_TYPE,
@@ -266,7 +267,8 @@ async def speech(request: Request, user=Depends(get_verified_user)):
266267

267268
try:
268269
# 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:
270272
async with session.post(
271273
url=f"{request.app.state.config.TTS_OPENAI_API_BASE_URL}/audio/speech",
272274
json=payload,
@@ -323,7 +325,8 @@ async def speech(request: Request, user=Depends(get_verified_user)):
323325
)
324326

325327
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:
327330
async with session.post(
328331
f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}",
329332
json={
@@ -380,7 +383,8 @@ async def speech(request: Request, user=Depends(get_verified_user)):
380383
data = f"""<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="{locale}">
381384
<voice name="{language}">{payload["input"]}</voice>
382385
</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:
384388
async with session.post(
385389
f"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1",
386390
headers={

0 commit comments

Comments
 (0)