openspeechapi 0.3.1__tar.gz → 0.4.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.
Files changed (174) hide show
  1. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/PKG-INFO +1 -1
  2. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/core/base.py +52 -0
  3. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/core/enums.py +3 -0
  4. openspeechapi-0.4.0/openspeechapi/core/voice_presets.py +91 -0
  5. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/engine_catalog.py +2 -0
  6. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/engine_registry.yaml +13 -0
  7. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/factory.py +5 -0
  8. openspeechapi-0.4.0/openspeechapi/local_engines/spark_venv.py +276 -0
  9. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/qwen3_omni_stt.py +54 -3
  10. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/coqui.py +19 -33
  11. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/f5_tts.py +22 -38
  12. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/indextts.py +56 -60
  13. openspeechapi-0.4.0/openspeechapi/providers/tts/spark.py +306 -0
  14. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/app.py +3 -1
  15. openspeechapi-0.4.0/openspeechapi/server/routes/chat.py +73 -0
  16. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/routes/management.py +38 -3
  17. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/routes/tts.py +68 -0
  18. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/webui/app.js +239 -1
  19. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/webui/index.html +21 -2
  20. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/webui/styles.css +20 -0
  21. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/ws/tts_stream.py +4 -0
  22. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/pyproject.toml +1 -1
  23. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/.gitignore +0 -0
  24. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/README.md +0 -0
  25. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/__init__.py +0 -0
  26. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/__main__.py +0 -0
  27. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/cli.py +0 -0
  28. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/client/__init__.py +0 -0
  29. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/client/client.py +0 -0
  30. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/config.py +0 -0
  31. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/core/__init__.py +0 -0
  32. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/core/model_hub.py +0 -0
  33. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/core/models.py +0 -0
  34. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/core/registry.py +0 -0
  35. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/core/settings.py +0 -0
  36. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/demo.py +0 -0
  37. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/__init__.py +0 -0
  38. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/aim_provision.py +0 -0
  39. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/context.py +0 -0
  40. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/dispatcher.py +0 -0
  41. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/executors/__init__.py +0 -0
  42. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/executors/base.py +0 -0
  43. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/executors/in_process.py +0 -0
  44. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/executors/remote.py +0 -0
  45. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/executors/subprocess_exec.py +0 -0
  46. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/fanout.py +0 -0
  47. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/filters.py +0 -0
  48. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/lifecycle.py +0 -0
  49. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/dispatch/watcher.py +0 -0
  50. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/exceptions.py +0 -0
  51. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/__init__.py +0 -0
  52. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/aim_resolver.py +0 -0
  53. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/backends/__init__.py +0 -0
  54. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/backends/docker_backend.py +0 -0
  55. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/backends/native_backend.py +0 -0
  56. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/base.py +0 -0
  57. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/cosyvoice_venv.py +0 -0
  58. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/engines/__init__.py +0 -0
  59. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/engines/faster_whisper.py +0 -0
  60. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/engines/fish_speech.py +0 -0
  61. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/engines/sherpa_onnx.py +0 -0
  62. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/engines/whisper.py +0 -0
  63. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/engines/whisperlivekit.py +0 -0
  64. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/fish_venv.py +0 -0
  65. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/indextts_venv.py +0 -0
  66. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/isolated_venv.py +0 -0
  67. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/manager.py +0 -0
  68. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/models.py +0 -0
  69. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/progress.py +0 -0
  70. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/registry.py +0 -0
  71. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/task_store.py +0 -0
  72. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/tasks.py +0 -0
  73. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/vllm_gb10_patch.py +0 -0
  74. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/local_engines/vllm_venv.py +0 -0
  75. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/logging_config.py +0 -0
  76. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/observe/__init__.py +0 -0
  77. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/observe/base.py +0 -0
  78. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/observe/debug.py +0 -0
  79. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/observe/latency.py +0 -0
  80. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/observe/metrics.py +0 -0
  81. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/observe/tracing.py +0 -0
  82. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/observe/usage.py +0 -0
  83. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/__init__.py +0 -0
  84. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/_template.py +0 -0
  85. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/__init__.py +0 -0
  86. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/_local_audio.py +0 -0
  87. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/alibaba.py +0 -0
  88. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/assemblyai.py +0 -0
  89. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/azure_speech.py +0 -0
  90. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/baidu.py +0 -0
  91. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/canary_qwen_stt.py +0 -0
  92. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/deepgram.py +0 -0
  93. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/dolphin_stt.py +0 -0
  94. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/elevenlabs.py +0 -0
  95. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/faster_whisper.py +0 -0
  96. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/fireredasr_stt.py +0 -0
  97. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/funasr_stt.py +0 -0
  98. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/gemma4.py +0 -0
  99. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/google_cloud.py +0 -0
  100. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/iflytek.py +0 -0
  101. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/kimi_audio_stt.py +0 -0
  102. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/macos_speech.py +0 -0
  103. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/mlx_whisper_stt.py +0 -0
  104. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/mms_languages.json +0 -0
  105. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/mms_stt.py +0 -0
  106. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/moonshine_stt.py +0 -0
  107. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/openai.py +0 -0
  108. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/paraformer.py +0 -0
  109. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/parakeet_mlx_stt.py +0 -0
  110. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/phi4_multimodal_stt.py +0 -0
  111. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/qwen3_asr.py +0 -0
  112. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/sensevoice.py +0 -0
  113. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/sherpa_onnx.py +0 -0
  114. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/tencent.py +0 -0
  115. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/volcengine.py +0 -0
  116. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/vosk_stt.py +0 -0
  117. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/voxtral_stt.py +0 -0
  118. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/wenet_stt.py +0 -0
  119. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/whisper.py +0 -0
  120. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/whisperlivekit.py +0 -0
  121. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/stt/windows_speech.py +0 -0
  122. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/__init__.py +0 -0
  123. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/alibaba.py +0 -0
  124. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/azure_speech.py +0 -0
  125. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/baidu.py +0 -0
  126. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/cosyvoice.py +0 -0
  127. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/deepgram.py +0 -0
  128. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/elevenlabs.py +0 -0
  129. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/fish_speech.py +0 -0
  130. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/google_cloud.py +0 -0
  131. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/iflytek.py +0 -0
  132. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/kokoro.py +0 -0
  133. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/macos_say.py +0 -0
  134. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/minimax.py +0 -0
  135. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/openai.py +0 -0
  136. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/piper.py +0 -0
  137. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/tencent.py +0 -0
  138. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/volcengine.py +0 -0
  139. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/providers/tts/windows_sapi.py +0 -0
  140. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/__init__.py +0 -0
  141. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/auth.py +0 -0
  142. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/extras_installer.py +0 -0
  143. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/middleware.py +0 -0
  144. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/model_downloads.py +0 -0
  145. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/native_installer.py +0 -0
  146. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/routes/__init__.py +0 -0
  147. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/routes/stt.py +0 -0
  148. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/routes/webui.py +0 -0
  149. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/system_metrics.py +0 -0
  150. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/ws/__init__.py +0 -0
  151. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/server/ws/stt_stream.py +0 -0
  152. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/telemetry/__init__.py +0 -0
  153. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/telemetry/perf.py +0 -0
  154. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/utils/__init__.py +0 -0
  155. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/utils/audio_converter.py +0 -0
  156. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/utils/audio_playback.py +0 -0
  157. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/openspeechapi/vendor_registry.yaml +0 -0
  158. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/providers.example.yaml +0 -0
  159. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/aim_adopt.py +0 -0
  160. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/aim_consumers.py +0 -0
  161. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/engines/cloud/install.sh +0 -0
  162. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/engines/faster-whisper/native/install.sh +0 -0
  163. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/engines/fish-speech/native/install.sh +0 -0
  164. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/engines/macos-stt/_bundle.sh +0 -0
  165. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/engines/macos-stt/install.sh +0 -0
  166. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/engines/macos-stt/macos_stt.swift +0 -0
  167. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/engines/macos-stt/request_auth.swift +0 -0
  168. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/engines/sherpa-onnx/native/install.sh +0 -0
  169. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/engines/sherpa-onnx/native/run_streaming_server.py +0 -0
  170. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/engines/whisper/native/install.sh +0 -0
  171. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/engines/whisperlivekit/native/install.sh +0 -0
  172. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/gen_mms_languages.py +0 -0
  173. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/preload_stt_model.py +0 -0
  174. {openspeechapi-0.3.1 → openspeechapi-0.4.0}/scripts/release.sh +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openspeechapi
3
- Version: 0.3.1
3
+ Version: 0.4.0
4
4
  Summary: Unified speech interface for STT/TTS providers
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: httpx>=0.27
@@ -1,7 +1,10 @@
1
1
  """Provider abstract base classes."""
2
2
  from __future__ import annotations
3
3
 
4
+ import base64
5
+ import contextlib
4
6
  import os
7
+ import tempfile
5
8
  from abc import ABC, abstractmethod
6
9
  from collections.abc import AsyncIterator
7
10
  from dataclasses import dataclass
@@ -335,3 +338,52 @@ class TTSProvider(SpeechProvider):
335
338
  Override to return a list. Must stay import-light (no torch): it runs in the server process
336
339
  off ``provider_cls`` with no instance/model."""
337
340
  return None
341
+
342
+ # ── clone-reference temp-file handling (shared by spark / indextts / f5 / coqui) ──────────────
343
+ @staticmethod
344
+ def _reference_to_wav(value: Any) -> tuple[str | None, bool]:
345
+ """A clone-reference value → ``(local_wav_path, is_temp)``.
346
+
347
+ Accepts an existing file path, a base64 string, or raw ``bytes``. base64/bytes are decoded
348
+ and written to a NEW temp WAV, returned with ``is_temp=True`` (the caller must delete it —
349
+ use :meth:`_reference_wav`). A falsy value, an existing path, or a non-base64 string is
350
+ returned as-is with ``is_temp=False`` — it is the user's own file (or no file), so it must
351
+ NEVER be deleted.
352
+ """
353
+ if not value:
354
+ return None, False
355
+ if isinstance(value, str):
356
+ if os.path.exists(value):
357
+ return value, False
358
+ try:
359
+ raw = base64.b64decode(value, validate=True)
360
+ except Exception: # noqa: BLE001 - not base64 → treat as a path/URL string
361
+ return value, False
362
+ else:
363
+ raw = value
364
+ f = tempfile.NamedTemporaryFile(suffix=".wav", delete=False)
365
+ f.write(raw)
366
+ f.close()
367
+ return f.name, True
368
+
369
+ @contextlib.contextmanager
370
+ def _reference_wav(self, resolved: tuple[str | None, bool]):
371
+ """Context manager over a resolved reference ``(path, is_temp)`` — yields ``path`` and deletes
372
+ the temp file *we* created (``is_temp=True``) when the block exits, whether it completes or
373
+ raises. A user-supplied path (``is_temp=False``) or ``None`` is yielded untouched.
374
+
375
+ Wrap the ``_synth`` call in ``synthesize`` so a base64/bytes reference clip doesn't leak a
376
+ ``.wav`` in the temp dir on every clone request::
377
+
378
+ with self._reference_wav(self._resolve_reference(opts, s)) as ref:
379
+ wav_bytes, sr = await asyncio.to_thread(self._synth, text, ref, ...)
380
+ """
381
+ path, is_temp = resolved
382
+ try:
383
+ yield path
384
+ finally:
385
+ if is_temp and path:
386
+ try:
387
+ os.unlink(path)
388
+ except OSError:
389
+ pass
@@ -40,3 +40,6 @@ class Capability(str, Enum):
40
40
  WORD_TIMESTAMPS = "word_timestamps"
41
41
  # STT: detects audio emotion + acoustic events (e.g. SenseVoice rich tags).
42
42
  AUDIO_EVENTS = "audio_events"
43
+ # Omni-modal engines (e.g. qwen3-omni) that expose an OpenAI-compatible /v1/chat/completions
44
+ # backend for text/image/audio/video understanding. Gates the OSA chat-completions proxy route.
45
+ CHAT = "chat"
@@ -0,0 +1,91 @@
1
+ """Generic per-engine **custom voice presets** — a named bundle of per-request override params.
2
+
3
+ Any TTS engine that supports per-request overrides (the Lab "Advanced Options") can save the current
4
+ param combo (e.g. Spark-TTS ``gender``/``pitch``/``speed``/``seed``, IndexTTS2 emotion) under a name;
5
+ selecting that name later re-applies the saved overrides. The MECHANISM is engine-agnostic; each
6
+ preset's EFFECT is engine-specific (it just stores that engine's override dict).
7
+
8
+ Presets are namespaced by **provider name** (e.g. ``spark-tts``), not by config alias — so every alias
9
+ of the same engine shares them and different engines never collide. Persisted as JSON in the user
10
+ config dir (next to ``providers.yaml``) so they survive restarts AND source-tree redeploys.
11
+
12
+ Store shape::
13
+
14
+ { "<provider-name>": { "<voice-name>": { <override-field>: <value>, ... }, ... }, ... }
15
+ """
16
+ from __future__ import annotations
17
+
18
+ import json
19
+ import os
20
+ import threading
21
+ from pathlib import Path
22
+
23
+ from openspeechapi.config import default_config_dir
24
+
25
+ _LOCK = threading.Lock()
26
+
27
+
28
+ def _store_path() -> Path:
29
+ return default_config_dir() / "voice_presets.json"
30
+
31
+
32
+ def _load_all() -> dict[str, dict[str, dict]]:
33
+ p = _store_path()
34
+ if not p.exists():
35
+ return {}
36
+ try:
37
+ data = json.loads(p.read_text(encoding="utf-8"))
38
+ except Exception: # noqa: BLE001 - corrupt/unreadable JSON → behave as empty (never crash the UI)
39
+ return {}
40
+ return data if isinstance(data, dict) else {}
41
+
42
+
43
+ def _write_all(data: dict) -> None:
44
+ p = _store_path()
45
+ p.parent.mkdir(parents=True, exist_ok=True)
46
+ tmp = p.with_suffix(".json.tmp")
47
+ tmp.write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
48
+ os.replace(tmp, p) # atomic swap → never leave a half-written store
49
+
50
+
51
+ def list_presets(provider: str) -> dict[str, dict]:
52
+ """All saved presets for *provider* → ``{name: overrides_dict}`` (a copy). Empty if none."""
53
+ with _LOCK:
54
+ return {k: dict(v) for k, v in (_load_all().get(provider, {}) or {}).items()}
55
+
56
+
57
+ def get_preset(provider: str, name: str) -> dict | None:
58
+ """The overrides dict saved under *name* for *provider*, or ``None`` if absent."""
59
+ with _LOCK:
60
+ v = _load_all().get(provider, {}).get(name)
61
+ return dict(v) if isinstance(v, dict) else None
62
+
63
+
64
+ def save_preset(provider: str, name: str, overrides: dict) -> None:
65
+ """Save (or replace) *name* for *provider* with *overrides* (a param dict)."""
66
+ provider = (provider or "").strip()
67
+ name = (name or "").strip()
68
+ if not provider:
69
+ raise ValueError("provider must not be empty")
70
+ if not name:
71
+ raise ValueError("voice name must not be empty")
72
+ if not isinstance(overrides, dict):
73
+ raise ValueError("overrides must be a dict")
74
+ with _LOCK:
75
+ data = _load_all()
76
+ data.setdefault(provider, {})[name] = dict(overrides)
77
+ _write_all(data)
78
+
79
+
80
+ def delete_preset(provider: str, name: str) -> bool:
81
+ """Remove *name* for *provider*. Returns True if it existed and was removed."""
82
+ with _LOCK:
83
+ data = _load_all()
84
+ bucket = data.get(provider, {})
85
+ if name not in bucket:
86
+ return False
87
+ del bucket[name]
88
+ if not bucket:
89
+ data.pop(provider, None) # drop empty provider buckets
90
+ _write_all(data)
91
+ return True
@@ -43,6 +43,7 @@ class CatalogEntry:
43
43
  fish_venv: bool = False # build a fish-speech serving venv + git src checkout (service-client engine)
44
44
  cosyvoice_venv: bool = False # dedicated git-clone SDK installer (CosyVoice SDK isn't on PyPI): Install builds ~/AI/venvs/cosyvoice via create_cosyvoice_venv (git clone --recursive + uv venv + wetext, no pynini) + worker runs from it (also set isolated_venv)
45
45
  indextts_venv: bool = False # dedicated git-clone SDK installer for IndexTTS2 (uv project): Install builds ~/AI/venvs/indextts via create_indextts_venv (git clone + uv sync + editable openspeechapi + .pth fallback) + worker runs from it (also set isolated_venv)
46
+ spark_venv: bool = False # dedicated git-clone SDK installer for Spark-TTS (no PyPI/pyproject): Install builds ~/AI/venvs/spark-tts via create_spark_venv (git clone + uv venv + editable openspeechapi + requirements[no gradio] + .pth → clone root) + worker runs from it (also set isolated_venv)
46
47
  cuda_torch: bool = False # isolated_venv: on a CUDA host, pre-install torch+torchaudio from the CUDA wheel index (default PyPI ships CPU torch on aarch64)
47
48
  spacy_models: list[str] = field(default_factory=list) # isolated_venv: best-effort-install these spaCy models (name==ver) from the (OSA_GITHUB_PROXY-mirrored) GitHub release AFTER extras — their only wheel is a GitHub asset, can't be a pip extra; e.g. kokoro's en_core_web_sm for misaki English G2P
48
49
 
@@ -206,6 +207,7 @@ def build_catalog(registry_path: Path | None = None) -> list[CatalogEntry]:
206
207
  fish_venv=bool(raw.get("fish_venv", False)),
207
208
  cosyvoice_venv=bool(raw.get("cosyvoice_venv", False)),
208
209
  indextts_venv=bool(raw.get("indextts_venv", False)),
210
+ spark_venv=bool(raw.get("spark_venv", False)),
209
211
  cuda_torch=bool(raw.get("cuda_torch", False)),
210
212
  spacy_models=list(raw.get("spacy_models", []) or []),
211
213
  )
@@ -558,6 +558,19 @@ engines:
558
558
  cuda_torch: true # CUDA 主机装后从 cu130 index 覆盖 torch(uv.lock 钉 torch==2.8.* 在 aarch64 是 CPU 版)
559
559
  pip_extras: [] # git-clone SDK 非 PyPI
560
560
 
561
+ - name: spark-tts
562
+ provider: spark-tts
563
+ type: tts
564
+ category: local
565
+ display_name: "Spark-TTS"
566
+ description: "Spark-TTS(SparkAudio,0.5B)— 基于 Qwen2.5 的自回归 TTS,两种能力:(1) 参考音零样本声音克隆(reference_audio + 可选 reference_text);(2) 可控音色生成(gender=male/female + pitch/speed=very_low..very_high),无需参考音即造一个新声音——首个非纯克隆的本地 TTS。EN/ZH 自动。OSA 托管 git-clone SDK venv(clone + uv venv,SDK 非 PyPI)+ subprocess IPC worker + editable openspeechapi。CUDA 主体(DGX 验证);macOS best-effort(CPU 可跑,MPS 未验证)。需 git 在 PATH。⚠️ 权重 CC BY-NC-SA 4.0 **非商用**(研究/内部);代码 Apache-2.0。"
567
+ default_alias: spark_tts
568
+ default_exec_mode: subprocess
569
+ spark_venv: true # 专用 git-clone SDK 安装器(clone + uv venv + editable openspeechapi + requirements[裁 gradio] + .pth → clone 根;SDK 非 PyPI)
570
+ isolated_venv: true # worker 从 ~/AI/venvs/spark-tts 跑(resolve_worker_python 据此);隔离 transformers==4.46.2
571
+ cuda_torch: true # CUDA 主机装 requirements 前先从 cu13x index 装 torch+torchaudio(requirements 钉 torch==2.5.1 在 aarch64 默认是 CPU 版且与 cu130 冲突)
572
+ pip_extras: [] # git-clone SDK 非 PyPI
573
+
561
574
  # ---- macOS Native ----
562
575
  - name: macos-stt
563
576
  provider: macos-stt
@@ -190,6 +190,11 @@ _PROVIDER_MAP: dict[str, tuple[str, str, str]] = {
190
190
  "IndexTTS2",
191
191
  "IndexTTS2Settings",
192
192
  ),
193
+ "spark-tts": (
194
+ "openspeechapi.providers.tts.spark",
195
+ "SparkTTSProvider",
196
+ "SparkTTSSettings",
197
+ ),
193
198
  "minimax": (
194
199
  "openspeechapi.providers.tts.minimax",
195
200
  "MinimaxTTS",
@@ -0,0 +1,276 @@
1
+ """Git-clone SDK serving-venv installer for Spark-TTS (SparkAudio/Spark-TTS).
2
+
3
+ Spark-TTS's SDK has NO PyPI package and NO pyproject/uv.lock — the ``sparktts`` package + the ``cli``
4
+ loader (``cli/SparkTTS.py``) are a plain PYTHONPATH repo. This installer git-clones the source
5
+ (pinned), builds a dedicated per-provider venv with the SAME python as the main interpreter (pickle/
6
+ ABI-safe, so the subprocess worker can run from it), reinstalls CUDA torch on CUDA hosts, editable-
7
+ installs openspeechapi (IPC compat), installs the repo's requirements.txt (gradio filtered out —
8
+ webui-only; torch/torchaudio also filtered on CUDA hosts so the ==2.5.1 pin can't downgrade the cu13x
9
+ torch), and writes a ``.pth`` with the clone root so ``from cli.SparkTTS import SparkTTS`` works in the
10
+ worker. Simpler than create_cosyvoice_venv: NO submodules, NO legacy-sdist no-isolation dance, NO
11
+ onnxruntime/grpcio substitutions, NO post-requirements pins. Idempotent: an existing checkout/venv is
12
+ reused; venv/pip steps re-run cheaply.
13
+
14
+ Layout (mirrors cosyvoice_venv's ``service_dir`` + isolated_venv's keyed venv)::
15
+
16
+ ~/AI/services/spark-tts/
17
+ src/ ← git clone of SparkAudio/Spark-TTS (pinned)
18
+ cli/SparkTTS.py ← exposes the SparkTTS class
19
+ sparktts/ ← the internal package (PYTHONPATH-imported)
20
+ requirements.txt
21
+ ~/AI/venvs/spark-tts/ ← uv venv (openspeechapi + Spark reqs), .pth → src (clone root)
22
+
23
+ China-friendly by default (uv python mirror + pip index), overridable via the same ``OSA_*`` env vars
24
+ as cosyvoice/fish. Service dir + git repo/ref overridable via ``OSA_SPARK_SERVICE_DIR`` /
25
+ ``OSA_SPARK_GIT_REPO`` / ``OSA_SPARK_GIT_REF``. Weights are NOT downloaded here — that stays with aim
26
+ provisioning at lazy-start (the provider's ``aim_model_spec``)."""
27
+ from __future__ import annotations
28
+
29
+ import os
30
+ import shutil
31
+ import subprocess
32
+ import sys
33
+ from collections.abc import Callable
34
+ from dataclasses import dataclass
35
+ from pathlib import Path
36
+
37
+ from openspeechapi.local_engines.isolated_venv import venv_dir, venv_python
38
+
39
+ # Defaults are China-fast; override per-machine with the OSA_* env vars (same knobs as cosyvoice/fish).
40
+ _UV_PYTHON_MIRROR_DEFAULT = (
41
+ "https://ghfast.top/https://github.com/astral-sh/"
42
+ "python-build-standalone/releases/download"
43
+ )
44
+ _PIP_INDEX_DEFAULT = "https://pypi.tuna.tsinghua.edu.cn/simple"
45
+ _GIT_REPO_DEFAULT = "https://github.com/SparkAudio/Spark-TTS.git"
46
+ # Pinned to the current main-branch commit (upstream ships NO release tag; resolved via
47
+ # `git ls-remote https://github.com/SparkAudio/Spark-TTS.git HEAD` in Task 2 Step 1). Override via
48
+ # OSA_SPARK_GIT_REF; on GitHub-blocked hosts set OSA_SPARK_GIT_REPO to a ghfast mirror.
49
+ _GIT_REF_DEFAULT = "2f1ea9082400547242641f5271b6f941c9f439d1"
50
+
51
+ # gradio is webui-only (Spark's app.py) — never imported by cli.SparkTTS / the provider. Drop it from
52
+ # requirements before install (it's large + can drag in version-finicky deps). Re-enable by removing.
53
+ _SKIP_PACKAGES = ("gradio",)
54
+
55
+
56
+ def spark_service_dir() -> Path:
57
+ """Where OSA installs the Spark-TTS source (env ``OSA_SPARK_SERVICE_DIR``)."""
58
+ raw = os.environ.get("OSA_SPARK_SERVICE_DIR", "").strip()
59
+ return Path(raw).expanduser() if raw else Path("~/AI/services/spark-tts").expanduser()
60
+
61
+
62
+ @dataclass
63
+ class SparkVenvResult:
64
+ ok: bool
65
+ venv_python: str = ""
66
+ method: str = ""
67
+ log: str = ""
68
+
69
+
70
+ def _run(cmd: list[str], env: dict | None = None, timeout: int = 3600) -> subprocess.CompletedProcess:
71
+ return subprocess.run(cmd, capture_output=True, text=True, timeout=timeout, env=env)
72
+
73
+
74
+ def _site_packages_dir(vpy: Path, timeout: int = 60) -> Path | None:
75
+ r = _run([str(vpy), "-c", "import sysconfig; print(sysconfig.get_path('purelib'))"], timeout=timeout)
76
+ if r.returncode != 0:
77
+ return None
78
+ out = (r.stdout or "").strip().splitlines()
79
+ if not out or not out[-1].strip():
80
+ return None
81
+ return Path(out[-1].strip())
82
+
83
+
84
+ def _dist_name(line: str) -> str:
85
+ """The distribution name at the head of a requirements line (lower-cased), '' for blank/comment.
86
+ Name ends at the first of: comparison op, ';' marker, '[' extras, whitespace, '@'."""
87
+ import re
88
+ head = line.split("#", 1)[0].strip()
89
+ if not head:
90
+ return ""
91
+ return re.split(r"[<>=!~;\[\s@]", head, 1)[0].strip().lower()
92
+
93
+
94
+ def create_spark_venv(
95
+ repo_root: Path | str, entry, *, timeout: int = 3600,
96
+ progress: Callable[[str], None] | None = None,
97
+ ) -> SparkVenvResult:
98
+ """Build the Spark-TTS serving venv: git clone (pinned) → uv venv (same python as main) → editable
99
+ openspeechapi → cuda_torch (CUDA hosts) → ``uv pip install -r requirements.txt`` (gradio filtered;
100
+ torch/torchaudio also filtered on CUDA hosts) → ``.pth`` for the clone root → verify
101
+ ``import cli.SparkTTS``. ``entry`` is a CatalogEntry (needs ``provider`` / ``cuda_torch``).
102
+ Idempotent."""
103
+ logs: list[str] = []
104
+
105
+ def emit(line: str) -> None:
106
+ line = (line or "").rstrip()
107
+ if not line:
108
+ return
109
+ logs.append(line)
110
+ if progress:
111
+ progress(line)
112
+
113
+ base = spark_service_dir()
114
+ src = base / "src"
115
+ # Key the venv by the PROVIDER KEY so resolve_worker_python(provider) finds it (same scheme as
116
+ # isolated_venv) — the executor spawns the worker from this venv's python.
117
+ provider_key = getattr(entry, "provider", "spark-tts") or "spark-tts"
118
+ vdir = venv_dir(provider_key)
119
+ vpy = venv_python(provider_key)
120
+
121
+ uv = shutil.which("uv")
122
+ if not uv:
123
+ return SparkVenvResult(ok=False, log="uv not found — install uv (https://docs.astral.sh/uv).")
124
+ git = shutil.which("git")
125
+ if not git:
126
+ return SparkVenvResult(ok=False, log="git not found — install git to clone Spark-TTS.")
127
+
128
+ env = dict(os.environ)
129
+ env.setdefault(
130
+ "UV_PYTHON_INSTALL_MIRROR",
131
+ os.environ.get("OSA_UV_PYTHON_MIRROR", _UV_PYTHON_MIRROR_DEFAULT),
132
+ )
133
+ pip_index = os.environ.get("OSA_PIP_INDEX_URL", _PIP_INDEX_DEFAULT)
134
+ git_repo = os.environ.get("OSA_SPARK_GIT_REPO", _GIT_REPO_DEFAULT)
135
+ git_ref = os.environ.get("OSA_SPARK_GIT_REF", _GIT_REF_DEFAULT)
136
+
137
+ # 1. Clone the Spark-TTS source (pinned ref) → base/src. Idempotent: skip when the SDK marker
138
+ # (cli/SparkTTS.py) is already present.
139
+ sdk_marker = src / "cli" / "SparkTTS.py"
140
+ if not sdk_marker.exists():
141
+ base.mkdir(parents=True, exist_ok=True)
142
+ if not (src / ".git").exists():
143
+ emit(f"git clone {git_repo} → {src} …")
144
+ r = _run([git, "clone", git_repo, str(src)], timeout=timeout)
145
+ emit((r.stdout or "") + (r.stderr or ""))
146
+ if r.returncode != 0:
147
+ return SparkVenvResult(ok=False, method="git", log="\n".join(logs)[-4000:])
148
+ emit(f"git checkout {git_ref} …")
149
+ r = _run([git, "-C", str(src), "checkout", git_ref], timeout=timeout)
150
+ if r.returncode != 0: # ref may need fetching first (shallow clone / new ref)
151
+ _run([git, "-C", str(src), "fetch", "origin", git_ref], timeout=timeout)
152
+ r = _run([git, "-C", str(src), "checkout", git_ref], timeout=timeout)
153
+ emit((r.stdout or "") + (r.stderr or ""))
154
+ if r.returncode != 0 or not sdk_marker.exists():
155
+ return SparkVenvResult(ok=False, method="git", log="\n".join(logs)[-4000:])
156
+ else:
157
+ emit(f"Spark-TTS source present (clone skipped): {src}")
158
+
159
+ # 2. Create the venv with the SAME python as the main interpreter (pickle/ABI safe — same as
160
+ # create_isolated_venv). Skip if its python already exists.
161
+ if not vpy.exists():
162
+ vdir.parent.mkdir(parents=True, exist_ok=True)
163
+ emit(f"uv venv --python {sys.executable} {vdir} …")
164
+ r = _run([uv, "venv", "--python", sys.executable, str(vdir)], env=env, timeout=timeout)
165
+ emit((r.stdout or "") + (r.stderr or ""))
166
+ if r.returncode != 0 or not vpy.exists():
167
+ return SparkVenvResult(ok=False, method="uv-venv", log="\n".join(logs)[-4000:])
168
+ else:
169
+ emit(f"venv present: {vdir}")
170
+
171
+ # 3. editable-install openspeechapi into the venv (IPC compat). Source checkout (repo_root has
172
+ # pyproject.toml) → -e repo_root; pip-installed OSA → the SAME version from the index. Reuses
173
+ # isolated_venv's source-vs-pip logic.
174
+ from openspeechapi.server.extras_installer import _installer_argv
175
+ argv, _ = _installer_argv(str(vpy))
176
+ if argv is None:
177
+ return SparkVenvResult(ok=False, method="uv", log="no pip/uv available to install into the venv")
178
+ if (Path(repo_root) / "pyproject.toml").exists():
179
+ osa_target = ["-e", str(repo_root)]
180
+ else:
181
+ from importlib.metadata import PackageNotFoundError
182
+ from importlib.metadata import version as _pkg_version
183
+ try:
184
+ osa_target = [f"openspeechapi=={_pkg_version('openspeechapi')}"]
185
+ except PackageNotFoundError: # pragma: no cover
186
+ osa_target = ["openspeechapi"]
187
+ emit(f"install openspeechapi into venv: {' '.join(osa_target)} …")
188
+ r = _run(argv + osa_target, env=env, timeout=timeout)
189
+ emit((r.stdout or "") + (r.stderr or ""))
190
+ if r.returncode != 0:
191
+ return SparkVenvResult(ok=False, method="uv", log="\n".join(logs)[-4000:])
192
+
193
+ # 4. CUDA torch override (CUDA host only): requirements pin torch==2.5.1, which resolves to a CPU
194
+ # build on aarch64 (DGX) AND conflicts with cu130. Install torch+torchaudio from the CUDA wheel
195
+ # index BEFORE requirements so the pinned torch is satisfied by the GPU build; torch/torchaudio
196
+ # are then filtered OUT of requirements (step 5) so uv can't downgrade back to the CPU 2.5.1.
197
+ # Skipped on non-CUDA hosts (no nvidia-smi, e.g. macOS) → requirements' torch==2.5.1 kept.
198
+ cuda_host = bool(getattr(entry, "cuda_torch", False) and shutil.which("nvidia-smi"))
199
+ if cuda_host:
200
+ index = os.environ.get(
201
+ "OSA_TORCH_CUDA_INDEX", "https://download.pytorch.org/whl/cu130").strip()
202
+ emit(f"[cuda_torch] pre-install CUDA torch+torchaudio from {index}")
203
+ r = _run([uv, "pip", "install", "--python", str(vpy), "torch", "torchaudio",
204
+ "--index-url", index], env=env, timeout=timeout)
205
+ emit((r.stdout or "") + (r.stderr or ""))
206
+ if r.returncode != 0:
207
+ return SparkVenvResult(ok=False, method="uv", log="\n".join(logs)[-4000:])
208
+
209
+ # 5. Install requirements.txt into the venv, FILTERING out gradio (webui-only) and — on a CUDA
210
+ # host — torch/torchaudio (their ==2.5.1 pin would downgrade the cu13x torch from step 4).
211
+ # `uv pip install` has no `--no-install-package`, so we filter lines out of a copy of
212
+ # requirements.txt and install the filtered file (same approach as create_cosyvoice_venv).
213
+ skip_pkgs = {p.lower() for p in _SKIP_PACKAGES}
214
+ if cuda_host:
215
+ skip_pkgs |= {"torch", "torchaudio"}
216
+ req = src / "requirements.txt"
217
+ install_req = req
218
+ if req.exists():
219
+ kept: list[str] = []
220
+ for raw_line in req.read_text(encoding="utf-8").splitlines():
221
+ name = _dist_name(raw_line)
222
+ if name and name in skip_pkgs:
223
+ continue
224
+ kept.append(raw_line)
225
+ install_req = src / "requirements.osa-filtered.txt"
226
+ install_req.write_text("\n".join(kept) + "\n", encoding="utf-8")
227
+ emit(f"uv pip install -r {install_req} (skip: {', '.join(sorted(skip_pkgs))}) …")
228
+ r = _run([uv, "pip", "install", "--python", str(vpy), "-i", pip_index, "-r", str(install_req)],
229
+ env=env, timeout=timeout)
230
+ emit((r.stdout or "") + (r.stderr or ""))
231
+ if r.returncode != 0:
232
+ return SparkVenvResult(ok=False, method="uv", log="\n".join(logs)[-4000:])
233
+ else:
234
+ emit(f"WARNING: {req} not found — skipping requirements install")
235
+
236
+ # 6. Write a `.pth` into the venv's site-packages so `from cli.SparkTTS import SparkTTS` (and
237
+ # `import sparktts`) work in the worker. A `.pth` loads at interpreter start (before any user
238
+ # code), so it's robust to the pickled-provider worker (which only runs _worker_main and never
239
+ # imports this module). One absolute path: the clone root (both `cli` and `sparktts` live there).
240
+ site = _site_packages_dir(vpy)
241
+ if site is None:
242
+ return SparkVenvResult(ok=False, method="uv",
243
+ log="\n".join(logs + ["could not resolve venv site-packages"])[-4000:])
244
+ pth = site / "openspeechapi_spark.pth"
245
+ try:
246
+ pth.write_text(f"{src}\n", encoding="utf-8")
247
+ emit(f"wrote {pth} → {src}")
248
+ except Exception as e: # noqa: BLE001 — surface as a build failure (worker import would fail)
249
+ return SparkVenvResult(ok=False, method="uv",
250
+ log="\n".join(logs + [f".pth write failed: {e}"])[-4000:])
251
+
252
+ # 7. Verify `import cli.SparkTTS` in the venv (the exact statement the provider uses). Failure →
253
+ # surface the log so the user can fix (a missing dep / wrong ref).
254
+ chk = _run([str(vpy), "-c", "import cli.SparkTTS"], timeout=120)
255
+ if chk.returncode != 0:
256
+ emit((chk.stdout or "") + (chk.stderr or ""))
257
+ return SparkVenvResult(ok=False, method="uv",
258
+ log="\n".join(logs + ["import cli.SparkTTS failed after install"])[-4000:])
259
+
260
+ return SparkVenvResult(ok=True, venv_python=str(vpy), method="spark-venv",
261
+ log="\n".join(logs)[-4000:])
262
+
263
+
264
+ def remove_spark_venv(provider_key: str = "spark-tts") -> bool:
265
+ """Remove the Spark-TTS venv + git src checkout (keeps the aim-managed weights). Returns True if
266
+ anything existed and was removed."""
267
+ removed = False
268
+ vdir = venv_dir(provider_key)
269
+ if vdir.exists():
270
+ shutil.rmtree(vdir, ignore_errors=True)
271
+ removed = True
272
+ src = spark_service_dir() / "src"
273
+ if src.exists():
274
+ shutil.rmtree(src, ignore_errors=True)
275
+ removed = True
276
+ return removed
@@ -122,6 +122,9 @@ class Qwen3OmniSTT(STTProvider):
122
122
  capabilities = {
123
123
  Capability.BATCH,
124
124
  Capability.MULTILINGUAL,
125
+ # Omni-modal: the managed vLLM speaks OpenAI /v1/chat/completions for text/image/audio/video
126
+ # understanding. Gates the OSA chat-completions proxy route (chat_completions() below).
127
+ Capability.CHAT,
125
128
  }
126
129
  supports_param_overrides = True
127
130
  field_options = {
@@ -325,15 +328,29 @@ class Qwen3OmniSTT(STTProvider):
325
328
  async def _ensure_service(self) -> None:
326
329
  """Launch the vllm-omni server on api_url if nothing healthy is there, then poll until
327
330
  ready. An already-healthy server is reused (never duplicated). docker mode runs the official
328
- cross-arch image; venv mode runs the per-engine venv binary."""
331
+ cross-arch image; venv mode runs the per-engine venv binary.
332
+
333
+ In ``serve_mode='auto'``, a failed docker start FALLS BACK to the venv binary — the common
334
+ real-world failure is the docker image not being cached and the host being unable to reach
335
+ the registry (restricted networks, e.g. the GB10 box), which would otherwise take down the
336
+ whole engine even though a working venv exists. An EXPLICIT ``serve_mode='docker'`` is
337
+ respected (the error is surfaced, not silently switched)."""
329
338
  if not self.settings.manage_service:
330
339
  return
331
340
  if await self.health_check():
332
341
  logger.info("{}: reusing existing service at {}", self.name, self.settings.api_url)
333
342
  return
334
- if self._resolve_serve_mode() == "docker":
343
+ if self._resolve_serve_mode() != "docker":
344
+ await self._start_venv()
345
+ return
346
+ explicit_docker = (self.settings.serve_mode or "auto").strip().lower() == "docker"
347
+ try:
335
348
  await self._start_docker()
336
- else:
349
+ except RuntimeError as exc:
350
+ if explicit_docker:
351
+ raise
352
+ logger.warning(
353
+ "{}: docker-mode start failed ({}); falling back to venv mode.", self.name, exc)
337
354
  await self._start_venv()
338
355
 
339
356
  async def _poll_until_healthy(self, alive, on_dead: str) -> None:
@@ -568,6 +585,40 @@ class Qwen3OmniSTT(STTProvider):
568
585
  return ""
569
586
  return str(choices[0].get("message", {}).get("content", "")).strip()
570
587
 
588
+ # ── OpenAI chat/completions proxy (multimodal: text/image/audio/video) ────────
589
+ async def chat_completions(self, body: dict, stream: bool = False) -> Any:
590
+ """Proxy an OpenAI ``/v1/chat/completions`` request to the managed vLLM — full multimodal
591
+ (text/image/audio/video). The caller passes the OSA engine alias as ``body['model']``; we
592
+ rewrite it to the vLLM's actual served id. Returns the parsed JSON dict (non-stream) or an
593
+ async byte-iterator of the upstream SSE stream (``stream=True``). Backs the OSA
594
+ chat-completions proxy route so external clients drive this omni-modal engine with the
595
+ standard OpenAI SDK through OSA (which stays the single, optionally-authed entrypoint)."""
596
+ if self._client is None:
597
+ raise RuntimeError("Provider not started — call start() first")
598
+ s = self.settings
599
+ payload = dict(body) # never mutate the caller's dict
600
+ payload["model"] = await self._served_model(aim_local_path_or(s.model_path, s.model))
601
+ url = urljoin(s.api_url.rstrip("/") + "/", s.chat_path.lstrip("/"))
602
+ headers = {"Content-Type": "application/json"}
603
+ if stream:
604
+ payload["stream"] = True
605
+
606
+ async def _sse():
607
+ async with self._client.stream(
608
+ "POST", url, content=json.dumps(payload), headers=headers,
609
+ timeout=s.request_timeout_s,
610
+ ) as resp:
611
+ resp.raise_for_status()
612
+ async for chunk in resp.aiter_bytes():
613
+ yield chunk
614
+
615
+ return _sse()
616
+ resp = await self._client.post(
617
+ url, content=json.dumps(payload), headers=headers, timeout=s.request_timeout_s,
618
+ )
619
+ resp.raise_for_status()
620
+ return resp.json()
621
+
571
622
  async def transcribe_stream(
572
623
  self, stream: AsyncIterator[bytes]
573
624
  ) -> AsyncIterator[Any]:
@@ -15,7 +15,6 @@ Heavy: torch + model → runs in an isolated venv (deps pin torch). XTTS is fetc
15
15
  from __future__ import annotations
16
16
 
17
17
  import asyncio
18
- import base64
19
18
  import contextlib
20
19
  import io
21
20
  import json
@@ -304,20 +303,20 @@ class CoquiTTS(TTSProvider):
304
303
  s = self._effective_settings(opts, typed_map={"model": "model", "language": "language"})
305
304
  await self._ensure_model(s)
306
305
  lang = (opts.language or s.language or "en").strip()
307
- ref = self._resolve_reference(opts, s)
308
- speaker = (opts.voice or s.speaker or "").strip() or None
309
- # cloning models clone from `ref`; multi-speaker models need a built-in `speaker` (voice);
310
- # single-speaker models need neither. XTTS is both (clone via ref OR a built-in speaker).
311
- needs_voice = _is_cloning(s.model) or bool(getattr(self._tts, "is_multi_speaker", False))
312
- if needs_voice and not ref and not speaker:
313
- raise ValueError(
314
- "coqui: this model needs a voice — upload a reference clip to clone (reference_audio) "
315
- "or pick a built-in speaker (Voice / settings.speaker). Single-speaker models need neither.")
316
- _t0 = time.perf_counter()
317
- wav_bytes, sr = await asyncio.to_thread(self._synth, text, ref, lang, speaker)
318
- logger.info("{}: completed in {:.0f}ms, {} bytes @ {}Hz",
319
- self.name, (time.perf_counter() - _t0) * 1000, len(wav_bytes), sr)
320
- return AudioData(data=wav_bytes, sample_rate=sr, channels=1, format=AudioFormat.WAV)
306
+ with self._reference_wav(self._resolve_reference(opts, s)) as ref:
307
+ speaker = (opts.voice or s.speaker or "").strip() or None
308
+ # cloning models clone from `ref`; multi-speaker models need a built-in `speaker` (voice);
309
+ # single-speaker models need neither. XTTS is both (clone via ref OR a built-in speaker).
310
+ needs_voice = _is_cloning(s.model) or bool(getattr(self._tts, "is_multi_speaker", False))
311
+ if needs_voice and not ref and not speaker:
312
+ raise ValueError(
313
+ "coqui: this model needs a voice — upload a reference clip to clone (reference_audio) "
314
+ "or pick a built-in speaker (Voice / settings.speaker). Single-speaker models need neither.")
315
+ _t0 = time.perf_counter()
316
+ wav_bytes, sr = await asyncio.to_thread(self._synth, text, ref, lang, speaker)
317
+ logger.info("{}: completed in {:.0f}ms, {} bytes @ {}Hz",
318
+ self.name, (time.perf_counter() - _t0) * 1000, len(wav_bytes), sr)
319
+ return AudioData(data=wav_bytes, sample_rate=sr, channels=1, format=AudioFormat.WAV)
321
320
 
322
321
  def _synth(self, text: str, ref: str | None, lang: str, speaker: str | None = None) -> tuple[bytes, int]:
323
322
  """Blocking coqui synth → (wav_bytes, sample_rate). Runs in a worker thread. Builds the
@@ -345,25 +344,12 @@ class CoquiTTS(TTSProvider):
345
344
  sr = int(w.getframerate())
346
345
  return data, sr
347
346
 
348
- def _resolve_reference(self, opts: TTSOptions, s: "CoquiTTSSettings") -> str | None:
349
- """Reference → a local WAV path. Accepts a path, base64, or raw bytes; bytes/base64 are
350
- written to a temp WAV."""
347
+ def _resolve_reference(self, opts: TTSOptions, s: "CoquiTTSSettings") -> tuple[str | None, bool]:
348
+ """Reference → ``(local_wav_path, is_temp)``. base64/bytes → a temp WAV (is_temp=True, cleaned
349
+ up by ``synthesize`` via ``_reference_wav``); an existing path is returned as-is. Per-request
350
+ ``opts.reference_audio`` wins, else ``settings.speaker_wav``."""
351
351
  ref = opts.reference_audio if opts.reference_audio is not None else (s.speaker_wav or None)
352
- if not ref:
353
- return None
354
- if isinstance(ref, str):
355
- if os.path.exists(ref):
356
- return ref
357
- try:
358
- raw = base64.b64decode(ref, validate=True)
359
- except Exception: # noqa: BLE001 - not base64 → treat as a path/URL string
360
- return ref
361
- else:
362
- raw = ref
363
- f = tempfile.NamedTemporaryFile(suffix=".wav", delete=False)
364
- f.write(raw)
365
- f.close()
366
- return f.name
352
+ return self._reference_to_wav(ref)
367
353
 
368
354
  @classmethod
369
355
  def available_models(cls) -> list[str]: