Skip to content

Commit

Permalink
Merge pull request #4117 from grossir/audio_transcribe_handle_bad_req…
Browse files Browse the repository at this point in the history
…uest

fix(audio.transcribe): mark failed when BadRequestError is raised
  • Loading branch information
grossir authored Jun 14, 2024
2 parents 6244d0f + 5f7b0b7 commit 8ec601e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cl/audio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.utils.text import slugify
from openai import (
APIConnectionError,
BadRequestError,
ConflictError,
InternalServerError,
OpenAI,
Expand Down Expand Up @@ -102,10 +103,12 @@ def transcribe_from_open_ai_api(self, audio_pk: int):
timestamp_granularities=["word", "segment"],
prompt=audio.case_name,
)
except UnprocessableEntityError:
except (UnprocessableEntityError, BadRequestError) as e:
# BadRequestError is an HTTP 400 and has this message:
# 'The audio file could not be decoded or its format is not supported'
audio.stt_status = Audio.STT_FAILED
audio.save()
logger.warning("UnprocessableEntityError for audio %s", audio_pk)
capture_exception(e)
return
except Exception as e:
# Sends to Sentry errors that we don't expect or
Expand Down

0 comments on commit 8ec601e

Please sign in to comment.