mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-08 03:08:02 +00:00
Run transcode_audio_to_mp3 in a thread to avoid blocking (#24876)
This incorporates the transcoding implementation in #24145.
This commit is contained in:
parent
2b99945d27
commit
8a104a7ab1
1 changed files with 3 additions and 1 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue