From 8a104a7ab1cbdca5b698de3b2f73a18e94da7125 Mon Sep 17 00:00:00 2001 From: Dara Adib Date: Tue, 19 May 2026 16:25:34 -0400 Subject: [PATCH] Run transcode_audio_to_mp3 in a thread to avoid blocking (#24876) This incorporates the transcoding implementation in #24145. --- backend/open_webui/routers/audio.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/routers/audio.py b/backend/open_webui/routers/audio.py index 51373caf3b..8e10e16762 100644 --- a/backend/open_webui/routers/audio.py +++ b/backend/open_webui/routers/audio.py @@ -438,7 +438,9 @@ async def speech(request: Request, user=Depends(get_verified_user)): audio_data = await r.read() content_type_header = r.headers.get('Content-Type', 'audio/mpeg') - if not transcode_audio_to_mp3(audio_data, content_type_header, file_path): + if not await asyncio.to_thread( + transcode_audio_to_mp3, audio_data, content_type_header, file_path + ): async with aiofiles.open(file_path, 'wb') as f: await f.write(audio_data)