From eec14f1c00401b84ff461653dae975aef7240166 Mon Sep 17 00:00:00 2001 From: DrMelone <27028174+Classic298@users.noreply.github.com> Date: Sun, 3 May 2026 20:08:19 +0200 Subject: [PATCH] fix: prevent STT from blocking the uvicorn event loop The transcription endpoint was async but called the synchronous transcribe() function directly, blocking the single-threaded uvicorn event loop for the entire duration of inference. This caused all HTTP and WebSocket connections to stall for every user on the instance during STT processing. - Add asyncio import - Use async UploadFile.read() instead of synchronous file.file.read() - Offload the blocking transcribe() call via asyncio.to_thread() Closes #24169 --- backend/open_webui/routers/audio.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/routers/audio.py b/backend/open_webui/routers/audio.py index c69be124e5..3758ea29b5 100644 --- a/backend/open_webui/routers/audio.py +++ b/backend/open_webui/routers/audio.py @@ -1,3 +1,4 @@ +import asyncio import hashlib import json import logging @@ -1247,7 +1248,7 @@ async def transcription( id = uuid.uuid4() filename = f'{id}.{ext}' - contents = file.file.read() + contents = await file.read() file_dir = os.path.join(CACHE_DIR, 'audio', 'transcriptions') os.makedirs(file_dir, exist_ok=True) @@ -1266,7 +1267,7 @@ async def transcription( if language: metadata = {'language': language} - result = transcribe(request, file_path, metadata, user) + result = await asyncio.to_thread(transcribe, request, file_path, metadata, user) return { **result,