openspeechapi 0.5.0__tar.gz → 0.6.0__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.5.0 → openspeechapi-0.6.0}/.gitignore +6 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/PKG-INFO +24 -6
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/README.md +23 -5
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/cli.py +7 -1
- openspeechapi-0.6.0/openspeechapi/client/client.py +348 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/config.py +25 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/core/enums.py +23 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/core/models.py +5 -0
- openspeechapi-0.6.0/openspeechapi/core/realtime.py +179 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/dispatcher.py +44 -20
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/executors/subprocess_exec.py +25 -2
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/filters.py +27 -3
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/lifecycle.py +23 -17
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/engine_registry.yaml +23 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/factory.py +11 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/aim_resolver.py +53 -4
- openspeechapi-0.6.0/openspeechapi/providers/realtime/__init__.py +1 -0
- openspeechapi-0.6.0/openspeechapi/providers/realtime/openai_realtime.py +48 -0
- openspeechapi-0.6.0/openspeechapi/providers/realtime/qwen_omni_realtime.py +70 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/deepgram.py +31 -16
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/elevenlabs.py +19 -12
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/gemma4.py +126 -23
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/openai.py +8 -2
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/qwen3_omni_stt.py +7 -15
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/sherpa_onnx.py +15 -16
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/vosk_stt.py +10 -4
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/whisperlivekit.py +40 -42
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/alibaba.py +7 -6
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/azure_speech.py +7 -6
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/baidu.py +2 -2
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/cosyvoice3.py +1 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/deepgram.py +20 -7
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/elevenlabs.py +40 -6
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/fish_speech.py +3 -3
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/google_cloud.py +4 -3
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/iflytek.py +25 -19
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/openai.py +51 -17
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/tencent.py +2 -2
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/volcengine.py +2 -2
- openspeechapi-0.6.0/openspeechapi/runtime_environment.py +165 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/app.py +26 -4
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/auth.py +1 -1
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/extras_installer.py +5 -3
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/model_downloads.py +167 -9
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/routes/config.py +20 -1
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/routes/engine_catalog.py +10 -6
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/routes/models.py +30 -1
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/routes/stt.py +98 -16
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/routes/tts.py +65 -5
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/routes/webui.py +8 -1
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/services/config_io.py +55 -25
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/webui/app.js +771 -46
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/webui/index.html +81 -15
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/webui/styles.css +158 -8
- openspeechapi-0.6.0/openspeechapi/server/ws/auth.py +47 -0
- openspeechapi-0.6.0/openspeechapi/server/ws/realtime_stream.py +158 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/ws/stt_stream.py +131 -100
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/ws/tts_stream.py +95 -39
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/utils/audio_converter.py +3 -2
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/providers.example.yaml +14 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/pyproject.toml +1 -1
- openspeechapi-0.5.0/openspeechapi/client/client.py +0 -145
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/__main__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/client/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/core/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/core/base.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/core/model_hub.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/core/model_presence.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/core/model_profile.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/core/registry.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/core/settings.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/core/voice_presets.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/demo.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/aim_provision.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/context.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/executors/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/executors/base.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/executors/in_process.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/executors/remote.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/fanout.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/dispatch/watcher.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/engine_catalog.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/exceptions.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/backends/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/backends/docker_backend.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/backends/native_backend.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/base.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/cosyvoice_venv.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/engines/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/engines/faster_whisper.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/engines/fish_speech.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/engines/sherpa_onnx.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/engines/whisper.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/engines/whisperlivekit.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/fish_venv.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/gemma4_server.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/indextts_venv.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/isolated_venv.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/manager.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/models.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/progress.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/registry.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/spark_venv.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/task_store.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/tasks.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/venv_common.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/vllm_gb10_patch.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/local_engines/vllm_venv.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/logging_config.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/observe/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/observe/base.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/observe/debug.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/observe/latency.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/observe/metrics.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/observe/tracing.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/observe/usage.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/_template.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/_local_audio.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/alibaba.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/assemblyai.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/azure_speech.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/baidu.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/canary_qwen_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/dolphin_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/faster_whisper.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/fireredasr_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/funasr_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/google_cloud.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/iflytek.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/kimi_audio_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/macos_speech.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/mlx_whisper_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/mms_languages.json +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/mms_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/moonshine_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/paraformer.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/parakeet_mlx_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/phi4_multimodal_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/qwen3_asr.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/sensevoice.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/tencent.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/volcengine.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/voxtral_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/wenet_stt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/whisper.py +6 -6
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/stt/windows_speech.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/chatterbox.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/coqui.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/cosyvoice.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/f5_tts.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/indextts.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/kokoro.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/macos_say.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/minimax.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/piper.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/spark.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/providers/tts/windows_sapi.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/middleware.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/native_installer.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/routes/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/routes/chat.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/routes/engine_services.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/routes/engines.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/services/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/services/model_provision.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/system_metrics.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/server/ws/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/telemetry/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/telemetry/perf.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/utils/__init__.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/utils/audio_playback.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/openspeechapi/vendor_registry.yaml +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/aim_adopt.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/aim_consumers.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/engines/cloud/install.sh +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/engines/faster-whisper/native/install.sh +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/engines/fish-speech/native/install.sh +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/engines/macos-stt/_bundle.sh +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/engines/macos-stt/install.sh +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/engines/macos-stt/macos_stt.swift +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/engines/macos-stt/request_auth.swift +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/engines/sherpa-onnx/native/install.sh +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/engines/sherpa-onnx/native/run_streaming_server.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/engines/whisper/native/install.sh +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/engines/whisperlivekit/native/install.sh +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/gen_mms_languages.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/preload_stt_model.py +0 -0
- {openspeechapi-0.5.0 → openspeechapi-0.6.0}/scripts/release.sh +0 -0
|
@@ -22,9 +22,15 @@ scripts/engines/macos-stt/Info.plist
|
|
|
22
22
|
|
|
23
23
|
# Runtime logs (structured JSONL + server stdio captures)
|
|
24
24
|
logs/
|
|
25
|
+
log/
|
|
26
|
+
serve.log
|
|
27
|
+
serve-deploy.log
|
|
25
28
|
server_err.log
|
|
26
29
|
server_stdout.log
|
|
27
30
|
server_stderr.log
|
|
28
31
|
|
|
32
|
+
# Local runtime state (download/task persistence)
|
|
33
|
+
.openspeech/
|
|
34
|
+
|
|
29
35
|
# Claude Code project-local config
|
|
30
36
|
.claude/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openspeechapi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Unified speech interface for STT/TTS providers
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Requires-Dist: httpx>=0.27
|
|
@@ -211,6 +211,12 @@ cd OpenSpeechAPI
|
|
|
211
211
|
uv venv && uv pip install -e ".[server,dev]" # 或 pip install -e ".[server,dev]";按需换 .[all] 等
|
|
212
212
|
```
|
|
213
213
|
|
|
214
|
+
源码 checkout 的标准共享运行环境是项目根目录 `.venv`。即使 shell 当前位于 Conda 或其他
|
|
215
|
+
Python 环境,`openspeechapi` CLI 也会一次性重新进入 `.venv`,确保主服务、普通 subprocess
|
|
216
|
+
Provider 和 Engine Catalog 依赖安装使用同一个解释器。确需保留当前解释器时可设置
|
|
217
|
+
`OSA_DISABLE_AUTO_VENV=1`。通过 PyPI/wheel 安装时没有项目 `.venv`,安装 OSA 的解释器就是
|
|
218
|
+
标准运行环境;声明 `isolated_venv` 的冲突 Provider 仍使用自己的 `~/AI/venvs/<provider>/`。
|
|
219
|
+
|
|
214
220
|
> ⚠️ 纯 `pip install openspeechapi`(核心库)**不含 fastapi/uvicorn**,无法 `serve`;起服务请带 `[server]`。
|
|
215
221
|
> 两种方式启动服务的差异见下方 [启动服务](#启动服务)。
|
|
216
222
|
|
|
@@ -1040,19 +1046,24 @@ server:
|
|
|
1040
1046
|
curl -H "Authorization: Bearer your-key" http://localhost:8600/v1/providers
|
|
1041
1047
|
```
|
|
1042
1048
|
|
|
1043
|
-
WebSocket
|
|
1044
|
-
```
|
|
1045
|
-
|
|
1049
|
+
WebSocket 建连后先发送认证帧,再发送业务数据:
|
|
1050
|
+
```json
|
|
1051
|
+
{"type": "auth", "token": "your-key"}
|
|
1046
1052
|
```
|
|
1047
1053
|
|
|
1048
|
-
|
|
1054
|
+
为兼容旧客户端仍接受 `?token=`,但不建议使用,因为 URL 可能进入代理或访问日志。Web UI
|
|
1055
|
+
可在顶部 API Key 输入框保存 token;Python Client 使用
|
|
1056
|
+
`Client("http://localhost:8600", api_key="your-key")`。
|
|
1057
|
+
|
|
1058
|
+
`/v1/health` 与 `/v1/auth/status` 端点免认证。不配置 `server.auth` 则无认证(开发模式)。
|
|
1059
|
+
当 `auth.enabled: true` 时必须至少配置一个非空 key,否则服务拒绝启动,避免误以为已启用认证。
|
|
1049
1060
|
|
|
1050
1061
|
## 流式 STT
|
|
1051
1062
|
|
|
1052
1063
|
Deepgram 支持实时流式转录:
|
|
1053
1064
|
|
|
1054
1065
|
```python
|
|
1055
|
-
async with Client("http://localhost:8600") as c:
|
|
1066
|
+
async with Client("http://localhost:8600", api_key="your-key") as c:
|
|
1056
1067
|
async def audio_source():
|
|
1057
1068
|
# 从麦克风或文件读取 PCM 音频块
|
|
1058
1069
|
yield pcm_chunk
|
|
@@ -1061,6 +1072,13 @@ async with Client("http://localhost:8600") as c:
|
|
|
1061
1072
|
print(transcription.text)
|
|
1062
1073
|
```
|
|
1063
1074
|
|
|
1075
|
+
TTS 同样支持 WebSocket 流式返回:
|
|
1076
|
+
```python
|
|
1077
|
+
async with Client("http://localhost:8600", api_key="your-key") as c:
|
|
1078
|
+
async for chunk in c.tts.synthesize_stream("elevenlabs_tts", "Hello"):
|
|
1079
|
+
play_or_store(chunk.data)
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1064
1082
|
WebSocket 方式:
|
|
1065
1083
|
```
|
|
1066
1084
|
ws://localhost:8600/v1/stt/stream?provider=deepgram
|
|
@@ -23,6 +23,12 @@ cd OpenSpeechAPI
|
|
|
23
23
|
uv venv && uv pip install -e ".[server,dev]" # 或 pip install -e ".[server,dev]";按需换 .[all] 等
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
源码 checkout 的标准共享运行环境是项目根目录 `.venv`。即使 shell 当前位于 Conda 或其他
|
|
27
|
+
Python 环境,`openspeechapi` CLI 也会一次性重新进入 `.venv`,确保主服务、普通 subprocess
|
|
28
|
+
Provider 和 Engine Catalog 依赖安装使用同一个解释器。确需保留当前解释器时可设置
|
|
29
|
+
`OSA_DISABLE_AUTO_VENV=1`。通过 PyPI/wheel 安装时没有项目 `.venv`,安装 OSA 的解释器就是
|
|
30
|
+
标准运行环境;声明 `isolated_venv` 的冲突 Provider 仍使用自己的 `~/AI/venvs/<provider>/`。
|
|
31
|
+
|
|
26
32
|
> ⚠️ 纯 `pip install openspeechapi`(核心库)**不含 fastapi/uvicorn**,无法 `serve`;起服务请带 `[server]`。
|
|
27
33
|
> 两种方式启动服务的差异见下方 [启动服务](#启动服务)。
|
|
28
34
|
|
|
@@ -852,19 +858,24 @@ server:
|
|
|
852
858
|
curl -H "Authorization: Bearer your-key" http://localhost:8600/v1/providers
|
|
853
859
|
```
|
|
854
860
|
|
|
855
|
-
WebSocket
|
|
856
|
-
```
|
|
857
|
-
|
|
861
|
+
WebSocket 建连后先发送认证帧,再发送业务数据:
|
|
862
|
+
```json
|
|
863
|
+
{"type": "auth", "token": "your-key"}
|
|
858
864
|
```
|
|
859
865
|
|
|
860
|
-
|
|
866
|
+
为兼容旧客户端仍接受 `?token=`,但不建议使用,因为 URL 可能进入代理或访问日志。Web UI
|
|
867
|
+
可在顶部 API Key 输入框保存 token;Python Client 使用
|
|
868
|
+
`Client("http://localhost:8600", api_key="your-key")`。
|
|
869
|
+
|
|
870
|
+
`/v1/health` 与 `/v1/auth/status` 端点免认证。不配置 `server.auth` 则无认证(开发模式)。
|
|
871
|
+
当 `auth.enabled: true` 时必须至少配置一个非空 key,否则服务拒绝启动,避免误以为已启用认证。
|
|
861
872
|
|
|
862
873
|
## 流式 STT
|
|
863
874
|
|
|
864
875
|
Deepgram 支持实时流式转录:
|
|
865
876
|
|
|
866
877
|
```python
|
|
867
|
-
async with Client("http://localhost:8600") as c:
|
|
878
|
+
async with Client("http://localhost:8600", api_key="your-key") as c:
|
|
868
879
|
async def audio_source():
|
|
869
880
|
# 从麦克风或文件读取 PCM 音频块
|
|
870
881
|
yield pcm_chunk
|
|
@@ -873,6 +884,13 @@ async with Client("http://localhost:8600") as c:
|
|
|
873
884
|
print(transcription.text)
|
|
874
885
|
```
|
|
875
886
|
|
|
887
|
+
TTS 同样支持 WebSocket 流式返回:
|
|
888
|
+
```python
|
|
889
|
+
async with Client("http://localhost:8600", api_key="your-key") as c:
|
|
890
|
+
async for chunk in c.tts.synthesize_stream("elevenlabs_tts", "Hello"):
|
|
891
|
+
play_or_store(chunk.data)
|
|
892
|
+
```
|
|
893
|
+
|
|
876
894
|
WebSocket 方式:
|
|
877
895
|
```
|
|
878
896
|
ws://localhost:8600/v1/stt/stream?provider=deepgram
|
|
@@ -9,6 +9,7 @@ from openspeechapi.exceptions import ConfigError
|
|
|
9
9
|
from openspeechapi.local_engines import EngineAction, EngineManager, RuntimeConfig
|
|
10
10
|
from openspeechapi.local_engines.models import TaskStatus
|
|
11
11
|
from openspeechapi.logging_config import configure_logging
|
|
12
|
+
from openspeechapi.runtime_environment import reexec_into_canonical_runtime
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
def _cmd_list(args: argparse.Namespace) -> None:
|
|
@@ -431,6 +432,11 @@ def _apply_logging_args(args: argparse.Namespace) -> None:
|
|
|
431
432
|
|
|
432
433
|
def main(argv: list[str] | None = None) -> None:
|
|
433
434
|
_load_dotenv()
|
|
435
|
+
# Source checkouts have one canonical shared environment at ``.venv``. Switch
|
|
436
|
+
# before parsing/importing command-specific modules so installs and workers do
|
|
437
|
+
# not accidentally inherit an unrelated shell/Conda interpreter.
|
|
438
|
+
effective_argv = list(argv) if argv is not None else sys.argv[1:]
|
|
439
|
+
reexec_into_canonical_runtime(effective_argv)
|
|
434
440
|
parser = argparse.ArgumentParser(prog="openspeechapi", description="OpenSpeechAPI CLI")
|
|
435
441
|
parser.add_argument(
|
|
436
442
|
"--config", default=None,
|
|
@@ -573,7 +579,7 @@ def main(argv: list[str] | None = None) -> None:
|
|
|
573
579
|
adopt_p.add_argument("--repo", action="append", default=[], help="Specific repo id (repeatable)")
|
|
574
580
|
adopt_p.add_argument("--dry-run", action="store_true", help="Preview only (no changes)")
|
|
575
581
|
|
|
576
|
-
args = parser.parse_args(
|
|
582
|
+
args = parser.parse_args(effective_argv)
|
|
577
583
|
_apply_logging_args(args)
|
|
578
584
|
if args.command is None:
|
|
579
585
|
parser.print_help()
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
"""Python thin client for OpenSpeechAPI HTTP/WebSocket server."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import asyncio
|
|
5
|
+
import base64
|
|
6
|
+
import json
|
|
7
|
+
from typing import Any
|
|
8
|
+
from urllib.parse import urlencode, urlparse, urlunparse
|
|
9
|
+
|
|
10
|
+
import httpx
|
|
11
|
+
|
|
12
|
+
from openspeechapi.core.enums import AudioFormat, audio_format_value
|
|
13
|
+
from openspeechapi.core.models import (
|
|
14
|
+
AudioChunk,
|
|
15
|
+
AudioData,
|
|
16
|
+
STTOptions,
|
|
17
|
+
TTSOptions,
|
|
18
|
+
Transcription,
|
|
19
|
+
Word,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class _ClientSTT:
|
|
24
|
+
def __init__(self, client: "Client") -> None:
|
|
25
|
+
self._client = client
|
|
26
|
+
|
|
27
|
+
async def transcribe(
|
|
28
|
+
self, provider: str, audio: AudioData, opts: STTOptions | None = None
|
|
29
|
+
) -> Transcription:
|
|
30
|
+
opts = opts or STTOptions()
|
|
31
|
+
data = {"provider": provider}
|
|
32
|
+
if opts.language:
|
|
33
|
+
data["language"] = opts.language
|
|
34
|
+
if opts.prompt:
|
|
35
|
+
data["prompt"] = opts.prompt
|
|
36
|
+
if opts.temperature is not None:
|
|
37
|
+
data["temperature"] = str(opts.temperature)
|
|
38
|
+
if opts.model:
|
|
39
|
+
data["model"] = opts.model
|
|
40
|
+
if opts.device:
|
|
41
|
+
data["device"] = opts.device
|
|
42
|
+
if opts.beam_size is not None:
|
|
43
|
+
data["beam_size"] = str(opts.beam_size)
|
|
44
|
+
if opts.compute_type:
|
|
45
|
+
data["compute_type"] = opts.compute_type
|
|
46
|
+
if opts.fp16 is not None:
|
|
47
|
+
data["fp16"] = str(bool(opts.fp16)).lower()
|
|
48
|
+
if opts.overrides:
|
|
49
|
+
data["params"] = json.dumps(opts.overrides)
|
|
50
|
+
data["sample_rate"] = str(audio.sample_rate)
|
|
51
|
+
data["channels"] = str(audio.channels)
|
|
52
|
+
data["audio_format"] = audio_format_value(audio.format)
|
|
53
|
+
|
|
54
|
+
files = {"audio": ("audio.wav", audio.data, "audio/wav")}
|
|
55
|
+
resp = await self._client._http.post(
|
|
56
|
+
f"{self._client._base_url}/v1/stt/transcribe",
|
|
57
|
+
data=data, files=files,
|
|
58
|
+
)
|
|
59
|
+
resp.raise_for_status()
|
|
60
|
+
j = resp.json()
|
|
61
|
+
|
|
62
|
+
words = None
|
|
63
|
+
if j.get("words"):
|
|
64
|
+
words = [Word(text=w["text"], start_ms=w["start_ms"], end_ms=w["end_ms"],
|
|
65
|
+
confidence=w.get("confidence")) for w in j["words"]]
|
|
66
|
+
|
|
67
|
+
return Transcription(
|
|
68
|
+
text=j["text"],
|
|
69
|
+
language=j.get("language"),
|
|
70
|
+
confidence=j.get("confidence"),
|
|
71
|
+
words=words,
|
|
72
|
+
duration_ms=j.get("duration_ms"),
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
async def fanout(
|
|
76
|
+
self, providers: list[str], audio: AudioData,
|
|
77
|
+
opts: STTOptions | None = None, strategy: str = "first_completed",
|
|
78
|
+
) -> Any:
|
|
79
|
+
opts = opts or STTOptions()
|
|
80
|
+
data = {
|
|
81
|
+
"providers": ",".join(providers),
|
|
82
|
+
"strategy": strategy,
|
|
83
|
+
}
|
|
84
|
+
if opts.language:
|
|
85
|
+
data["language"] = opts.language
|
|
86
|
+
if opts.prompt:
|
|
87
|
+
data["prompt"] = opts.prompt
|
|
88
|
+
if opts.temperature is not None:
|
|
89
|
+
data["temperature"] = str(opts.temperature)
|
|
90
|
+
if opts.model:
|
|
91
|
+
data["model"] = opts.model
|
|
92
|
+
if opts.device:
|
|
93
|
+
data["device"] = opts.device
|
|
94
|
+
if opts.beam_size is not None:
|
|
95
|
+
data["beam_size"] = str(opts.beam_size)
|
|
96
|
+
if opts.compute_type:
|
|
97
|
+
data["compute_type"] = opts.compute_type
|
|
98
|
+
if opts.fp16 is not None:
|
|
99
|
+
data["fp16"] = str(bool(opts.fp16)).lower()
|
|
100
|
+
if opts.overrides:
|
|
101
|
+
data["params"] = json.dumps(opts.overrides)
|
|
102
|
+
data["sample_rate"] = str(audio.sample_rate)
|
|
103
|
+
data["channels"] = str(audio.channels)
|
|
104
|
+
data["audio_format"] = audio_format_value(audio.format)
|
|
105
|
+
|
|
106
|
+
files = {"audio": ("audio.wav", audio.data, "audio/wav")}
|
|
107
|
+
resp = await self._client._http.post(
|
|
108
|
+
f"{self._client._base_url}/v1/stt/transcribe/fanout",
|
|
109
|
+
data=data, files=files,
|
|
110
|
+
)
|
|
111
|
+
resp.raise_for_status()
|
|
112
|
+
return resp.json()
|
|
113
|
+
|
|
114
|
+
async def transcribe_stream(
|
|
115
|
+
self,
|
|
116
|
+
provider: str,
|
|
117
|
+
stream,
|
|
118
|
+
opts: STTOptions | None = None,
|
|
119
|
+
):
|
|
120
|
+
"""Stream raw PCM chunks and yield partial/final ``Transcription`` snapshots."""
|
|
121
|
+
opts = opts or STTOptions()
|
|
122
|
+
params = {
|
|
123
|
+
"provider": provider,
|
|
124
|
+
"language": opts.language or "",
|
|
125
|
+
"sample_rate": opts.sample_rate or 16000,
|
|
126
|
+
}
|
|
127
|
+
if opts.overrides:
|
|
128
|
+
params["params"] = json.dumps(opts.overrides)
|
|
129
|
+
url = self._client._ws_url("/v1/stt/stream", params)
|
|
130
|
+
auth_enabled = await self._client._server_auth_enabled()
|
|
131
|
+
websockets = self._client._load_websockets()
|
|
132
|
+
|
|
133
|
+
async with websockets.connect(url) as ws:
|
|
134
|
+
if auth_enabled:
|
|
135
|
+
await ws.send(json.dumps({"type": "auth", "token": self._client._api_key or ""}))
|
|
136
|
+
|
|
137
|
+
async def _send_audio() -> None:
|
|
138
|
+
async for chunk in stream:
|
|
139
|
+
if chunk:
|
|
140
|
+
await ws.send(chunk)
|
|
141
|
+
await ws.send(json.dumps({"type": "stop"}))
|
|
142
|
+
|
|
143
|
+
sender = asyncio.create_task(_send_audio())
|
|
144
|
+
try:
|
|
145
|
+
async for raw in ws:
|
|
146
|
+
if isinstance(raw, bytes):
|
|
147
|
+
continue
|
|
148
|
+
message = json.loads(raw)
|
|
149
|
+
kind = message.get("type")
|
|
150
|
+
if kind in ("partial", "final"):
|
|
151
|
+
yield Transcription(
|
|
152
|
+
text=message.get("text", ""),
|
|
153
|
+
language=message.get("language"),
|
|
154
|
+
confidence=message.get("confidence"),
|
|
155
|
+
is_partial=kind == "partial",
|
|
156
|
+
)
|
|
157
|
+
elif kind == "error":
|
|
158
|
+
raise RuntimeError(message.get("detail") or message.get("message") or message)
|
|
159
|
+
elif kind == "closed":
|
|
160
|
+
break
|
|
161
|
+
finally:
|
|
162
|
+
if not sender.done():
|
|
163
|
+
sender.cancel()
|
|
164
|
+
try:
|
|
165
|
+
await sender
|
|
166
|
+
except asyncio.CancelledError:
|
|
167
|
+
pass
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class _ClientTTS:
|
|
171
|
+
def __init__(self, client: "Client") -> None:
|
|
172
|
+
self._client = client
|
|
173
|
+
|
|
174
|
+
async def synthesize(
|
|
175
|
+
self, provider: str, text: str, opts: TTSOptions | None = None
|
|
176
|
+
) -> AudioData:
|
|
177
|
+
opts = opts or TTSOptions()
|
|
178
|
+
body = {"text": text, "provider": provider}
|
|
179
|
+
if opts.voice:
|
|
180
|
+
body["voice"] = opts.voice
|
|
181
|
+
if opts.speed != 1.0:
|
|
182
|
+
body["speed"] = opts.speed
|
|
183
|
+
if opts.model:
|
|
184
|
+
body["model"] = opts.model
|
|
185
|
+
if opts.stream_transport:
|
|
186
|
+
body["stream_transport"] = opts.stream_transport
|
|
187
|
+
body["output_format"] = audio_format_value(opts.output_format)
|
|
188
|
+
if opts.reference_audio is not None:
|
|
189
|
+
body["reference_audio"] = (
|
|
190
|
+
base64.b64encode(opts.reference_audio).decode("ascii")
|
|
191
|
+
if isinstance(opts.reference_audio, bytes)
|
|
192
|
+
else opts.reference_audio
|
|
193
|
+
)
|
|
194
|
+
if opts.reference_text:
|
|
195
|
+
body["reference_text"] = opts.reference_text
|
|
196
|
+
if opts.language:
|
|
197
|
+
body["language"] = opts.language
|
|
198
|
+
if opts.overrides:
|
|
199
|
+
body["params"] = opts.overrides
|
|
200
|
+
|
|
201
|
+
resp = await self._client._http.post(
|
|
202
|
+
f"{self._client._base_url}/v1/tts/synthesize",
|
|
203
|
+
json=body,
|
|
204
|
+
)
|
|
205
|
+
resp.raise_for_status()
|
|
206
|
+
|
|
207
|
+
sample_rate = int(resp.headers.get("X-Sample-Rate", "16000"))
|
|
208
|
+
channels = int(resp.headers.get("X-Channels", "1"))
|
|
209
|
+
format_name = resp.headers.get("X-Audio-Format", "wav")
|
|
210
|
+
try:
|
|
211
|
+
audio_format = AudioFormat(format_name)
|
|
212
|
+
except ValueError:
|
|
213
|
+
audio_format = AudioFormat.WAV
|
|
214
|
+
return AudioData(
|
|
215
|
+
data=resp.content,
|
|
216
|
+
sample_rate=sample_rate,
|
|
217
|
+
channels=channels,
|
|
218
|
+
format=audio_format,
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
async def synthesize_stream(
|
|
222
|
+
self, provider: str, text: str, opts: TTSOptions | None = None
|
|
223
|
+
):
|
|
224
|
+
"""Yield audio chunks from the server's TTS WebSocket endpoint."""
|
|
225
|
+
opts = opts or TTSOptions()
|
|
226
|
+
reference_audio = opts.reference_audio
|
|
227
|
+
if isinstance(reference_audio, bytes):
|
|
228
|
+
reference_audio = base64.b64encode(reference_audio).decode("ascii")
|
|
229
|
+
payload = {
|
|
230
|
+
"provider": provider,
|
|
231
|
+
"text": text,
|
|
232
|
+
"voice": opts.voice,
|
|
233
|
+
"speed": opts.speed,
|
|
234
|
+
"model": opts.model,
|
|
235
|
+
"stream_transport": opts.stream_transport,
|
|
236
|
+
"output_format": audio_format_value(opts.output_format),
|
|
237
|
+
"reference_audio": reference_audio,
|
|
238
|
+
"reference_text": opts.reference_text,
|
|
239
|
+
"language": opts.language,
|
|
240
|
+
"params": opts.overrides,
|
|
241
|
+
}
|
|
242
|
+
auth_enabled = await self._client._server_auth_enabled()
|
|
243
|
+
websockets = self._client._load_websockets()
|
|
244
|
+
url = self._client._ws_url("/v1/tts/stream")
|
|
245
|
+
async with websockets.connect(url) as ws:
|
|
246
|
+
if auth_enabled:
|
|
247
|
+
await ws.send(json.dumps({"type": "auth", "token": self._client._api_key or ""}))
|
|
248
|
+
await ws.send(json.dumps(payload))
|
|
249
|
+
sequence = 0
|
|
250
|
+
metadata: dict[str, Any] = {}
|
|
251
|
+
async for raw in ws:
|
|
252
|
+
if isinstance(raw, bytes):
|
|
253
|
+
fmt = metadata.get("audio_format")
|
|
254
|
+
try:
|
|
255
|
+
audio_format = AudioFormat(fmt) if fmt else None
|
|
256
|
+
except ValueError:
|
|
257
|
+
audio_format = None
|
|
258
|
+
yield AudioChunk(
|
|
259
|
+
data=raw,
|
|
260
|
+
sequence=sequence,
|
|
261
|
+
format=audio_format,
|
|
262
|
+
sample_rate=metadata.get("sample_rate"),
|
|
263
|
+
channels=metadata.get("channels"),
|
|
264
|
+
)
|
|
265
|
+
sequence += 1
|
|
266
|
+
continue
|
|
267
|
+
message = json.loads(raw)
|
|
268
|
+
kind = message.get("type")
|
|
269
|
+
if kind == "meta":
|
|
270
|
+
metadata = message
|
|
271
|
+
elif kind == "error":
|
|
272
|
+
raise RuntimeError(message.get("detail") or message.get("message") or message)
|
|
273
|
+
elif kind == "done":
|
|
274
|
+
fmt = message.get("audio_format") or metadata.get("audio_format")
|
|
275
|
+
try:
|
|
276
|
+
audio_format = AudioFormat(fmt) if fmt else None
|
|
277
|
+
except ValueError:
|
|
278
|
+
audio_format = None
|
|
279
|
+
yield AudioChunk(
|
|
280
|
+
data=b"",
|
|
281
|
+
sequence=sequence,
|
|
282
|
+
is_final=True,
|
|
283
|
+
format=audio_format,
|
|
284
|
+
sample_rate=message.get("sample_rate") or metadata.get("sample_rate"),
|
|
285
|
+
channels=message.get("channels") or metadata.get("channels"),
|
|
286
|
+
)
|
|
287
|
+
break
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class Client:
|
|
291
|
+
"""OpenSpeechAPI HTTP client — same interface as ServiceDispatcher."""
|
|
292
|
+
|
|
293
|
+
def __init__(
|
|
294
|
+
self, base_url: str, timeout: float = 30.0, api_key: str | None = None
|
|
295
|
+
) -> None:
|
|
296
|
+
self._base_url = base_url.rstrip("/")
|
|
297
|
+
self._api_key = api_key
|
|
298
|
+
self._auth_enabled: bool | None = None
|
|
299
|
+
headers = {"Authorization": f"Bearer {api_key}"} if api_key else None
|
|
300
|
+
self._http = httpx.AsyncClient(timeout=timeout, headers=headers)
|
|
301
|
+
self.stt = _ClientSTT(self)
|
|
302
|
+
self.tts = _ClientTTS(self)
|
|
303
|
+
|
|
304
|
+
@staticmethod
|
|
305
|
+
def _load_websockets():
|
|
306
|
+
try:
|
|
307
|
+
import websockets
|
|
308
|
+
except ImportError as exc:
|
|
309
|
+
raise ImportError(
|
|
310
|
+
"Streaming client support requires websockets: pip install 'openspeechapi[server]'"
|
|
311
|
+
) from exc
|
|
312
|
+
return websockets
|
|
313
|
+
|
|
314
|
+
def _ws_url(self, path: str, params: dict[str, Any] | None = None) -> str:
|
|
315
|
+
parsed = urlparse(self._base_url)
|
|
316
|
+
scheme = "wss" if parsed.scheme == "https" else "ws"
|
|
317
|
+
query = urlencode(params or {})
|
|
318
|
+
return urlunparse((scheme, parsed.netloc, path, "", query, ""))
|
|
319
|
+
|
|
320
|
+
async def _server_auth_enabled(self) -> bool:
|
|
321
|
+
if self._auth_enabled is None:
|
|
322
|
+
response = await self._http.get(f"{self._base_url}/v1/auth/status")
|
|
323
|
+
response.raise_for_status()
|
|
324
|
+
self._auth_enabled = bool(response.json().get("enabled"))
|
|
325
|
+
return self._auth_enabled
|
|
326
|
+
|
|
327
|
+
async def close(self) -> None:
|
|
328
|
+
await self._http.aclose()
|
|
329
|
+
|
|
330
|
+
async def __aenter__(self) -> "Client":
|
|
331
|
+
return self
|
|
332
|
+
|
|
333
|
+
async def __aexit__(self, *args: Any) -> None:
|
|
334
|
+
await self.close()
|
|
335
|
+
|
|
336
|
+
async def list_engines(self) -> list[dict]:
|
|
337
|
+
resp = await self._http.get(f"{self._base_url}/v1/engines")
|
|
338
|
+
resp.raise_for_status()
|
|
339
|
+
return resp.json()["engines"]
|
|
340
|
+
|
|
341
|
+
# Backward compatibility alias
|
|
342
|
+
async def list_providers(self) -> list[dict]:
|
|
343
|
+
return await self.list_engines()
|
|
344
|
+
|
|
345
|
+
async def health(self) -> dict:
|
|
346
|
+
resp = await self._http.get(f"{self._base_url}/v1/health")
|
|
347
|
+
resp.raise_for_status()
|
|
348
|
+
return resp.json()
|
|
@@ -128,6 +128,15 @@ class ServerConfig:
|
|
|
128
128
|
# engines (cheap to reconnect) keep the shorter default. Only raises an inherited value — an
|
|
129
129
|
# explicit per-engine ``keepalive`` (incl. 0 = never unload) is respected. 0 disables.
|
|
130
130
|
keepalive_floor_local: int = 1800
|
|
131
|
+
# Request/resource ceilings. These are enforced at both REST and WebSocket boundaries.
|
|
132
|
+
max_stt_upload_bytes: int = 100 * 1024 * 1024
|
|
133
|
+
max_ws_audio_bytes: int = 100 * 1024 * 1024
|
|
134
|
+
max_tts_text_chars: int = 20_000
|
|
135
|
+
max_reference_audio_bytes: int = 25 * 1024 * 1024
|
|
136
|
+
max_stream_queue_chunks: int = 64
|
|
137
|
+
# Shared cloud-provider HTTP client ignores ambient HTTP(S)/ALL_PROXY by default. Enable only
|
|
138
|
+
# when the runtime has the corresponding proxy transport dependency (e.g. httpx[socks]).
|
|
139
|
+
http_trust_env: bool = False
|
|
131
140
|
|
|
132
141
|
|
|
133
142
|
@dataclass
|
|
@@ -285,6 +294,22 @@ def load_config(path: Path) -> OpenSpeechConfig:
|
|
|
285
294
|
0, int(srv.get("keepalive_floor_local", server_cfg.keepalive_floor_local)))
|
|
286
295
|
except (TypeError, ValueError):
|
|
287
296
|
pass
|
|
297
|
+
for field_name in (
|
|
298
|
+
"max_stt_upload_bytes",
|
|
299
|
+
"max_ws_audio_bytes",
|
|
300
|
+
"max_tts_text_chars",
|
|
301
|
+
"max_reference_audio_bytes",
|
|
302
|
+
"max_stream_queue_chunks",
|
|
303
|
+
):
|
|
304
|
+
try:
|
|
305
|
+
setattr(server_cfg, field_name, max(1, int(srv.get(
|
|
306
|
+
field_name, getattr(server_cfg, field_name)
|
|
307
|
+
))))
|
|
308
|
+
except (TypeError, ValueError):
|
|
309
|
+
pass
|
|
310
|
+
server_cfg.http_trust_env = bool(
|
|
311
|
+
srv.get("http_trust_env", server_cfg.http_trust_env)
|
|
312
|
+
)
|
|
288
313
|
auth = srv.get("auth", {})
|
|
289
314
|
if auth:
|
|
290
315
|
server_cfg.auth_enabled = bool(auth.get("enabled", False))
|
|
@@ -6,6 +6,7 @@ class ProviderType(str, Enum):
|
|
|
6
6
|
STT = "stt"
|
|
7
7
|
TTS = "tts"
|
|
8
8
|
BOTH = "both"
|
|
9
|
+
REALTIME = "realtime" # end-to-end speech-to-speech (bidirectional realtime voice)
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class ExecMode(str, Enum):
|
|
@@ -20,6 +21,7 @@ class ExecMode(str, Enum):
|
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
class AudioFormat(str, Enum):
|
|
24
|
+
PCM = "pcm"
|
|
23
25
|
PCM_16K = "pcm_16k"
|
|
24
26
|
PCM_44K = "pcm_44k"
|
|
25
27
|
WAV = "wav"
|
|
@@ -29,6 +31,26 @@ class AudioFormat(str, Enum):
|
|
|
29
31
|
FLAC = "flac"
|
|
30
32
|
OPUS = "opus"
|
|
31
33
|
WEBM = "webm"
|
|
34
|
+
AAC = "aac"
|
|
35
|
+
SPEEX = "speex"
|
|
36
|
+
MULAW = "mulaw"
|
|
37
|
+
ALAW = "alaw"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def audio_format_value(value: "AudioFormat | str | None", default: str = "wav") -> str:
|
|
41
|
+
"""Return the wire value for an audio format, including legacy enum-like strings."""
|
|
42
|
+
if isinstance(value, AudioFormat):
|
|
43
|
+
return value.value
|
|
44
|
+
text = str(value or "").strip()
|
|
45
|
+
if not text:
|
|
46
|
+
return default
|
|
47
|
+
if text.startswith("AudioFormat."):
|
|
48
|
+
member = text.split(".", 1)[1]
|
|
49
|
+
try:
|
|
50
|
+
return AudioFormat[member].value
|
|
51
|
+
except KeyError:
|
|
52
|
+
return default
|
|
53
|
+
return text.lower()
|
|
32
54
|
|
|
33
55
|
|
|
34
56
|
class Capability(str, Enum):
|
|
@@ -43,3 +65,4 @@ class Capability(str, Enum):
|
|
|
43
65
|
# Omni-modal engines (e.g. qwen3-omni) that expose an OpenAI-compatible /v1/chat/completions
|
|
44
66
|
# backend for text/image/audio/video understanding. Gates the OSA chat-completions proxy route.
|
|
45
67
|
CHAT = "chat"
|
|
68
|
+
REALTIME = "realtime" # end-to-end realtime speech-to-speech (bidirectional WS voice chat)
|
|
@@ -41,11 +41,16 @@ class AudioChunk:
|
|
|
41
41
|
data: bytes
|
|
42
42
|
sequence: int
|
|
43
43
|
is_final: bool = False
|
|
44
|
+
format: AudioFormat | None = None
|
|
45
|
+
sample_rate: int | None = None
|
|
46
|
+
channels: int | None = None
|
|
44
47
|
|
|
45
48
|
|
|
46
49
|
@dataclass
|
|
47
50
|
class STTOptions:
|
|
48
51
|
language: str | None = None
|
|
52
|
+
sample_rate: int | None = None
|
|
53
|
+
channels: int | None = None
|
|
49
54
|
prompt: str | None = None
|
|
50
55
|
temperature: float | None = None
|
|
51
56
|
model: str | None = None
|