fix: show the speech engine's reason when it refuses a transcription (#32186)

When an OpenAI-compatible speech-to-text engine or Deepgram rejected a recording, the error shown after dictating only gave the HTTP status, such as "429 Too Many Requests", and the engine's own reason, such as "Quota exceeded" or "Invalid credentials.", was lost. The error now shows that reason. When the engine sends no reason, the HTTP status is shown as before.

Fixes #32009
This commit is contained in:
Classic298 2026-10-10 18:00:51 +02:00 • committed by GitHub
parent 8fa22d0997
commit 6faf540310
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -941,6 +941,8 @@ async def _transcribe_openai(request, file_path, filename, languages, file_dir,
if r.status == 200:
break
# raise_for_status releases the response, so read the error body first
await r.read()
r.raise_for_status()
data = await r.json()
@ -955,6 +957,8 @@ async def _transcribe_openai(request, file_path, filename, languages, file_dir,
res = await r.json()
if 'error' in res:
detail = f'External: {res["error"].get("message", "")}'
else:
detail = f'External: {e}'
except Exception:
detail = f'External: {e}'
# LICENSE covers this Open WebUI error identifier.
@ -993,6 +997,7 @@ async def _transcribe_deepgram(request, file_path, languages, file_dir, id):
if r.status == 200:
break
await r.read()
r.raise_for_status()
body = await r.json()
@ -1021,9 +1026,11 @@ async def _transcribe_deepgram(request, file_path, languages, file_dir, id):
res.get('error', {}).get('message', '')
if isinstance(res.get('error'), dict)
else str(res.get('error', ''))
)
) or res.get('err_msg', '')
if msg:
detail = f'External: {msg}'
else:
detail = f'External: {e}'
except Exception:
detail = f'External: {e}'
raise Exception(detail)