Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4022-split-off-recap-docs-2024-0…
Browse files Browse the repository at this point in the history
…5-03' into 4022-split-off-recap-docs-2024-05-03
  • Loading branch information
mlissner committed Jun 14, 2024
2 parents e1369c9 + f9b0a8d commit 5c6d3ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion cl/audio/management/commands/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def handle_open_ai_transcriptions(options) -> None:
continue

valid_count += 1
transcribe_from_open_ai_api.delay(audio.pk)
transcribe_from_open_ai_api.apply_async(
args=(audio.pk,), queue=options["queue"]
)

# For parallel processing: seed RPM requests per minute
# if requests_per_minute == 0, do not sleep
Expand Down Expand Up @@ -118,6 +120,11 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
help="""Max number of audio files to get from the database
for processing. '--limit 0' means there is no limit. Default: 0""",
)
parser.add_argument(
"--queue",
default="batch1",
help="The celery queue where the tasks should be processed.",
)

def handle(self, *args: list[str], **options: OptionsType) -> None:
super().handle(*args, **options)
Expand Down
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 5c6d3ac

Please sign in to comment.