openspeechapi 0.2.22__tar.gz → 0.2.23__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/PKG-INFO +1 -1
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/config.py +25 -3
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/core/model_hub.py +13 -6
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/canary_qwen_stt.py +21 -3
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/faster_whisper.py +40 -2
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/fireredasr_stt.py +32 -3
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/mms_stt.py +22 -4
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/moonshine_stt.py +27 -8
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/phi4_multimodal_stt.py +22 -4
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/qwen3_omni_stt.py +54 -4
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/vosk_stt.py +80 -5
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/whisper.py +84 -2
- openspeechapi-0.2.23/openspeechapi/server/model_downloads.py +396 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/routes/management.py +80 -6
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/webui/app.js +156 -22
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/webui/styles.css +13 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/ws/stt_stream.py +25 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/pyproject.toml +1 -1
- openspeechapi-0.2.22/openspeechapi/server/model_downloads.py +0 -191
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/.gitignore +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/README.md +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/__main__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/cli.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/client/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/client/client.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/core/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/core/base.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/core/enums.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/core/models.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/core/registry.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/core/settings.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/demo.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/aim_provision.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/context.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/dispatcher.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/executors/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/executors/base.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/executors/in_process.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/executors/remote.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/executors/subprocess_exec.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/fanout.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/filters.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/lifecycle.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/dispatch/watcher.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/engine_catalog.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/engine_registry.yaml +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/exceptions.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/factory.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/aim_resolver.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/backends/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/backends/docker_backend.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/backends/native_backend.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/base.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/engines/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/engines/faster_whisper.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/engines/fish_speech.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/engines/sherpa_onnx.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/engines/whisper.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/engines/whisperlivekit.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/isolated_venv.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/manager.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/models.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/progress.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/registry.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/task_store.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/local_engines/tasks.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/logging_config.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/observe/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/observe/base.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/observe/debug.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/observe/latency.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/observe/metrics.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/observe/tracing.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/observe/usage.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/_template.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/_local_audio.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/alibaba.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/assemblyai.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/azure_speech.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/baidu.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/deepgram.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/dolphin_stt.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/elevenlabs.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/funasr_stt.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/gemma4.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/google_cloud.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/iflytek.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/kimi_audio_stt.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/macos_speech.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/mlx_whisper_stt.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/mms_languages.json +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/openai.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/paraformer.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/parakeet_mlx_stt.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/qwen3_asr.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/sensevoice.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/sherpa_onnx.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/tencent.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/volcengine.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/voxtral_stt.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/wenet_stt.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/whisperlivekit.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/windows_speech.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/alibaba.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/azure_speech.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/baidu.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/coqui.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/cosyvoice.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/deepgram.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/elevenlabs.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/fish_speech.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/google_cloud.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/iflytek.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/macos_say.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/minimax.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/openai.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/piper.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/tencent.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/volcengine.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/tts/windows_sapi.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/app.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/auth.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/extras_installer.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/middleware.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/native_installer.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/routes/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/routes/stt.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/routes/tts.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/routes/webui.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/system_metrics.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/webui/index.html +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/ws/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/server/ws/tts_stream.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/telemetry/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/telemetry/perf.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/utils/__init__.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/utils/audio_converter.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/utils/audio_playback.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/vendor_registry.yaml +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/providers.example.yaml +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/aim_adopt.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/aim_consumers.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/engines/cloud/install.sh +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/engines/faster-whisper/native/install.sh +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/engines/fish-speech/native/install.sh +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/engines/macos-stt/_bundle.sh +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/engines/macos-stt/install.sh +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/engines/macos-stt/macos_stt.swift +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/engines/macos-stt/request_auth.swift +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/engines/sherpa-onnx/native/install.sh +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/engines/sherpa-onnx/native/run_streaming_server.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/engines/whisper/native/install.sh +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/engines/whisperlivekit/native/install.sh +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/gen_mms_languages.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/preload_stt_model.py +0 -0
- {openspeechapi-0.2.22 → openspeechapi-0.2.23}/scripts/release.sh +0 -0
|
@@ -120,6 +120,14 @@ class ServerConfig:
|
|
|
120
120
|
# multi-engine / memory-constrained boxes so idle engines free their GPU/RAM after N seconds
|
|
121
121
|
# of inactivity (auto-reloaded on next request). A per-engine ``keepalive > 0`` overrides this.
|
|
122
122
|
default_keepalive: int = 0
|
|
123
|
+
# Keepalive FLOOR (seconds) for reload-expensive LOCAL engines (subprocess/local model
|
|
124
|
+
# loaders, e.g. gemma4 / qwen3-omni). A short ``default_keepalive`` (e.g. 600) idle-unloads a
|
|
125
|
+
# multi-GB model between interactive requests; the cold reload (tens of seconds to minutes,
|
|
126
|
+
# worse under concurrent disk I/O) then reads as "no result" in live mic. This floors the
|
|
127
|
+
# INHERITED keepalive for such engines so interactive use stays warm, while cloud/native
|
|
128
|
+
# engines (cheap to reconnect) keep the shorter default. Only raises an inherited value — an
|
|
129
|
+
# explicit per-engine ``keepalive`` (incl. 0 = never unload) is respected. 0 disables.
|
|
130
|
+
keepalive_floor_local: int = 1800
|
|
123
131
|
|
|
124
132
|
|
|
125
133
|
@dataclass
|
|
@@ -272,17 +280,31 @@ def load_config(path: Path) -> OpenSpeechConfig:
|
|
|
272
280
|
0, int(srv.get("default_keepalive", server_cfg.default_keepalive)))
|
|
273
281
|
except (TypeError, ValueError):
|
|
274
282
|
pass
|
|
283
|
+
try:
|
|
284
|
+
server_cfg.keepalive_floor_local = max(
|
|
285
|
+
0, int(srv.get("keepalive_floor_local", server_cfg.keepalive_floor_local)))
|
|
286
|
+
except (TypeError, ValueError):
|
|
287
|
+
pass
|
|
275
288
|
auth = srv.get("auth", {})
|
|
276
289
|
if auth:
|
|
277
290
|
server_cfg.auth_enabled = bool(auth.get("enabled", False))
|
|
278
291
|
server_cfg.api_keys = list(auth.get("api_keys", []))
|
|
279
292
|
|
|
280
293
|
# Engines that didn't set their own keepalive inherit the global default (so operators can
|
|
281
|
-
# set one idle-unload policy via server.default_keepalive instead of per-engine).
|
|
294
|
+
# set one idle-unload policy via server.default_keepalive instead of per-engine). Reload-
|
|
295
|
+
# expensive LOCAL loaders (subprocess/local) additionally get a keepalive FLOOR so a short
|
|
296
|
+
# global default doesn't idle-unload a multi-GB model between interactive requests (the cold
|
|
297
|
+
# reload reads as "no result" in live mic). Only an INHERITED value (keepalive == 0) is
|
|
298
|
+
# adjusted — an explicit per-engine keepalive is respected as-is.
|
|
299
|
+
_LOCAL_LOADERS = {"subprocess", "local"}
|
|
282
300
|
if server_cfg.default_keepalive > 0:
|
|
283
301
|
for eng in engines.values():
|
|
284
|
-
if eng.keepalive
|
|
285
|
-
|
|
302
|
+
if eng.keepalive != 0:
|
|
303
|
+
continue
|
|
304
|
+
eng.keepalive = server_cfg.default_keepalive
|
|
305
|
+
if (server_cfg.keepalive_floor_local > 0
|
|
306
|
+
and str(eng.exec_mode).strip().lower() in _LOCAL_LOADERS):
|
|
307
|
+
eng.keepalive = max(eng.keepalive, server_cfg.keepalive_floor_local)
|
|
286
308
|
|
|
287
309
|
return OpenSpeechConfig(
|
|
288
310
|
engines=engines,
|
|
@@ -112,10 +112,12 @@ def effective_source(hub: str) -> str:
|
|
|
112
112
|
"""Effective download source for a model: 'hf' or 'ms'.
|
|
113
113
|
|
|
114
114
|
- explicit engine hub 'ms'/'hf' wins
|
|
115
|
-
- ``'auto'`` →
|
|
116
|
-
|
|
117
|
-
HF
|
|
118
|
-
|
|
115
|
+
- ``'auto'`` → explicit ms default is TRUSTED unconditionally (a transient probe must not flip
|
|
116
|
+
an ms-preferred, usually HF-blocked box to HF — that caused FunASR engines to re-fetch from
|
|
117
|
+
HF and stall); explicit hf default uses hf when reachable, else falls back to ms (HF-block-
|
|
118
|
+
proofing); with NO explicit default: ModelScope if reachable (funasr-native) else HuggingFace
|
|
119
|
+
(direct or via auto-mirror). Only decides a *fresh* download's source — _materialise reuses
|
|
120
|
+
any already-downloaded copy first.
|
|
119
121
|
- hub '' → global OSA_DEFAULT_MODEL_SOURCE (default 'hf')
|
|
120
122
|
- back-compat: OSA_PREFER_MODELSCOPE=1 with no explicit default → 'ms'
|
|
121
123
|
"""
|
|
@@ -124,11 +126,16 @@ def effective_source(hub: str) -> str:
|
|
|
124
126
|
return h
|
|
125
127
|
glob = os.environ.get("OSA_DEFAULT_MODEL_SOURCE", "").strip().lower()
|
|
126
128
|
if h == "auto":
|
|
129
|
+
# Explicit ms default → TRUST it, no reachability gate. ms-preferred boxes are typically
|
|
130
|
+
# HF-blocked, so a transient ms probe failure must NOT flip them to HF — that made
|
|
131
|
+
# FunASR-style engines re-fetch the model/VAD from HF, causing duplicate downloads +
|
|
132
|
+
# stalls. (hf default keeps its probe + ms fallback below, which is the HF-block-proofing
|
|
133
|
+
# for hf-preferred boxes; only ms-trust is unconditional.)
|
|
134
|
+
if glob == "ms":
|
|
135
|
+
return "ms"
|
|
127
136
|
reach = reachable_sources()
|
|
128
137
|
if glob == "hf" and (reach["hf"] or reach["hf_mirror"]):
|
|
129
138
|
return "hf"
|
|
130
|
-
if glob == "ms" and reach["ms"]:
|
|
131
|
-
return "ms"
|
|
132
139
|
if reach["ms"]:
|
|
133
140
|
return "ms" # ModelScope reachable → prefer it (HF-block-proof)
|
|
134
141
|
return "hf" # HF direct, or auto-mirror via ensure_reachable_download_env
|
{openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/canary_qwen_stt.py
RENAMED
|
@@ -16,8 +16,9 @@ from collections.abc import AsyncIterator
|
|
|
16
16
|
from dataclasses import dataclass
|
|
17
17
|
from typing import Any
|
|
18
18
|
|
|
19
|
-
from openspeechapi.core.base import STTProvider
|
|
19
|
+
from openspeechapi.core.base import AimModelSpec, STTProvider, aim_local_path_or
|
|
20
20
|
from openspeechapi.core.enums import Capability, ExecMode, ProviderType
|
|
21
|
+
from openspeechapi.core.model_hub import build_aim_spec
|
|
21
22
|
from openspeechapi.core.models import AudioData, STTOptions, Transcription
|
|
22
23
|
from openspeechapi.core.settings import BaseSettings
|
|
23
24
|
from openspeechapi.logging_config import logger
|
|
@@ -27,6 +28,10 @@ from openspeechapi.providers.stt._local_audio import duration_ms, write_temp_wav
|
|
|
27
28
|
@dataclass
|
|
28
29
|
class CanaryQwenSTTSettings(BaseSettings):
|
|
29
30
|
model: str = "nvidia/canary-qwen-2.5b"
|
|
31
|
+
# aim-resolved local path, set by the main-process aim provisioning step and
|
|
32
|
+
# persisted to providers.yaml. When set + present on disk, the loader uses it
|
|
33
|
+
# instead of `model` (keeps working when aim is absent — falls back to the repo id).
|
|
34
|
+
model_path: str = ""
|
|
30
35
|
device: str = "cpu" # cpu | cuda (GPU strongly recommended)
|
|
31
36
|
dtype: str = "bfloat16" # bfloat16 | float32
|
|
32
37
|
max_new_tokens: int = 128
|
|
@@ -66,8 +71,17 @@ class CanaryQwenSTT(STTProvider):
|
|
|
66
71
|
async def health_check(self) -> bool:
|
|
67
72
|
return self._model is not None
|
|
68
73
|
|
|
74
|
+
def aim_model_spec(self) -> AimModelSpec | None:
|
|
75
|
+
"""Let aim (ai-model-manager) download + manage the weights, per CLAUDE.md's aim
|
|
76
|
+
rule. ``SALM.from_pretrained`` loads from a HF repo id; ``build_aim_spec`` adds
|
|
77
|
+
existing-copy-first (defers to a copy already in the HF cache instead of having aim
|
|
78
|
+
re-download) and the ``hf:`` scheme. canary-qwen has no ModelScope mirror, so the
|
|
79
|
+
hub is fixed to ``hf``."""
|
|
80
|
+
return build_aim_spec(self.settings.model, "hf", None, "asr/model")
|
|
81
|
+
|
|
69
82
|
async def _ensure_model(self, s: "CanaryQwenSTTSettings") -> None:
|
|
70
|
-
|
|
83
|
+
# model_path changes the resolved load target → part of the reload key.
|
|
84
|
+
key = (s.model.strip(), s.model_path.strip(), s.device.strip(), s.dtype.strip())
|
|
71
85
|
if self._model is not None and self._loaded_key == key:
|
|
72
86
|
return
|
|
73
87
|
try:
|
|
@@ -79,8 +93,12 @@ class CanaryQwenSTT(STTProvider):
|
|
|
79
93
|
"pip install 'nemo_toolkit[asr] @ git+https://github.com/NVIDIA/NeMo.git'"
|
|
80
94
|
) from exc
|
|
81
95
|
|
|
96
|
+
# Load from the aim-provisioned local path when set + present on disk; else the repo
|
|
97
|
+
# id (NeMo downloads it). Keeps working when aim is absent (falls back to the id).
|
|
98
|
+
target = aim_local_path_or(s.model_path, s.model)
|
|
99
|
+
|
|
82
100
|
def _load() -> Any:
|
|
83
|
-
m = SALM.from_pretrained(
|
|
101
|
+
m = SALM.from_pretrained(target)
|
|
84
102
|
if s.dtype.strip().lower() == "bfloat16":
|
|
85
103
|
m = m.bfloat16()
|
|
86
104
|
return m.eval().to(s.device)
|
|
@@ -10,15 +10,36 @@ from collections.abc import AsyncIterator
|
|
|
10
10
|
from dataclasses import dataclass
|
|
11
11
|
from typing import Any
|
|
12
12
|
|
|
13
|
-
from openspeechapi.core.base import STTProvider
|
|
13
|
+
from openspeechapi.core.base import AimModelSpec, STTProvider, aim_local_path_or
|
|
14
14
|
|
|
15
15
|
from openspeechapi.core.enums import Capability, ExecMode, ProviderType
|
|
16
|
+
from openspeechapi.core.model_hub import build_aim_spec
|
|
16
17
|
from openspeechapi.core.models import AudioData, STTOptions, Transcription, Word
|
|
17
18
|
from openspeechapi.core.settings import BaseSettings
|
|
18
19
|
|
|
20
|
+
# faster-whisper's own size→HF-repo map (faster_whisper.utils._MODELS), restricted to the
|
|
21
|
+
# sizes we offer in field_options. Used to give aim a concrete `hf:<repo>` source — aim
|
|
22
|
+
# can't act on a bare size alias like "large-v3". NOTE: the turbo + large aliases live
|
|
23
|
+
# under different orgs (mobiuslabsgmbh / large-v3), so this can't be derived by f-string.
|
|
24
|
+
_FW_REPOS = {
|
|
25
|
+
"tiny": "Systran/faster-whisper-tiny",
|
|
26
|
+
"base": "Systran/faster-whisper-base",
|
|
27
|
+
"small": "Systran/faster-whisper-small",
|
|
28
|
+
"medium": "Systran/faster-whisper-medium",
|
|
29
|
+
"large-v2": "Systran/faster-whisper-large-v2",
|
|
30
|
+
"large-v3": "Systran/faster-whisper-large-v3",
|
|
31
|
+
"large-v3-turbo": "mobiuslabsgmbh/faster-whisper-large-v3-turbo",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
19
35
|
@dataclass
|
|
20
36
|
class FasterWhisperSTTSettings(BaseSettings):
|
|
21
37
|
model_size: str = "base"
|
|
38
|
+
# aim-resolved local path, set by the main-process aim provisioning step and persisted
|
|
39
|
+
# to providers.yaml. When set + present on disk, the loader uses it instead of the size
|
|
40
|
+
# alias (keeps working when aim is absent — falls back to the size, which faster-whisper
|
|
41
|
+
# resolves to its HF repo itself).
|
|
42
|
+
model_path: str = ""
|
|
22
43
|
device: str = "auto"
|
|
23
44
|
compute_type: str = "default"
|
|
24
45
|
download_root: str | None = None
|
|
@@ -53,6 +74,18 @@ class FasterWhisperSTT(STTProvider):
|
|
|
53
74
|
)
|
|
54
75
|
logger.info("{} provider started", self.name)
|
|
55
76
|
|
|
77
|
+
def aim_model_spec(self) -> AimModelSpec | None:
|
|
78
|
+
"""Let aim (ai-model-manager) download + manage the weights, per CLAUDE.md's aim
|
|
79
|
+
rule. faster-whisper resolves a size alias (e.g. "large-v3") to a HF repo
|
|
80
|
+
internally; map it back via ``_FW_REPOS`` so aim gets a concrete ``hf:<repo>``.
|
|
81
|
+
``build_aim_spec`` adds existing-copy-first (defers to a copy already in the HF
|
|
82
|
+
cache) and the ``hf:`` scheme. None when the configured size is a local dir or an
|
|
83
|
+
unknown alias (no repo to map → fall back to faster-whisper's own download)."""
|
|
84
|
+
repo = _FW_REPOS.get((self.settings.model_size or "").strip())
|
|
85
|
+
if not repo:
|
|
86
|
+
return None
|
|
87
|
+
return build_aim_spec(repo, "hf", None, "asr/model")
|
|
88
|
+
|
|
56
89
|
async def _ensure_model(
|
|
57
90
|
self,
|
|
58
91
|
*,
|
|
@@ -67,7 +100,12 @@ class FasterWhisperSTT(STTProvider):
|
|
|
67
100
|
"Install faster-whisper: pip install openspeechapi[faster-whisper]"
|
|
68
101
|
)
|
|
69
102
|
|
|
70
|
-
|
|
103
|
+
# Prefer the aim-provisioned local dir when set + present on disk; else the size
|
|
104
|
+
# alias (faster-whisper resolves it to its HF repo and downloads). Keeps working
|
|
105
|
+
# when aim is absent (falls back to the alias).
|
|
106
|
+
normalized_model_size = self._resolve_model_dir(
|
|
107
|
+
aim_local_path_or(self.settings.model_path, model_size)
|
|
108
|
+
)
|
|
71
109
|
|
|
72
110
|
if (
|
|
73
111
|
self._model is not None
|
|
@@ -5,8 +5,12 @@ strong singing-lyrics recognition. Two variants:
|
|
|
5
5
|
* ``aed`` — FireRedASR-AED-L (attention-encoder-decoder), audio ≤ 60s
|
|
6
6
|
* ``llm`` — FireRedASR-LLM-L (LLM-based), audio ≤ 30s
|
|
7
7
|
|
|
8
|
-
Weights are
|
|
9
|
-
|
|
8
|
+
Weights are pulled from **ModelScope** by fireredasr itself — its
|
|
9
|
+
``FireRedAsr.from_pretrained(asr_type)`` calls ``modelscope.snapshot_download(
|
|
10
|
+
"pengzhendong/FireRedASR-<TYPE>-L")`` internally (it takes ONLY the type, computes the
|
|
11
|
+
repo + cache dir itself, and exposes no path/repo override). So aim can pre-fetch the
|
|
12
|
+
weights (download button + lazy-start), but the load call can't be redirected to an
|
|
13
|
+
aim-resolved ``model_path`` the way the other engines are — see ``aim_model_spec``.
|
|
10
14
|
|
|
11
15
|
Capabilities: BATCH + MULTILINGUAL. Offline batch model.
|
|
12
16
|
"""
|
|
@@ -19,13 +23,21 @@ from collections.abc import AsyncIterator
|
|
|
19
23
|
from dataclasses import dataclass
|
|
20
24
|
from typing import Any
|
|
21
25
|
|
|
22
|
-
from openspeechapi.core.base import STTProvider
|
|
26
|
+
from openspeechapi.core.base import AimModelSpec, STTProvider
|
|
23
27
|
from openspeechapi.core.enums import Capability, ExecMode, ProviderType
|
|
28
|
+
from openspeechapi.core.model_hub import build_aim_spec
|
|
24
29
|
from openspeechapi.core.models import AudioData, STTOptions, Transcription
|
|
25
30
|
from openspeechapi.core.settings import BaseSettings
|
|
26
31
|
from openspeechapi.logging_config import logger
|
|
27
32
|
from openspeechapi.providers.stt._local_audio import duration_ms, write_temp_wav
|
|
28
33
|
|
|
34
|
+
# fireredasr's hardcoded ModelScope repo per variant (FireRedAsr.from_pretrained →
|
|
35
|
+
# snapshot_download(f"pengzhendong/FireRedASR-{TYPE}-L")). Drives the aim source.
|
|
36
|
+
_FIRERED_REPOS = {
|
|
37
|
+
"aed": "pengzhendong/FireRedASR-AED-L",
|
|
38
|
+
"llm": "pengzhendong/FireRedASR-LLM-L",
|
|
39
|
+
}
|
|
40
|
+
|
|
29
41
|
|
|
30
42
|
@dataclass
|
|
31
43
|
class FireRedASRSTTSettings(BaseSettings):
|
|
@@ -68,6 +80,23 @@ class FireRedASRSTT(STTProvider):
|
|
|
68
80
|
async def health_check(self) -> bool:
|
|
69
81
|
return self._model is not None
|
|
70
82
|
|
|
83
|
+
def aim_model_spec(self) -> AimModelSpec | None:
|
|
84
|
+
"""Let aim (ai-model-manager) pre-fetch the weights, per CLAUDE.md's aim rule.
|
|
85
|
+
fireredasr downloads from **ModelScope** (``snapshot_download("pengzhendong/
|
|
86
|
+
FireRedASR-<TYPE>-L")``), so the aim source uses the ``ms:`` scheme via
|
|
87
|
+
``build_aim_spec`` (which also defers to an already-downloaded copy → returns None).
|
|
88
|
+
|
|
89
|
+
NOTE: this only makes aim DOWNLOAD the weights ahead of time (WebUI button /
|
|
90
|
+
lazy-start). fireredasr's ``from_pretrained(asr_type)`` takes no path/repo and
|
|
91
|
+
re-runs its own ``snapshot_download`` into the ModelScope cache at load time, so —
|
|
92
|
+
unlike the other engines — there's no ``model_path`` for the loader to consume.
|
|
93
|
+
aim pre-fetching the same ModelScope repo warms that cache so the load is a no-op
|
|
94
|
+
re-resolve (``snapshot_download`` is idempotent)."""
|
|
95
|
+
repo = _FIRERED_REPOS.get((self.settings.model_type or "").strip().lower())
|
|
96
|
+
if not repo:
|
|
97
|
+
return None
|
|
98
|
+
return build_aim_spec(repo, "ms", None, "asr/model")
|
|
99
|
+
|
|
71
100
|
async def _ensure_model(self, s: "FireRedASRSTTSettings") -> None:
|
|
72
101
|
key = (s.model_type.strip(), s.device.strip())
|
|
73
102
|
if self._model is not None and self._loaded_key == key:
|
|
@@ -17,8 +17,9 @@ from dataclasses import dataclass
|
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
from typing import Any
|
|
19
19
|
|
|
20
|
-
from openspeechapi.core.base import STTProvider
|
|
20
|
+
from openspeechapi.core.base import AimModelSpec, STTProvider, aim_local_path_or
|
|
21
21
|
from openspeechapi.core.enums import Capability, ExecMode, ProviderType
|
|
22
|
+
from openspeechapi.core.model_hub import build_aim_spec
|
|
22
23
|
from openspeechapi.core.models import AudioData, STTOptions, Transcription
|
|
23
24
|
from openspeechapi.core.settings import BaseSettings
|
|
24
25
|
from openspeechapi.logging_config import logger
|
|
@@ -51,6 +52,10 @@ for _x in _MMS_LANGS:
|
|
|
51
52
|
@dataclass
|
|
52
53
|
class MMSSTTSettings(BaseSettings):
|
|
53
54
|
model: str = "facebook/mms-1b-all"
|
|
55
|
+
# aim-resolved local path, set by the main-process aim provisioning step and
|
|
56
|
+
# persisted to providers.yaml. When set + present on disk, the loader uses it
|
|
57
|
+
# instead of `model` (keeps working when aim is absent — falls back to the repo id).
|
|
58
|
+
model_path: str = ""
|
|
54
59
|
language: str = "eng" # ISO 639-3 (eng, cmn, yue, jpn, ...)
|
|
55
60
|
device: str = "auto" # auto | cpu | cuda | mps (auto: cuda > mps > cpu)
|
|
56
61
|
|
|
@@ -118,8 +123,17 @@ class MMSSTT(STTProvider):
|
|
|
118
123
|
pass
|
|
119
124
|
return "cpu"
|
|
120
125
|
|
|
126
|
+
def aim_model_spec(self) -> AimModelSpec | None:
|
|
127
|
+
"""Let aim (ai-model-manager) download + manage the model, per CLAUDE.md's aim
|
|
128
|
+
rule. ``build_aim_spec`` adds existing-copy-first (defers to a copy already in the
|
|
129
|
+
HF cache instead of having aim re-download it) and the ``hf:`` scheme, consistent
|
|
130
|
+
with the other STT engines. Meta MMS has no ModelScope mirror, so the hub is fixed
|
|
131
|
+
to ``hf``."""
|
|
132
|
+
return build_aim_spec(self.settings.model, "hf", None, "asr/model")
|
|
133
|
+
|
|
121
134
|
async def _ensure_model(self, s: "MMSSTTSettings") -> None:
|
|
122
|
-
|
|
135
|
+
# model_path changes the resolved load target → part of the reload key.
|
|
136
|
+
key = (s.model.strip(), s.model_path.strip(), s.language.strip(), s.device.strip())
|
|
123
137
|
if self._model is not None and self._loaded_key == key:
|
|
124
138
|
return
|
|
125
139
|
try:
|
|
@@ -130,12 +144,16 @@ class MMSSTT(STTProvider):
|
|
|
130
144
|
"pip install 'openspeechapi[mms-stt]'"
|
|
131
145
|
) from exc
|
|
132
146
|
|
|
147
|
+
# Load from the aim-provisioned local path when set + present on disk; else the repo
|
|
148
|
+
# id (transformers downloads it). Keeps working when aim is absent (falls back to id).
|
|
149
|
+
target = aim_local_path_or(s.model_path, s.model)
|
|
150
|
+
|
|
133
151
|
def _build(local_only: bool) -> tuple[Any, Any]:
|
|
134
152
|
processor = AutoProcessor.from_pretrained(
|
|
135
|
-
|
|
153
|
+
target, target_lang=s.language, local_files_only=local_only
|
|
136
154
|
)
|
|
137
155
|
model = Wav2Vec2ForCTC.from_pretrained(
|
|
138
|
-
|
|
156
|
+
target, target_lang=s.language, ignore_mismatched_sizes=True,
|
|
139
157
|
local_files_only=local_only,
|
|
140
158
|
)
|
|
141
159
|
return model, processor
|
|
@@ -14,8 +14,9 @@ from collections.abc import AsyncIterator
|
|
|
14
14
|
from dataclasses import dataclass
|
|
15
15
|
from typing import Any
|
|
16
16
|
|
|
17
|
-
from openspeechapi.core.base import STTProvider
|
|
17
|
+
from openspeechapi.core.base import AimModelSpec, STTProvider, aim_local_path_or
|
|
18
18
|
from openspeechapi.core.enums import Capability, ExecMode, ProviderType
|
|
19
|
+
from openspeechapi.core.model_hub import build_aim_spec
|
|
19
20
|
from openspeechapi.core.models import AudioData, STTOptions, Transcription
|
|
20
21
|
from openspeechapi.core.settings import BaseSettings
|
|
21
22
|
from openspeechapi.logging_config import logger
|
|
@@ -25,6 +26,10 @@ from openspeechapi.providers.stt._local_audio import duration_ms, write_temp_wav
|
|
|
25
26
|
@dataclass
|
|
26
27
|
class MoonshineSTTSettings(BaseSettings):
|
|
27
28
|
model: str = "UsefulSensors/moonshine-base" # base | tiny (English)
|
|
29
|
+
# aim-resolved local path, set by the main-process aim provisioning step and
|
|
30
|
+
# persisted to providers.yaml. When set + present on disk, the loader uses it
|
|
31
|
+
# instead of `model` (keeps working when aim is absent — falls back to the repo id).
|
|
32
|
+
model_path: str = ""
|
|
28
33
|
|
|
29
34
|
|
|
30
35
|
class MoonshineSTT(STTProvider):
|
|
@@ -44,25 +49,35 @@ class MoonshineSTT(STTProvider):
|
|
|
44
49
|
self.settings = settings or MoonshineSTTSettings()
|
|
45
50
|
self._model: Any = None
|
|
46
51
|
self._processor: Any = None
|
|
47
|
-
self.
|
|
52
|
+
self._loaded_key: tuple | None = None
|
|
48
53
|
|
|
49
54
|
# ── lifecycle ──────────────────────────────────────────────────────────
|
|
50
55
|
async def start(self) -> None:
|
|
51
56
|
await self._ensure_model(self.settings.model)
|
|
52
|
-
logger.info("{} provider started (model={})", self.name, self.
|
|
57
|
+
logger.info("{} provider started (model={})", self.name, self.settings.model)
|
|
53
58
|
|
|
54
59
|
async def stop(self) -> None:
|
|
55
60
|
self._model = None
|
|
56
61
|
self._processor = None
|
|
57
|
-
self.
|
|
62
|
+
self._loaded_key = None
|
|
58
63
|
logger.info("{} provider stopped", self.name)
|
|
59
64
|
|
|
60
65
|
async def health_check(self) -> bool:
|
|
61
66
|
return self._model is not None
|
|
62
67
|
|
|
68
|
+
def aim_model_spec(self) -> AimModelSpec | None:
|
|
69
|
+
"""Let aim (ai-model-manager) download + manage the model, per CLAUDE.md's aim
|
|
70
|
+
rule. ``build_aim_spec`` adds existing-copy-first (defers to a copy already in the
|
|
71
|
+
HF cache instead of having aim re-download it) and the ``hf:`` scheme, consistent
|
|
72
|
+
with the other STT engines. Moonshine has no ModelScope mirror, so the hub is
|
|
73
|
+
fixed to ``hf``."""
|
|
74
|
+
return build_aim_spec(self.settings.model, "hf", None, "asr/model")
|
|
75
|
+
|
|
63
76
|
async def _ensure_model(self, model: str) -> None:
|
|
64
77
|
model = (model or self.settings.model).strip()
|
|
65
|
-
|
|
78
|
+
# model_path changes the resolved load target → part of the reload key.
|
|
79
|
+
key = (model, self.settings.model_path.strip())
|
|
80
|
+
if self._model is not None and self._loaded_key == key:
|
|
66
81
|
return
|
|
67
82
|
try:
|
|
68
83
|
from transformers import AutoProcessor, MoonshineForConditionalGeneration
|
|
@@ -72,13 +87,17 @@ class MoonshineSTT(STTProvider):
|
|
|
72
87
|
"pip install 'openspeechapi[moonshine-stt]'"
|
|
73
88
|
) from exc
|
|
74
89
|
|
|
90
|
+
# Load from the aim-provisioned local path when set + present on disk; else the repo
|
|
91
|
+
# id (transformers downloads it). Keeps working when aim is absent (falls back to id).
|
|
92
|
+
target = aim_local_path_or(self.settings.model_path, model)
|
|
93
|
+
|
|
75
94
|
def _load() -> tuple[Any, Any]:
|
|
76
|
-
processor = AutoProcessor.from_pretrained(
|
|
77
|
-
m = MoonshineForConditionalGeneration.from_pretrained(
|
|
95
|
+
processor = AutoProcessor.from_pretrained(target)
|
|
96
|
+
m = MoonshineForConditionalGeneration.from_pretrained(target)
|
|
78
97
|
return m, processor
|
|
79
98
|
|
|
80
99
|
self._model, self._processor = await asyncio.to_thread(_load)
|
|
81
|
-
self.
|
|
100
|
+
self._loaded_key = key
|
|
82
101
|
|
|
83
102
|
# ── transcription ──────────────────────────────────────────────────────
|
|
84
103
|
async def transcribe(
|
{openspeechapi-0.2.22 → openspeechapi-0.2.23}/openspeechapi/providers/stt/phi4_multimodal_stt.py
RENAMED
|
@@ -15,8 +15,9 @@ from collections.abc import AsyncIterator
|
|
|
15
15
|
from dataclasses import dataclass
|
|
16
16
|
from typing import Any
|
|
17
17
|
|
|
18
|
-
from openspeechapi.core.base import STTProvider
|
|
18
|
+
from openspeechapi.core.base import AimModelSpec, STTProvider, aim_local_path_or
|
|
19
19
|
from openspeechapi.core.enums import Capability, ExecMode, ProviderType
|
|
20
|
+
from openspeechapi.core.model_hub import build_aim_spec
|
|
20
21
|
from openspeechapi.core.models import AudioData, STTOptions, Transcription
|
|
21
22
|
from openspeechapi.core.settings import BaseSettings
|
|
22
23
|
from openspeechapi.logging_config import logger
|
|
@@ -26,6 +27,10 @@ from openspeechapi.providers.stt._local_audio import duration_ms, write_temp_wav
|
|
|
26
27
|
@dataclass
|
|
27
28
|
class Phi4MultimodalSTTSettings(BaseSettings):
|
|
28
29
|
model: str = "microsoft/Phi-4-multimodal-instruct"
|
|
30
|
+
# aim-resolved local path, set by the main-process aim provisioning step and
|
|
31
|
+
# persisted to providers.yaml. When set + present on disk, the loader uses it
|
|
32
|
+
# instead of `model` (keeps working when aim is absent — falls back to the repo id).
|
|
33
|
+
model_path: str = ""
|
|
29
34
|
device: str = "auto" # auto | cpu | cuda | mps (auto: cuda > mps > cpu)
|
|
30
35
|
dtype: str = "auto" # auto | bfloat16 | float16
|
|
31
36
|
prompt: str = "Transcribe the audio clip into text."
|
|
@@ -88,8 +93,17 @@ class Phi4MultimodalSTT(STTProvider):
|
|
|
88
93
|
pass
|
|
89
94
|
return "cpu"
|
|
90
95
|
|
|
96
|
+
def aim_model_spec(self) -> AimModelSpec | None:
|
|
97
|
+
"""Let aim (ai-model-manager) download + manage the model, per CLAUDE.md's aim
|
|
98
|
+
rule. ``build_aim_spec`` adds existing-copy-first (defers to a copy already in the
|
|
99
|
+
HF cache instead of having aim re-download it) and the ``hf:`` scheme, consistent
|
|
100
|
+
with the other STT engines. Phi-4-multimodal has no ModelScope mirror, so the hub
|
|
101
|
+
is fixed to ``hf``."""
|
|
102
|
+
return build_aim_spec(self.settings.model, "hf", None, "asr/model")
|
|
103
|
+
|
|
91
104
|
async def _ensure_model(self, s: "Phi4MultimodalSTTSettings") -> None:
|
|
92
|
-
|
|
105
|
+
# model_path changes the resolved load target → part of the reload key.
|
|
106
|
+
key = (s.model.strip(), s.model_path.strip(), s.device.strip(), s.dtype.strip())
|
|
93
107
|
if self._model is not None and self._loaded_key == key:
|
|
94
108
|
return
|
|
95
109
|
try:
|
|
@@ -100,18 +114,22 @@ class Phi4MultimodalSTT(STTProvider):
|
|
|
100
114
|
"pip install 'openspeechapi[phi4-multimodal-stt]'"
|
|
101
115
|
) from exc
|
|
102
116
|
|
|
117
|
+
# Load from the aim-provisioned local path when set + present on disk; else the repo
|
|
118
|
+
# id (transformers downloads it). Keeps working when aim is absent (falls back to id).
|
|
119
|
+
target = aim_local_path_or(s.model_path, s.model)
|
|
120
|
+
|
|
103
121
|
def _load() -> tuple[Any, Any, Any]:
|
|
104
122
|
dev = self._resolve_device(s.device)
|
|
105
123
|
# Phi-4 defaults to flash_attention_2 (CUDA-only). MPS/CPU must use eager;
|
|
106
124
|
# use sdpa on CUDA so no flash-attn package is required.
|
|
107
125
|
attn = "eager" if dev in ("mps", "cpu") else "sdpa"
|
|
108
|
-
processor = AutoProcessor.from_pretrained(
|
|
126
|
+
processor = AutoProcessor.from_pretrained(target, trust_remote_code=True)
|
|
109
127
|
|
|
110
128
|
def _from(d: str, impl: str) -> Any:
|
|
111
129
|
# Phi-4 pins transformers==4.48.2 (its isolated venv), where the kwarg
|
|
112
130
|
# is `torch_dtype` (the `dtype` alias only exists in newer transformers).
|
|
113
131
|
m = AutoModelForCausalLM.from_pretrained(
|
|
114
|
-
|
|
132
|
+
target, trust_remote_code=True, torch_dtype=s.dtype,
|
|
115
133
|
_attn_implementation=impl,
|
|
116
134
|
)
|
|
117
135
|
return m.to(d)
|
|
@@ -16,8 +16,9 @@ from collections.abc import AsyncIterator
|
|
|
16
16
|
from dataclasses import dataclass
|
|
17
17
|
from typing import Any
|
|
18
18
|
|
|
19
|
-
from openspeechapi.core.base import STTProvider
|
|
19
|
+
from openspeechapi.core.base import AimModelSpec, STTProvider, aim_local_path_or
|
|
20
20
|
from openspeechapi.core.enums import Capability, ExecMode, ProviderType
|
|
21
|
+
from openspeechapi.core.model_hub import build_aim_spec
|
|
21
22
|
from openspeechapi.core.models import AudioData, STTOptions, Transcription
|
|
22
23
|
from openspeechapi.core.settings import BaseSettings
|
|
23
24
|
from openspeechapi.logging_config import logger
|
|
@@ -27,6 +28,13 @@ from openspeechapi.providers.stt._local_audio import duration_ms, write_temp_wav
|
|
|
27
28
|
@dataclass
|
|
28
29
|
class Qwen3OmniSTTSettings(BaseSettings):
|
|
29
30
|
model: str = "Qwen/Qwen3-Omni-30B-A3B-Instruct"
|
|
31
|
+
# aim-resolved local path, set by the main-process aim provisioning step and
|
|
32
|
+
# persisted to providers.yaml. When set + present on disk, the loader uses it
|
|
33
|
+
# instead of `model` (keeps working when aim is absent — falls back to the repo id).
|
|
34
|
+
model_path: str = ""
|
|
35
|
+
# Download source for aim: "auto" follows OSA_DEFAULT_MODEL_SOURCE (ModelScope on
|
|
36
|
+
# the DGX box); force with "hf" | "ms". The repo id is identical on both hubs.
|
|
37
|
+
hub: str = "auto"
|
|
30
38
|
dtype: str = "auto" # auto | bfloat16 | float16
|
|
31
39
|
device_map: str = "auto" # auto | cuda | cpu
|
|
32
40
|
attn_implementation: str = "sdpa" # sdpa | flash_attention_2 | eager
|
|
@@ -47,6 +55,7 @@ class Qwen3OmniSTT(STTProvider):
|
|
|
47
55
|
supports_param_overrides = True
|
|
48
56
|
field_options = {
|
|
49
57
|
"model": ["Qwen/Qwen3-Omni-30B-A3B-Instruct"],
|
|
58
|
+
"hub": ["auto", "hf", "ms"],
|
|
50
59
|
"dtype": ["auto", "bfloat16", "float16"],
|
|
51
60
|
"device_map": ["auto", "cuda", "cpu"],
|
|
52
61
|
"attn_implementation": ["sdpa", "flash_attention_2", "eager"],
|
|
@@ -72,8 +81,39 @@ class Qwen3OmniSTT(STTProvider):
|
|
|
72
81
|
async def health_check(self) -> bool:
|
|
73
82
|
return self._model is not None
|
|
74
83
|
|
|
84
|
+
@staticmethod
|
|
85
|
+
def _resolve_device_map(device_map: str) -> str:
|
|
86
|
+
"""Resolve the configured device_map to a concrete placement.
|
|
87
|
+
|
|
88
|
+
device_map="auto" mis-reads unified-memory GPUs (DGX/GB10, Jetson) whose free
|
|
89
|
+
VRAM reports as N/A → accelerate concludes nothing "fits" and offloads the whole
|
|
90
|
+
30B model to CPU (~20x slower). Pin the GPU when CUDA is present (mirrors gemma4's
|
|
91
|
+
_load_cuda fix); fall back to CPU only when there's no CUDA at all. Explicit
|
|
92
|
+
"cuda"/"cpu" are user overrides and pass through untouched (no torch probe).
|
|
93
|
+
|
|
94
|
+
NOTE: pinning "cuda" places the whole model on a single device — correct for the
|
|
95
|
+
unified-memory targets this engine is gated to (GB10 128GB / Jetson). True
|
|
96
|
+
multi-GPU sharding of the 30B MoE would need a separate explicit option (e.g.
|
|
97
|
+
"balanced"), not "auto".
|
|
98
|
+
"""
|
|
99
|
+
dm = (device_map or "auto").strip().lower()
|
|
100
|
+
if dm != "auto":
|
|
101
|
+
return dm
|
|
102
|
+
import torch
|
|
103
|
+
return "cuda" if torch.cuda.is_available() else "cpu"
|
|
104
|
+
|
|
105
|
+
def aim_model_spec(self) -> AimModelSpec | None:
|
|
106
|
+
"""Let aim (ai-model-manager) download + manage the 30B weights, per CLAUDE.md's
|
|
107
|
+
aim rule. ``build_aim_spec`` adds existing-copy-first (defers to a copy already in
|
|
108
|
+
cache instead of re-downloading) and the ``hf:``/``ms:`` scheme by ``effective_source``
|
|
109
|
+
(hub 'auto' → ModelScope on the DGX box). The repo id is identical on HF and
|
|
110
|
+
ModelScope, so no ms_repo_map is needed."""
|
|
111
|
+
return build_aim_spec(self.settings.model, self.settings.hub, None, "asr/model")
|
|
112
|
+
|
|
75
113
|
async def _ensure_model(self, s: "Qwen3OmniSTTSettings") -> None:
|
|
76
|
-
|
|
114
|
+
# model_path/hub change the resolved load target → part of the reload key.
|
|
115
|
+
key = (s.model.strip(), s.model_path.strip(), s.hub.strip(),
|
|
116
|
+
s.dtype.strip(), s.device_map.strip(), s.attn_implementation.strip())
|
|
77
117
|
if self._model is not None and self._loaded_key == key:
|
|
78
118
|
return
|
|
79
119
|
try:
|
|
@@ -87,12 +127,22 @@ class Qwen3OmniSTT(STTProvider):
|
|
|
87
127
|
"pip install 'openspeechapi[qwen3-omni-stt]'"
|
|
88
128
|
) from exc
|
|
89
129
|
|
|
130
|
+
# Resolve device placement on THIS (event-loop) thread, before the heavy load is
|
|
131
|
+
# offloaded to a worker. Probing CUDA imports torch, and the FIRST torch import in
|
|
132
|
+
# an asyncio worker thread segfaults on macOS; resolving here also avoids relying on
|
|
133
|
+
# transformers having already pre-imported torch. _load() then loads with a concrete
|
|
134
|
+
# device only.
|
|
135
|
+
device_map = self._resolve_device_map(s.device_map)
|
|
136
|
+
# Load from the aim-provisioned local path when set + present on disk; else the repo
|
|
137
|
+
# id (transformers downloads it). Keeps working when aim is absent (falls back to id).
|
|
138
|
+
target = aim_local_path_or(s.model_path, s.model)
|
|
139
|
+
|
|
90
140
|
def _load() -> tuple[Any, Any]:
|
|
91
141
|
model = Qwen3OmniMoeForConditionalGeneration.from_pretrained(
|
|
92
|
-
|
|
142
|
+
target, dtype=s.dtype, device_map=device_map,
|
|
93
143
|
attn_implementation=s.attn_implementation,
|
|
94
144
|
)
|
|
95
|
-
processor = Qwen3OmniMoeProcessor.from_pretrained(
|
|
145
|
+
processor = Qwen3OmniMoeProcessor.from_pretrained(target)
|
|
96
146
|
return model, processor
|
|
97
147
|
|
|
98
148
|
self._model, self._processor = await asyncio.to_thread(_load)
|