mirror of
https://github.com/open-webui/open-webui
synced 2025-02-22 21:32:32 +00:00
Merge pull request #10408 from hangxingliu/liu/fix-proxy
fix: respect proxy and timeout settings in audio-related aiohttp requests
This commit is contained in:
commit
e1cc104805
@ -37,6 +37,7 @@ from open_webui.config import (
|
|||||||
|
|
||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
from open_webui.env import (
|
from open_webui.env import (
|
||||||
|
AIOHTTP_CLIENT_TIMEOUT,
|
||||||
ENV,
|
ENV,
|
||||||
SRC_LOG_LEVELS,
|
SRC_LOG_LEVELS,
|
||||||
DEVICE_TYPE,
|
DEVICE_TYPE,
|
||||||
@ -266,7 +267,8 @@ async def speech(request: Request, user=Depends(get_verified_user)):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# print(payload)
|
# print(payload)
|
||||||
async with aiohttp.ClientSession() as session:
|
timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT)
|
||||||
|
async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session:
|
||||||
async with session.post(
|
async with session.post(
|
||||||
url=f"{request.app.state.config.TTS_OPENAI_API_BASE_URL}/audio/speech",
|
url=f"{request.app.state.config.TTS_OPENAI_API_BASE_URL}/audio/speech",
|
||||||
json=payload,
|
json=payload,
|
||||||
@ -323,7 +325,8 @@ async def speech(request: Request, user=Depends(get_verified_user)):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with aiohttp.ClientSession() as session:
|
timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT)
|
||||||
|
async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session:
|
||||||
async with session.post(
|
async with session.post(
|
||||||
f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}",
|
f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}",
|
||||||
json={
|
json={
|
||||||
@ -380,7 +383,8 @@ async def speech(request: Request, user=Depends(get_verified_user)):
|
|||||||
data = f"""<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="{locale}">
|
data = f"""<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="{locale}">
|
||||||
<voice name="{language}">{payload["input"]}</voice>
|
<voice name="{language}">{payload["input"]}</voice>
|
||||||
</speak>"""
|
</speak>"""
|
||||||
async with aiohttp.ClientSession() as session:
|
timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT)
|
||||||
|
async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session:
|
||||||
async with session.post(
|
async with session.post(
|
||||||
f"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1",
|
f"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1",
|
||||||
headers={
|
headers={
|
||||||
|
Loading…
Reference in New Issue
Block a user