openspeechapi 0.2.16__tar.gz → 0.2.18__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.16 → openspeechapi-0.2.18}/PKG-INFO +1 -1
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/config.py +21 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/qwen3_omni_stt.py +29 -1
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/app.py +11 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/routes/management.py +13 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/routes/stt.py +4 -3
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/routes/tts.py +3 -2
- openspeechapi-0.2.18/openspeechapi/server/system_metrics.py +290 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/webui/app.js +57 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/webui/index.html +3 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/webui/styles.css +24 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/pyproject.toml +1 -1
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/.gitignore +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/README.md +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/__main__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/cli.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/client/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/client/client.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/core/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/core/base.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/core/enums.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/core/model_hub.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/core/models.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/core/registry.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/core/settings.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/demo.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/aim_provision.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/context.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/dispatcher.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/executors/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/executors/base.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/executors/in_process.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/executors/remote.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/executors/subprocess_exec.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/fanout.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/filters.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/lifecycle.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/watcher.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/engine_catalog.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/engine_registry.yaml +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/exceptions.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/factory.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/aim_resolver.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/backends/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/backends/docker_backend.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/backends/native_backend.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/base.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/faster_whisper.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/fish_speech.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/sherpa_onnx.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/whisper.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/whisperlivekit.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/isolated_venv.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/manager.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/models.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/progress.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/registry.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/task_store.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/tasks.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/logging_config.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/observe/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/observe/base.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/observe/debug.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/observe/latency.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/observe/metrics.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/observe/tracing.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/observe/usage.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/_template.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/_local_audio.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/alibaba.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/assemblyai.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/azure_speech.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/baidu.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/canary_qwen_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/deepgram.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/dolphin_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/elevenlabs.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/faster_whisper.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/fireredasr_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/funasr_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/gemma4.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/google_cloud.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/iflytek.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/kimi_audio_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/macos_speech.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/mlx_whisper_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/mms_languages.json +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/mms_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/moonshine_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/openai.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/paraformer.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/parakeet_mlx_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/phi4_multimodal_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/qwen3_asr.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/sensevoice.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/sherpa_onnx.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/tencent.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/volcengine.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/vosk_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/voxtral_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/wenet_stt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/whisper.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/whisperlivekit.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/windows_speech.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/alibaba.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/azure_speech.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/baidu.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/coqui.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/cosyvoice.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/deepgram.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/elevenlabs.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/fish_speech.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/google_cloud.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/iflytek.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/macos_say.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/minimax.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/openai.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/piper.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/tencent.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/volcengine.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/tts/windows_sapi.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/auth.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/extras_installer.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/middleware.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/native_installer.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/routes/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/routes/webui.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/ws/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/ws/stt_stream.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/server/ws/tts_stream.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/telemetry/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/telemetry/perf.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/utils/__init__.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/utils/audio_converter.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/utils/audio_playback.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/vendor_registry.yaml +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/providers.example.yaml +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/aim_adopt.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/aim_consumers.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/cloud/install.sh +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/faster-whisper/native/install.sh +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/fish-speech/native/install.sh +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/macos-stt/_bundle.sh +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/macos-stt/install.sh +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/macos-stt/macos_stt.swift +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/macos-stt/request_auth.swift +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/sherpa-onnx/native/install.sh +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/sherpa-onnx/native/run_streaming_server.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/whisper/native/install.sh +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/whisperlivekit/native/install.sh +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/gen_mms_languages.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/preload_stt_model.py +0 -0
- {openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/release.sh +0 -0
|
@@ -106,6 +106,15 @@ class ServerConfig:
|
|
|
106
106
|
# Per-source download attempts (huggingface_hub resumes between attempts) before
|
|
107
107
|
# switching source. Exports OSA_MODEL_DOWNLOAD_RETRIES for workers.
|
|
108
108
|
model_download_retries: int = 3
|
|
109
|
+
# System monitor (WebUI footer + thermal guard). Background sampler interval (s) for
|
|
110
|
+
# CPU/mem/GPU/temperature; the footer polls /v1/system at roughly the same cadence.
|
|
111
|
+
metrics_interval: int = 10
|
|
112
|
+
# Thermal thresholds (°C). At >= temp_warn_c the footer turns amber; at >= temp_critical_c
|
|
113
|
+
# it turns red and (when thermal_guard) new STT/TTS requests get 503 until temp < warn
|
|
114
|
+
# (hysteresis) — guards a unified-memory GPU box from overheating into a hard hang.
|
|
115
|
+
temp_warn_c: float = 80.0
|
|
116
|
+
temp_critical_c: float = 90.0
|
|
117
|
+
thermal_guard: bool = True
|
|
109
118
|
|
|
110
119
|
|
|
111
120
|
@dataclass
|
|
@@ -241,6 +250,18 @@ def load_config(path: Path) -> OpenSpeechConfig:
|
|
|
241
250
|
server_cfg.default_model_source = src
|
|
242
251
|
elif server_cfg.prefer_modelscope:
|
|
243
252
|
server_cfg.default_model_source = "ms"
|
|
253
|
+
# System monitor / thermal guard
|
|
254
|
+
try:
|
|
255
|
+
server_cfg.metrics_interval = max(
|
|
256
|
+
2, int(srv.get("metrics_interval", server_cfg.metrics_interval)))
|
|
257
|
+
except (TypeError, ValueError):
|
|
258
|
+
pass
|
|
259
|
+
try:
|
|
260
|
+
server_cfg.temp_warn_c = float(srv.get("temp_warn_c", server_cfg.temp_warn_c))
|
|
261
|
+
server_cfg.temp_critical_c = float(srv.get("temp_critical_c", server_cfg.temp_critical_c))
|
|
262
|
+
except (TypeError, ValueError):
|
|
263
|
+
pass
|
|
264
|
+
server_cfg.thermal_guard = bool(srv.get("thermal_guard", server_cfg.thermal_guard))
|
|
244
265
|
auth = srv.get("auth", {})
|
|
245
266
|
if auth:
|
|
246
267
|
server_cfg.auth_enabled = bool(auth.get("enabled", False))
|
|
@@ -72,6 +72,27 @@ class Qwen3OmniSTT(STTProvider):
|
|
|
72
72
|
async def health_check(self) -> bool:
|
|
73
73
|
return self._model is not None
|
|
74
74
|
|
|
75
|
+
@staticmethod
|
|
76
|
+
def _resolve_device_map(device_map: str) -> str:
|
|
77
|
+
"""Resolve the configured device_map to a concrete placement.
|
|
78
|
+
|
|
79
|
+
device_map="auto" mis-reads unified-memory GPUs (DGX/GB10, Jetson) whose free
|
|
80
|
+
VRAM reports as N/A → accelerate concludes nothing "fits" and offloads the whole
|
|
81
|
+
30B model to CPU (~20x slower). Pin the GPU when CUDA is present (mirrors gemma4's
|
|
82
|
+
_load_cuda fix); fall back to CPU only when there's no CUDA at all. Explicit
|
|
83
|
+
"cuda"/"cpu" are user overrides and pass through untouched (no torch probe).
|
|
84
|
+
|
|
85
|
+
NOTE: pinning "cuda" places the whole model on a single device — correct for the
|
|
86
|
+
unified-memory targets this engine is gated to (GB10 128GB / Jetson). True
|
|
87
|
+
multi-GPU sharding of the 30B MoE would need a separate explicit option (e.g.
|
|
88
|
+
"balanced"), not "auto".
|
|
89
|
+
"""
|
|
90
|
+
dm = (device_map or "auto").strip().lower()
|
|
91
|
+
if dm != "auto":
|
|
92
|
+
return dm
|
|
93
|
+
import torch
|
|
94
|
+
return "cuda" if torch.cuda.is_available() else "cpu"
|
|
95
|
+
|
|
75
96
|
async def _ensure_model(self, s: "Qwen3OmniSTTSettings") -> None:
|
|
76
97
|
key = (s.model.strip(), s.dtype.strip(), s.device_map.strip(), s.attn_implementation.strip())
|
|
77
98
|
if self._model is not None and self._loaded_key == key:
|
|
@@ -87,9 +108,16 @@ class Qwen3OmniSTT(STTProvider):
|
|
|
87
108
|
"pip install 'openspeechapi[qwen3-omni-stt]'"
|
|
88
109
|
) from exc
|
|
89
110
|
|
|
111
|
+
# Resolve device placement on THIS (event-loop) thread, before the heavy load is
|
|
112
|
+
# offloaded to a worker. Probing CUDA imports torch, and the FIRST torch import in
|
|
113
|
+
# an asyncio worker thread segfaults on macOS; resolving here also avoids relying on
|
|
114
|
+
# transformers having already pre-imported torch. _load() then loads with a concrete
|
|
115
|
+
# device only.
|
|
116
|
+
device_map = self._resolve_device_map(s.device_map)
|
|
117
|
+
|
|
90
118
|
def _load() -> tuple[Any, Any]:
|
|
91
119
|
model = Qwen3OmniMoeForConditionalGeneration.from_pretrained(
|
|
92
|
-
s.model, dtype=s.dtype, device_map=
|
|
120
|
+
s.model, dtype=s.dtype, device_map=device_map,
|
|
93
121
|
attn_implementation=s.attn_implementation,
|
|
94
122
|
)
|
|
95
123
|
processor = Qwen3OmniMoeProcessor.from_pretrained(s.model)
|
|
@@ -15,6 +15,7 @@ from openspeechapi.local_engines import EngineManager
|
|
|
15
15
|
from openspeechapi.logging_config import ensure_configured, logger
|
|
16
16
|
from openspeechapi.server.middleware import RequestContextMiddleware
|
|
17
17
|
from openspeechapi.server.routes import stt, tts, management, webui
|
|
18
|
+
from openspeechapi.server.system_metrics import SystemMonitor
|
|
18
19
|
from openspeechapi.server.ws import stt_stream, tts_stream
|
|
19
20
|
|
|
20
21
|
|
|
@@ -109,6 +110,15 @@ def create_app(config_path: Path, registry: ProviderRegistry) -> FastAPI:
|
|
|
109
110
|
async def lifespan(app: FastAPI):
|
|
110
111
|
await dispatcher.start()
|
|
111
112
|
|
|
113
|
+
monitor = SystemMonitor(
|
|
114
|
+
interval=config.server.metrics_interval,
|
|
115
|
+
warn_c=config.server.temp_warn_c,
|
|
116
|
+
critical_c=config.server.temp_critical_c,
|
|
117
|
+
guard=config.server.thermal_guard,
|
|
118
|
+
)
|
|
119
|
+
app.state.system_monitor = monitor
|
|
120
|
+
await monitor.start()
|
|
121
|
+
|
|
112
122
|
async def _on_reload() -> dict:
|
|
113
123
|
return await dispatcher.reload_config(config_path, registry)
|
|
114
124
|
|
|
@@ -118,6 +128,7 @@ def create_app(config_path: Path, registry: ProviderRegistry) -> FastAPI:
|
|
|
118
128
|
yield
|
|
119
129
|
|
|
120
130
|
await watcher.stop()
|
|
131
|
+
await monitor.stop()
|
|
121
132
|
await dispatcher.stop()
|
|
122
133
|
|
|
123
134
|
app = FastAPI(title="OpenSpeechAPI API", version="0.1.0", lifespan=lifespan)
|
|
@@ -89,6 +89,19 @@ async def health_check(request: Request):
|
|
|
89
89
|
return {"status": "ok" if all_healthy else "degraded", "engines": health}
|
|
90
90
|
|
|
91
91
|
|
|
92
|
+
@router.get("/system")
|
|
93
|
+
async def system_metrics(request: Request):
|
|
94
|
+
"""Latest cached CPU/memory/GPU/temperature snapshot + thermal_state for the WebUI
|
|
95
|
+
footer. Sampled on a background interval (server.metrics_interval); this only reads the
|
|
96
|
+
cache, so it's safe to poll frequently and never blocks on nvidia-smi."""
|
|
97
|
+
mon = getattr(request.app.state, "system_monitor", None)
|
|
98
|
+
if mon is None:
|
|
99
|
+
return {"available": False}
|
|
100
|
+
snap = mon.snapshot()
|
|
101
|
+
snap["available"] = True
|
|
102
|
+
return snap
|
|
103
|
+
|
|
104
|
+
|
|
92
105
|
@router.get("/metrics")
|
|
93
106
|
async def metrics(request: Request):
|
|
94
107
|
dispatcher = request.app.state.dispatcher
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"""STT REST endpoints."""
|
|
2
2
|
from __future__ import annotations
|
|
3
|
-
from fastapi import APIRouter, File, Form, Request, UploadFile, HTTPException
|
|
3
|
+
from fastapi import APIRouter, Depends, File, Form, Request, UploadFile, HTTPException
|
|
4
4
|
from openspeechapi.core.models import AudioData, STTOptions
|
|
5
5
|
from openspeechapi.dispatch.fanout import FirstCompleted, HighestConfidence, CollectAll
|
|
6
6
|
from openspeechapi.exceptions import AudioConversionError, ProviderNotFoundError, FanOutAllFailedError
|
|
7
|
+
from openspeechapi.server.system_metrics import thermal_guard
|
|
7
8
|
from openspeechapi.utils.audio_converter import AudioConverter
|
|
8
9
|
|
|
9
10
|
router = APIRouter()
|
|
@@ -15,7 +16,7 @@ STRATEGY_MAP = {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
@router.post("/transcribe")
|
|
19
|
+
@router.post("/transcribe", dependencies=[Depends(thermal_guard)])
|
|
19
20
|
async def transcribe(
|
|
20
21
|
request: Request,
|
|
21
22
|
audio: UploadFile = File(...),
|
|
@@ -90,7 +91,7 @@ async def transcribe(
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
|
|
93
|
-
@router.post("/transcribe/fanout")
|
|
94
|
+
@router.post("/transcribe/fanout", dependencies=[Depends(thermal_guard)])
|
|
94
95
|
async def transcribe_fanout(
|
|
95
96
|
request: Request,
|
|
96
97
|
audio: UploadFile = File(...),
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"""TTS REST endpoints."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
import time
|
|
4
|
-
from fastapi import APIRouter, Request, HTTPException, UploadFile, File, Form
|
|
4
|
+
from fastapi import APIRouter, Depends, Request, HTTPException, UploadFile, File, Form
|
|
5
5
|
from fastapi.responses import Response
|
|
6
6
|
from pydantic import BaseModel
|
|
7
7
|
from openspeechapi.core.enums import AudioFormat
|
|
8
8
|
from openspeechapi.core.models import AudioData, TTSOptions
|
|
9
9
|
from openspeechapi.exceptions import ProviderNotFoundError
|
|
10
|
+
from openspeechapi.server.system_metrics import thermal_guard
|
|
10
11
|
from openspeechapi.utils.audio_converter import AudioConverter
|
|
11
12
|
|
|
12
13
|
router = APIRouter()
|
|
@@ -59,7 +60,7 @@ async def list_voices(request: Request, provider: str):
|
|
|
59
60
|
return {"voices": voices}
|
|
60
61
|
|
|
61
62
|
|
|
62
|
-
@router.post("/synthesize")
|
|
63
|
+
@router.post("/synthesize", dependencies=[Depends(thermal_guard)])
|
|
63
64
|
async def synthesize(request: Request, body: SynthesizeRequest):
|
|
64
65
|
dispatcher = request.app.state.dispatcher
|
|
65
66
|
opts = TTSOptions(
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"""Lightweight system resource + temperature monitor (CPU / memory / GPU / thermal).
|
|
2
|
+
|
|
3
|
+
Powers the WebUI footer status bar and an optional **thermal guard** that sheds new
|
|
4
|
+
STT/TTS load when the box runs too hot — added after a GB10/DGX box overheated into a
|
|
5
|
+
hard hang (sshd + HTTP both starved). Sampling is cheap (reads `/proc` files + one short
|
|
6
|
+
`nvidia-smi`/`tegrastats` call) and runs on a background interval; requests and the footer
|
|
7
|
+
only read the cached snapshot, never sample inline.
|
|
8
|
+
|
|
9
|
+
Temperature sourcing is defensive — it takes the max of whatever is available:
|
|
10
|
+
`/sys/class/thermal/thermal_zone*/temp`, `nvidia-smi` GPU temp, and `tegrastats` (Tegra
|
|
11
|
+
SoCs like GB10/Jetson). On a box with none of these the temp is simply ``None`` and the
|
|
12
|
+
guard stays inactive.
|
|
13
|
+
"""
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import asyncio
|
|
17
|
+
import glob
|
|
18
|
+
import os
|
|
19
|
+
import re
|
|
20
|
+
import shutil
|
|
21
|
+
import subprocess
|
|
22
|
+
import sys
|
|
23
|
+
import time
|
|
24
|
+
from typing import Any
|
|
25
|
+
|
|
26
|
+
from fastapi import HTTPException, Request
|
|
27
|
+
|
|
28
|
+
from openspeechapi.logging_config import logger
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# ── individual cheap samplers (each returns None on any failure) ─────────────
|
|
32
|
+
|
|
33
|
+
def _read_cpu_load() -> float | None:
|
|
34
|
+
"""1-min load average (cross-platform: macOS + Linux via os.getloadavg)."""
|
|
35
|
+
try:
|
|
36
|
+
return round(os.getloadavg()[0], 2)
|
|
37
|
+
except (OSError, AttributeError, IndexError):
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _read_mem() -> tuple[float | None, float | None]:
|
|
42
|
+
"""(used_gb, total_gb). Linux via /proc/meminfo (accurate MemAvailable); other POSIX
|
|
43
|
+
(macOS) via sysconf as a fallback so the footer still shows memory off-Linux."""
|
|
44
|
+
try:
|
|
45
|
+
info: dict[str, int] = {}
|
|
46
|
+
with open("/proc/meminfo") as f:
|
|
47
|
+
for line in f:
|
|
48
|
+
parts = line.split()
|
|
49
|
+
if parts and parts[0].rstrip(":") in ("MemTotal", "MemAvailable"):
|
|
50
|
+
info[parts[0].rstrip(":")] = int(parts[1]) # kB
|
|
51
|
+
total, avail = info.get("MemTotal"), info.get("MemAvailable")
|
|
52
|
+
if total is not None and avail is not None:
|
|
53
|
+
return round((total - avail) / 1048576, 2), round(total / 1048576, 2)
|
|
54
|
+
except (OSError, ValueError):
|
|
55
|
+
pass
|
|
56
|
+
if sys.platform == "darwin": # macOS has no /proc → sysctl + vm_stat
|
|
57
|
+
return _read_mem_macos()
|
|
58
|
+
return None, None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _read_mem_macos() -> tuple[float | None, float | None]:
|
|
62
|
+
"""(used_gb, total_gb) on macOS via `sysctl hw.memsize` + `vm_stat`. used = total −
|
|
63
|
+
(free + inactive + speculative), i.e. counts reclaimable pages as available."""
|
|
64
|
+
try:
|
|
65
|
+
total_b = int(subprocess.run(["sysctl", "-n", "hw.memsize"],
|
|
66
|
+
capture_output=True, text=True, timeout=3).stdout.strip())
|
|
67
|
+
vm = subprocess.run(["vm_stat"], capture_output=True, text=True, timeout=3).stdout
|
|
68
|
+
except (subprocess.SubprocessError, OSError, ValueError):
|
|
69
|
+
return None, None
|
|
70
|
+
page_m = re.search(r"page size of (\d+) bytes", vm)
|
|
71
|
+
page = int(page_m.group(1)) if page_m else 4096
|
|
72
|
+
|
|
73
|
+
def _pages(name: str) -> int:
|
|
74
|
+
m = re.search(rf"{name}:\s+(\d+)", vm)
|
|
75
|
+
return int(m.group(1)) if m else 0
|
|
76
|
+
free_b = (_pages("Pages free") + _pages("Pages inactive")
|
|
77
|
+
+ _pages("Pages speculative")) * page
|
|
78
|
+
return round((total_b - free_b) / 1073741824, 2), round(total_b / 1073741824, 2)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _read_thermal_zones() -> float | None:
|
|
82
|
+
"""Max temp (°C) across /sys/class/thermal/thermal_zone*/temp (values in milli-°C)."""
|
|
83
|
+
temps: list[float] = []
|
|
84
|
+
for p in glob.glob("/sys/class/thermal/thermal_zone*/temp"):
|
|
85
|
+
try:
|
|
86
|
+
with open(p) as f:
|
|
87
|
+
v = int(f.read().strip())
|
|
88
|
+
temps.append(v / 1000.0 if v > 1000 else float(v)) # milli-°C or °C
|
|
89
|
+
except (OSError, ValueError):
|
|
90
|
+
continue
|
|
91
|
+
return round(max(temps), 1) if temps else None
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _nvidia_smi() -> dict[str, float | None] | None:
|
|
95
|
+
"""Best-effort GPU temp/util/mem via nvidia-smi (short timeout). None if unavailable.
|
|
96
|
+
|
|
97
|
+
On unified-memory GPUs (GB10) some fields read ``[N/A]`` → parsed as None."""
|
|
98
|
+
if not shutil.which("nvidia-smi"):
|
|
99
|
+
return None
|
|
100
|
+
try:
|
|
101
|
+
out = subprocess.run(
|
|
102
|
+
["nvidia-smi",
|
|
103
|
+
"--query-gpu=temperature.gpu,utilization.gpu,memory.used,memory.total",
|
|
104
|
+
"--format=csv,noheader,nounits"],
|
|
105
|
+
capture_output=True, text=True, timeout=5,
|
|
106
|
+
)
|
|
107
|
+
except (subprocess.SubprocessError, OSError):
|
|
108
|
+
return None
|
|
109
|
+
line = out.stdout.strip().splitlines()[0] if out.stdout.strip() else ""
|
|
110
|
+
if out.returncode != 0 or not line:
|
|
111
|
+
return None
|
|
112
|
+
|
|
113
|
+
def _num(x: str) -> float | None:
|
|
114
|
+
try:
|
|
115
|
+
return float(x.strip())
|
|
116
|
+
except ValueError:
|
|
117
|
+
return None
|
|
118
|
+
f = [c for c in line.split(",")]
|
|
119
|
+
mem_used = _num(f[2]) if len(f) > 2 else None
|
|
120
|
+
if mem_used is None: # unified-memory GPU (GB10): global memory.used reads [N/A] →
|
|
121
|
+
mem_used = _nvidia_compute_apps_mem_mb() # sum per-process GPU memory instead
|
|
122
|
+
return {
|
|
123
|
+
"temp_c": _num(f[0]) if len(f) > 0 else None,
|
|
124
|
+
"util_pct": _num(f[1]) if len(f) > 1 else None,
|
|
125
|
+
"mem_used_mb": mem_used,
|
|
126
|
+
"mem_total_mb": _num(f[3]) if len(f) > 3 else None,
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _nvidia_compute_apps_mem_mb() -> float | None:
|
|
131
|
+
"""Sum per-process GPU memory (MiB) from `nvidia-smi --query-compute-apps`. Works on
|
|
132
|
+
unified-memory GPUs (GB10) where the global memory.used query returns [N/A]. None if
|
|
133
|
+
nvidia-smi is absent or no compute apps are running."""
|
|
134
|
+
if not shutil.which("nvidia-smi"):
|
|
135
|
+
return None
|
|
136
|
+
try:
|
|
137
|
+
out = subprocess.run(
|
|
138
|
+
["nvidia-smi", "--query-compute-apps=used_memory",
|
|
139
|
+
"--format=csv,noheader,nounits"],
|
|
140
|
+
capture_output=True, text=True, timeout=5)
|
|
141
|
+
except (subprocess.SubprocessError, OSError):
|
|
142
|
+
return None
|
|
143
|
+
total, found = 0.0, False
|
|
144
|
+
for ln in out.stdout.splitlines():
|
|
145
|
+
try:
|
|
146
|
+
total += float(ln.strip())
|
|
147
|
+
found = True
|
|
148
|
+
except ValueError:
|
|
149
|
+
continue
|
|
150
|
+
return round(total, 1) if found else None
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _tegrastats_temp() -> float | None:
|
|
154
|
+
"""Max temp from a single tegrastats line (Tegra SoCs: GB10/Jetson). None if absent.
|
|
155
|
+
|
|
156
|
+
tegrastats streams forever, so we read one line with a timeout and parse ``<name>@<temp>C``
|
|
157
|
+
tokens (e.g. ``cpu@61.5C gpu@59C``)."""
|
|
158
|
+
if not shutil.which("tegrastats"):
|
|
159
|
+
return None
|
|
160
|
+
try:
|
|
161
|
+
out = subprocess.run(["tegrastats", "--interval", "100"],
|
|
162
|
+
capture_output=True, text=True, timeout=4)
|
|
163
|
+
line = out.stdout.strip().splitlines()[0] if out.stdout.strip() else ""
|
|
164
|
+
except (subprocess.SubprocessError, OSError):
|
|
165
|
+
return None
|
|
166
|
+
temps = [float(m) for m in re.findall(r"@(\d+(?:\.\d+)?)C", line)]
|
|
167
|
+
return round(max(temps), 1) if temps else None
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def sample() -> dict[str, Any]:
|
|
171
|
+
"""One cheap snapshot of CPU / memory / GPU / temperature (all best-effort)."""
|
|
172
|
+
mem_used_gb, mem_total_gb = _read_mem()
|
|
173
|
+
gpu = _nvidia_smi()
|
|
174
|
+
gpu_temp = gpu.get("temp_c") if gpu else None
|
|
175
|
+
cpu_zone_temp = _read_thermal_zones()
|
|
176
|
+
tegra_temp = _tegrastats_temp()
|
|
177
|
+
temps = [t for t in (gpu_temp, cpu_zone_temp, tegra_temp) if t is not None]
|
|
178
|
+
return {
|
|
179
|
+
"cpu_load1": _read_cpu_load(),
|
|
180
|
+
"cpu_count": os.cpu_count(),
|
|
181
|
+
"mem_used_gb": mem_used_gb,
|
|
182
|
+
"mem_total_gb": mem_total_gb,
|
|
183
|
+
"mem_pct": (round(mem_used_gb / mem_total_gb * 100, 1)
|
|
184
|
+
if mem_used_gb is not None and mem_total_gb else None),
|
|
185
|
+
"gpu_util_pct": gpu.get("util_pct") if gpu else None,
|
|
186
|
+
"gpu_mem_used_mb": gpu.get("mem_used_mb") if gpu else None,
|
|
187
|
+
"gpu_mem_total_mb": gpu.get("mem_total_mb") if gpu else None,
|
|
188
|
+
"temp_c": round(max(temps), 1) if temps else None,
|
|
189
|
+
"temp_gpu_c": gpu_temp,
|
|
190
|
+
"temp_cpu_c": cpu_zone_temp if cpu_zone_temp is not None else tegra_temp,
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class SystemMonitor:
|
|
195
|
+
"""Latest cached sample + thermal state (with hysteresis) + a background sampling loop.
|
|
196
|
+
|
|
197
|
+
Thermal state transitions (hysteresis so it doesn't flap at the boundary):
|
|
198
|
+
``ok`` → ``warn`` at ``warn_c`` → ``critical`` at ``critical_c``; once ``critical`` it
|
|
199
|
+
stays critical until the temp falls back **below warn_c**, then clears to ``ok``.
|
|
200
|
+
"""
|
|
201
|
+
|
|
202
|
+
def __init__(self, *, interval: float = 10.0, warn_c: float = 80.0,
|
|
203
|
+
critical_c: float = 90.0, guard: bool = True) -> None:
|
|
204
|
+
self.interval = max(2.0, float(interval))
|
|
205
|
+
self.warn_c = float(warn_c)
|
|
206
|
+
self.critical_c = float(critical_c)
|
|
207
|
+
self.guard = bool(guard)
|
|
208
|
+
self._latest: dict[str, Any] = {}
|
|
209
|
+
self._state = "ok"
|
|
210
|
+
self._task: asyncio.Task | None = None
|
|
211
|
+
|
|
212
|
+
def _update_state(self, temp: float | None) -> None:
|
|
213
|
+
if temp is None:
|
|
214
|
+
return # temp unreadable → keep prior state, never falsely guard
|
|
215
|
+
if temp >= self.critical_c:
|
|
216
|
+
self._state = "critical"
|
|
217
|
+
elif temp >= self.warn_c:
|
|
218
|
+
self._state = "critical" if self._state == "critical" else "warn"
|
|
219
|
+
else:
|
|
220
|
+
self._state = "ok"
|
|
221
|
+
|
|
222
|
+
def refresh(self) -> dict[str, Any]:
|
|
223
|
+
s = sample()
|
|
224
|
+
s["ts"] = time.time() # so the footer can show staleness if sampling stalls
|
|
225
|
+
self._update_state(s.get("temp_c"))
|
|
226
|
+
s["thermal_state"] = self._state
|
|
227
|
+
self._latest = s
|
|
228
|
+
return s
|
|
229
|
+
|
|
230
|
+
def snapshot(self) -> dict[str, Any]:
|
|
231
|
+
out = dict(self._latest)
|
|
232
|
+
out.setdefault("thermal_state", self._state)
|
|
233
|
+
out["thresholds"] = {
|
|
234
|
+
"warn_c": self.warn_c, "critical_c": self.critical_c,
|
|
235
|
+
"guard": self.guard, "interval": self.interval,
|
|
236
|
+
}
|
|
237
|
+
return out
|
|
238
|
+
|
|
239
|
+
@property
|
|
240
|
+
def latest_temp(self) -> float | None:
|
|
241
|
+
return self._latest.get("temp_c")
|
|
242
|
+
|
|
243
|
+
@property
|
|
244
|
+
def overheated(self) -> bool:
|
|
245
|
+
"""True when the guard is on AND the box is in the critical thermal state."""
|
|
246
|
+
return self.guard and self._state == "critical"
|
|
247
|
+
|
|
248
|
+
async def _loop(self) -> None:
|
|
249
|
+
while True:
|
|
250
|
+
try:
|
|
251
|
+
await asyncio.to_thread(self.refresh)
|
|
252
|
+
if self._state == "critical":
|
|
253
|
+
logger.warning(
|
|
254
|
+
"system monitor: thermal CRITICAL ({}°C ≥ {}°C) — shedding new "
|
|
255
|
+
"STT/TTS requests until it cools below {}°C",
|
|
256
|
+
self.latest_temp, self.critical_c, self.warn_c)
|
|
257
|
+
except Exception as exc: # never let a sampling hiccup kill the loop
|
|
258
|
+
logger.debug("system monitor sample failed: {}", exc)
|
|
259
|
+
await asyncio.sleep(self.interval)
|
|
260
|
+
|
|
261
|
+
async def start(self) -> None:
|
|
262
|
+
try: # prime one sample so the first footer poll has data
|
|
263
|
+
await asyncio.to_thread(self.refresh)
|
|
264
|
+
except Exception as exc:
|
|
265
|
+
logger.debug("system monitor initial sample failed: {}", exc)
|
|
266
|
+
self._task = asyncio.create_task(self._loop())
|
|
267
|
+
|
|
268
|
+
async def stop(self) -> None:
|
|
269
|
+
if self._task is not None:
|
|
270
|
+
self._task.cancel()
|
|
271
|
+
try:
|
|
272
|
+
await self._task
|
|
273
|
+
except asyncio.CancelledError:
|
|
274
|
+
pass
|
|
275
|
+
except Exception: # pragma: no cover
|
|
276
|
+
pass
|
|
277
|
+
self._task = None
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def thermal_guard(request: Request) -> None:
|
|
281
|
+
"""FastAPI dependency: reject a new STT/TTS request with 503 while the box is in the
|
|
282
|
+
critical thermal state (the guard) so it can cool instead of overheating into a hang.
|
|
283
|
+
In-flight requests are never interrupted; new ones resume once temp < warn_c."""
|
|
284
|
+
mon: SystemMonitor | None = getattr(request.app.state, "system_monitor", None)
|
|
285
|
+
if mon is not None and mon.overheated:
|
|
286
|
+
raise HTTPException(
|
|
287
|
+
status_code=503,
|
|
288
|
+
detail=(f"Server cooling down (temperature {mon.latest_temp}°C ≥ "
|
|
289
|
+
f"{mon.critical_c}°C); please retry shortly."),
|
|
290
|
+
)
|
|
@@ -3297,3 +3297,60 @@ async function init() {
|
|
|
3297
3297
|
}
|
|
3298
3298
|
|
|
3299
3299
|
init().catch((err) => setOutput(`Init failed: ${err.message}`));
|
|
3300
|
+
|
|
3301
|
+
|
|
3302
|
+
// ── System monitor footer ────────────────────────────────────────────────
|
|
3303
|
+
// Polls /v1/system on a fixed interval and renders CPU / memory / GPU / temperature
|
|
3304
|
+
// in the bottom bar, colour-coded by thermal state (ok/warn/critical). On a critical
|
|
3305
|
+
// (overheat) state the server's thermal guard sheds new STT/TTS requests; the bar says so.
|
|
3306
|
+
// If the backend is unreachable the bar hides itself rather than showing stale numbers
|
|
3307
|
+
// (keeps the footer honest about backend state).
|
|
3308
|
+
function _sysmonNum(v, digits) {
|
|
3309
|
+
return (v === null || v === undefined) ? "—" : Number(v).toFixed(digits);
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3312
|
+
let _sysmonMs = 10000; // poll cadence — synced to the server's metrics_interval each poll
|
|
3313
|
+
|
|
3314
|
+
async function refreshSysmon() {
|
|
3315
|
+
const bar = document.getElementById("sysmon-bar");
|
|
3316
|
+
if (!bar) return;
|
|
3317
|
+
try {
|
|
3318
|
+
const d = await fetchJson("/v1/system");
|
|
3319
|
+
if (!d || d.available === false) { bar.hidden = true; return; }
|
|
3320
|
+
if (d.thresholds && d.thresholds.interval)
|
|
3321
|
+
_sysmonMs = Math.max(2000, d.thresholds.interval * 1000);
|
|
3322
|
+
const state = d.thermal_state || "ok";
|
|
3323
|
+
bar.className = "sysmon-bar sysmon-" + state;
|
|
3324
|
+
const parts = [];
|
|
3325
|
+
if (d.temp_c != null) parts.push(`🌡 ${_sysmonNum(d.temp_c, 1)}°C`);
|
|
3326
|
+
if (d.cpu_load1 != null) parts.push(`CPU ${_sysmonNum(d.cpu_load1, 2)}${d.cpu_count ? " / " + d.cpu_count : ""}`);
|
|
3327
|
+
if (d.mem_pct != null) {
|
|
3328
|
+
const detail = (d.mem_used_gb != null && d.mem_total_gb != null)
|
|
3329
|
+
? ` (${_sysmonNum(d.mem_used_gb, 1)}/${_sysmonNum(d.mem_total_gb, 0)}G)` : "";
|
|
3330
|
+
parts.push(`内存 ${_sysmonNum(d.mem_pct, 0)}%${detail}`);
|
|
3331
|
+
}
|
|
3332
|
+
if (d.gpu_util_pct != null) parts.push(`GPU ${_sysmonNum(d.gpu_util_pct, 0)}%`);
|
|
3333
|
+
if (d.gpu_mem_used_mb != null) {
|
|
3334
|
+
const usedG = _sysmonNum(d.gpu_mem_used_mb / 1024, 1);
|
|
3335
|
+
// total is N/A on unified-memory GPUs (GB10) → show used only
|
|
3336
|
+
parts.push(d.gpu_mem_total_mb != null
|
|
3337
|
+
? `显存 ${usedG}/${_sysmonNum(d.gpu_mem_total_mb / 1024, 0)}G`
|
|
3338
|
+
: `显存 ${usedG}G`);
|
|
3339
|
+
}
|
|
3340
|
+
let text = parts.join(" · ") || "系统监控";
|
|
3341
|
+
if (state === "critical") text += " · ⚠️ 降温中:已暂停接收新请求";
|
|
3342
|
+
else if (state === "warn") text += " · ⚠️ 偏热";
|
|
3343
|
+
bar.innerHTML = '<span class="sysmon-dot"></span>' + text;
|
|
3344
|
+
bar.hidden = false;
|
|
3345
|
+
} catch (_) {
|
|
3346
|
+
bar.hidden = true; // backend down → hide, don't show stale readings
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3350
|
+
// Self-rescheduling poll at the server's metrics_interval (so `server.metrics_interval: 3`
|
|
3351
|
+
// makes the footer refresh every 3s). setTimeout (not setInterval) so the cadence can follow
|
|
3352
|
+
// config changes and never overlaps a slow request.
|
|
3353
|
+
function _sysmonLoop() {
|
|
3354
|
+
refreshSysmon().finally(() => setTimeout(_sysmonLoop, _sysmonMs));
|
|
3355
|
+
}
|
|
3356
|
+
_sysmonLoop();
|
|
@@ -242,6 +242,9 @@
|
|
|
242
242
|
</div>
|
|
243
243
|
</div>
|
|
244
244
|
|
|
245
|
+
<!-- System monitor: CPU/mem/GPU/temperature + thermal-guard state (filled by app.js) -->
|
|
246
|
+
<footer id="sysmon-bar" class="sysmon-bar" hidden></footer>
|
|
247
|
+
|
|
245
248
|
<script src="/ui/app.js" defer></script>
|
|
246
249
|
</body>
|
|
247
250
|
</html>
|
|
@@ -648,3 +648,27 @@ button.filter-chip.active { background: var(--accent); color: #fff; border-color
|
|
|
648
648
|
box-shadow: 0 8px 32px rgba(0,0,0,.15);
|
|
649
649
|
}
|
|
650
650
|
#config-add-dialog label { display: block; margin-bottom: .8rem; }
|
|
651
|
+
|
|
652
|
+
/* ── System monitor footer (CPU / mem / GPU / temperature + thermal guard) ── */
|
|
653
|
+
body { padding-bottom: 34px; } /* room for the fixed status bar */
|
|
654
|
+
.sysmon-bar {
|
|
655
|
+
position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
|
|
656
|
+
display: flex; align-items: center; gap: 8px;
|
|
657
|
+
padding: 5px 14px; font-size: .78rem; line-height: 1.2;
|
|
658
|
+
background: var(--bg-2, #ece8de);
|
|
659
|
+
border-top: 1px solid var(--line, rgba(31, 42, 31, .16));
|
|
660
|
+
color: var(--ink-soft, #4f5b4f);
|
|
661
|
+
font-variant-numeric: tabular-nums;
|
|
662
|
+
}
|
|
663
|
+
.sysmon-dot {
|
|
664
|
+
width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
|
|
665
|
+
background: var(--accent, #0d7c5a);
|
|
666
|
+
}
|
|
667
|
+
.sysmon-warn { color: #8a5a00; }
|
|
668
|
+
.sysmon-warn .sysmon-dot { background: #d99800; }
|
|
669
|
+
.sysmon-critical {
|
|
670
|
+
color: #fff; font-weight: 600;
|
|
671
|
+
background: var(--danger, #b0352f);
|
|
672
|
+
border-top-color: var(--danger, #b0352f);
|
|
673
|
+
}
|
|
674
|
+
.sysmon-critical .sysmon-dot { background: #fff; }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/executors/in_process.py
RENAMED
|
File without changes
|
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/dispatch/executors/subprocess_exec.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/backends/__init__.py
RENAMED
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/backends/docker_backend.py
RENAMED
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/backends/native_backend.py
RENAMED
|
File without changes
|
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/__init__.py
RENAMED
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/faster_whisper.py
RENAMED
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/fish_speech.py
RENAMED
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/sherpa_onnx.py
RENAMED
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/whisper.py
RENAMED
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/local_engines/engines/whisperlivekit.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/canary_qwen_stt.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/mlx_whisper_stt.py
RENAMED
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/mms_languages.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/parakeet_mlx_stt.py
RENAMED
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/openspeechapi/providers/stt/phi4_multimodal_stt.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/faster-whisper/native/install.sh
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openspeechapi-0.2.16 → openspeechapi-0.2.18}/scripts/engines/whisperlivekit/native/install.sh
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|