Skip to content

Commit 98e2924

Browse files
fix flaky transcribe tests (#12262)
1 parent 976046d commit 98e2924

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

localstack-core/localstack/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
# Artifacts endpoint
3434
ASSETS_ENDPOINT = "https://assets.localstack.cloud"
3535

36+
# Hugging Face endpoint for localstack
37+
HUGGING_FACE_ENDPOINT = "https://huggingface.co/localstack"
38+
3639
# host to bind to when starting the services
3740
BIND_HOST = "0.0.0.0"
3841

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
TranscriptionJobSummary,
3131
)
3232
from localstack.aws.connect import connect_to
33+
from localstack.constants import HUGGING_FACE_ENDPOINT
3334
from localstack.packages.ffmpeg import ffmpeg_package
3435
from localstack.services.s3.utils import (
3536
get_bucket_and_key_from_presign_url,
@@ -44,6 +45,8 @@
4445

4546
LOG = logging.getLogger(__name__)
4647

48+
VOSK_MODELS_URL = f"{HUGGING_FACE_ENDPOINT}/vosk-models/resolve/main/"
49+
4750
# Map of language codes to language models
4851
LANGUAGE_MODELS = {
4952
"en-IN": "vosk-model-small-en-in-0.4",
@@ -237,9 +240,15 @@ def download_model(name: str):
237240

238241
from vosk import MODEL_PRE_URL # noqa
239242

240-
download(
241-
MODEL_PRE_URL + str(model_path.name) + ".zip", model_zip_path, verify_ssl=False
242-
)
243+
download_urls = [MODEL_PRE_URL, VOSK_MODELS_URL]
244+
245+
for url in download_urls:
246+
try:
247+
download(url + str(model_path.name) + ".zip", model_zip_path, verify_ssl=False)
248+
except Exception as e:
249+
LOG.warning("Failed to download model from %s: %s", url, e)
250+
continue
251+
break
243252

244253
LOG.debug("Extracting language model: %s", model_path.name)
245254
with ZipFile(model_zip_path, "r") as model_ref:

tests/aws/services/transcribe/test_transcribe.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def is_transcription_done():
136136
"$..Error..Code",
137137
]
138138
)
139-
@pytest.mark.skip(reason="flaky")
140139
def test_transcribe_happy_path(self, transcribe_create_job, snapshot, aws_client):
141140
file_path = os.path.join(BASEDIR, "../../files/en-gb.wav")
142141
job_name = transcribe_create_job(audio_file=file_path)
@@ -181,7 +180,6 @@ def is_transcription_done():
181180
],
182181
)
183182
@markers.aws.needs_fixing
184-
@pytest.mark.skip(reason="flaky")
185183
def test_transcribe_supported_media_formats(
186184
self, transcribe_create_job, media_file, speech, aws_client
187185
):
@@ -322,7 +320,6 @@ def test_failing_start_transcription_job(self, s3_bucket, snapshot, aws_client):
322320
(None, None), # without output bucket and output key
323321
],
324322
)
325-
@pytest.mark.skip(reason="flaky")
326323
def test_transcribe_start_job(
327324
self,
328325
output_bucket,

0 commit comments

Comments
 (0)