Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: probe STT Transformers availability off the event loop (#16783)

Daniel Hand44fd45ac711
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index 557efeddbd5..4b2ec45c578 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -25500,6 +25500,8 @@ async def stt_status(
audiocpp_downloaded = await asyncio.to_thread(stt_audiocpp_sidecar.downloaded_model_ids)
# Choosing the launch backend can run the binary's --version.
audio_cpp_runtime = await asyncio.to_thread(_audio_cpp_runtime_status)
+ # The first probe imports torch, Transformers and PyAV (seconds); keep it off the event loop.
+ transformers_available = await asyncio.to_thread(is_available)
transformers_downloaded = [
model_id for model_id in STT_MODELS if stt_sidecar.is_model_downloaded(model_id)
]
@@ -25507,7 +25509,7 @@ async def stt_status(
transformers_downloaded.append(model)
response = JSONResponse(
content = {
- "available": is_available(),
+ "available": transformers_available,
"loaded_model": sidecar.loaded_model,
"loading": sidecar.is_loading(),
"device": sidecar.device,
@@ -25516,7 +25518,7 @@ async def stt_status(
"models": list(STT_MODELS.keys()),
# Transformers block mirrors the gguf shape so clients read either generically; top-level fields above are kept for old clients.
"transformers": {
- "available": is_available(),
+ "available": transformers_available,
"loaded_model": sidecar.loaded_model,
"loading": sidecar.is_loading(),
"device": sidecar.device,
diff --git a/studio/backend/tests/test_audio_cpp_runtime_status.py b/studio/backend/tests/test_audio_cpp_runtime_status.py
index 81b60cf1842..5f7c98c7f54 100644
--- a/studio/backend/tests/test_audio_cpp_runtime_status.py
+++ b/studio/backend/tests/test_audio_cpp_runtime_status.py
@@ -377,3 +377,23 @@ def test_stt_status_reads_the_runtime_off_the_event_loop(monkeypatch):
response = asyncio.run(inference.stt_status(model = None, current_subject = "owner"))
assert json.loads(response.body)["audio_cpp_runtime"] == {"available": False}
assert seen == [False]
+
+
+def test_stt_status_probes_transformers_off_the_event_loop(monkeypatch):
+ import threading
+
+ from core.inference import stt_sidecar
+
+ seen = []
+
+ def available():
+ seen.append(threading.current_thread() is threading.main_thread())
+ return True
+
+ monkeypatch.setattr(stt_sidecar, "is_available", available)
+ monkeypatch.setattr(inference, "_audio_cpp_runtime_status", lambda: {"available": False})
+ monkeypatch.setattr(inference.account_access, "managed_account", lambda: False)
+ response = asyncio.run(inference.stt_status(model = None, current_subject = "owner"))
+ body = json.loads(response.body)
+ assert body["available"] is True and body["transformers"]["available"] is True
+ assert seen == [False]