Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit eddcdb9

Browse files
committed
Adding fix for validating audit length
1 parent 90ccf60 commit eddcdb9

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • localstack-core/localstack/services/transcribe

localstack-core/localstack/services/transcribe/provider.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
from localstack.utils.run import run
4545
from localstack.utils.threads import start_thread
4646

47+
MAX_AUDIO_DURATION_SECONDS = 60 * 60 * 4
48+
4749
LOG = logging.getLogger(__name__)
4850

4951
VOSK_MODELS_URL = f"{HUGGING_FACE_ENDPOINT}/vosk-models/resolve/main/"
@@ -305,6 +307,13 @@ def _run_transcription_job(self, args: Tuple[TranscribeStore, str]):
305307
LOG.debug("Media format detected as: %s", format)
306308
job["MediaFormat"] = SUPPORTED_FORMAT_NAMES[format]
307309

310+
duration = ffprobe_output["format"]["duration"]
311+
LOG.debug("Media duration: %s (seconds)", duration)
312+
313+
if float(duration) >= MAX_AUDIO_DURATION_SECONDS:
314+
failure_reason = "Invalid file size: file size too large. Maximum audio duration is 4.000000 hours. Check the length of the file and try your request again"
315+
raise RuntimeError()
316+
308317
# Determine the sample rate of input audio if possible
309318
for stream in ffprobe_output["streams"]:
310319
if stream["codec_type"] == "audio":

0 commit comments

Comments
 (0)