vocal-api 0.3.7__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 (50) hide show
  1. {vocal_api-0.3.7 → vocal_api-0.4.0}/.gitignore +1 -2
  2. {vocal_api-0.3.7 → vocal_api-0.4.0}/MANIFEST.in +4 -4
  3. {vocal_api-0.3.7 → vocal_api-0.4.0}/PKG-INFO +7 -7
  4. {vocal_api-0.3.7 → vocal_api-0.4.0}/pyproject.toml +6 -6
  5. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/__init__.py +9 -9
  6. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/config.py +3 -0
  7. vocal_api-0.4.0/vocal_api/main.py +166 -0
  8. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/models/model.py +25 -4
  9. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/routes/__init__.py +2 -0
  10. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/routes/models.py +17 -15
  11. vocal_api-0.4.0/vocal_api/routes/realtime.py +745 -0
  12. vocal_api-0.4.0/vocal_api/routes/settings.py +185 -0
  13. vocal_api-0.4.0/vocal_api/routes/stream.py +300 -0
  14. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/routes/system.py +16 -16
  15. vocal_api-0.4.0/vocal_api/routes/transcription.py +139 -0
  16. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/routes/tts.py +13 -2
  17. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/services/__init__.py +9 -9
  18. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/services/model_service.py +6 -0
  19. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/services/transcription_service.py +50 -21
  20. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/services/tts_service.py +119 -16
  21. vocal_api-0.4.0/vocal_api/webui/app.css +472 -0
  22. vocal_api-0.4.0/vocal_api/webui/app.html +96 -0
  23. vocal_api-0.4.0/vocal_api/webui/design.md +137 -0
  24. vocal_api-0.4.0/vocal_api/webui/index.html +570 -0
  25. vocal_api-0.4.0/vocal_api/webui/js/api.js +155 -0
  26. vocal_api-0.4.0/vocal_api/webui/js/app.js +168 -0
  27. vocal_api-0.4.0/vocal_api/webui/js/audio.js +289 -0
  28. vocal_api-0.4.0/vocal_api/webui/js/connection.js +128 -0
  29. vocal_api-0.4.0/vocal_api/webui/js/icons.js +50 -0
  30. vocal_api-0.4.0/vocal_api/webui/js/mic.js +132 -0
  31. vocal_api-0.4.0/vocal_api/webui/js/pcm-worklet.js +11 -0
  32. vocal_api-0.4.0/vocal_api/webui/js/store.js +81 -0
  33. vocal_api-0.4.0/vocal_api/webui/js/ui.js +190 -0
  34. vocal_api-0.4.0/vocal_api/webui/js/views/agent.js +417 -0
  35. vocal_api-0.4.0/vocal_api/webui/js/views/clone.js +293 -0
  36. vocal_api-0.4.0/vocal_api/webui/js/views/dashboard.js +163 -0
  37. vocal_api-0.4.0/vocal_api/webui/js/views/live.js +240 -0
  38. vocal_api-0.4.0/vocal_api/webui/js/views/models.js +290 -0
  39. vocal_api-0.4.0/vocal_api/webui/js/views/settings.js +189 -0
  40. vocal_api-0.4.0/vocal_api/webui/js/views/stt.js +344 -0
  41. vocal_api-0.4.0/vocal_api/webui/js/views/tts.js +230 -0
  42. vocal_api-0.4.0/vocal_api/webui/og.svg +33 -0
  43. vocal_api-0.4.0/vocal_api/webui/theme.css +585 -0
  44. vocal_api-0.3.7/vocal_api/main.py +0 -107
  45. vocal_api-0.3.7/vocal_api/routes/realtime.py +0 -393
  46. vocal_api-0.3.7/vocal_api/routes/stream.py +0 -216
  47. vocal_api-0.3.7/vocal_api/routes/transcription.py +0 -83
  48. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/dependencies.py +0 -0
  49. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/models/__init__.py +0 -0
  50. {vocal_api-0.3.7 → vocal_api-0.4.0}/vocal_api/models/transcription.py +0 -0
@@ -27,8 +27,7 @@ venv/
27
27
  ENV/
28
28
  env/
29
29
 
30
- # UV
31
- uv.lock
30
+ # UV (uv.lock is committed for reproducible builds)
32
31
 
33
32
  # IDE
34
33
  .vscode/
@@ -1,4 +1,4 @@
1
- include ../../../README.md
2
- include ../../../LICENSE
3
- recursive-include vocal_api *.py
4
- recursive-include vocal_api/models *.py
1
+ include ../../../README.md
2
+ include ../../../LICENSE
3
+ recursive-include vocal_api *.py
4
+ recursive-include vocal_api/models *.py
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: vocal-api
3
- Version: 0.3.7
3
+ Version: 0.4.0
4
4
  Summary: FastAPI server for Vocal - Ollama-style Voice Model Management
5
5
  Project-URL: Homepage, https://github.com/niradler/vocal
6
6
  Project-URL: Documentation, https://github.com/niradler/vocal/tree/master/docs
@@ -19,8 +19,8 @@ Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
20
20
  Requires-Python: >=3.11
21
21
  Requires-Dist: aiofiles>=25.1.0
22
- Requires-Dist: fastapi>=0.135.1
23
- Requires-Dist: pydantic>=2.12.5
24
- Requires-Dist: python-multipart>=0.0.22
25
- Requires-Dist: uvicorn[standard]>=0.41.0
26
- Requires-Dist: vocal-core>=0.3.7
22
+ Requires-Dist: fastapi>=0.163.2
23
+ Requires-Dist: pydantic>=2.14.3
24
+ Requires-Dist: python-multipart>=0.0.34
25
+ Requires-Dist: uvicorn[standard]>=0.54.0
26
+ Requires-Dist: vocal-core>=0.4.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "vocal-api"
3
- version = "0.3.7"
3
+ version = "0.4.0"
4
4
  description = "FastAPI server for Vocal - Ollama-style Voice Model Management"
5
5
  requires-python = ">=3.11"
6
6
  license = { text = "SSPL-1.0" }
@@ -19,11 +19,11 @@ classifiers = [
19
19
  "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
20
20
  ]
21
21
  dependencies = [
22
- "fastapi>=0.135.1",
23
- "uvicorn[standard]>=0.41.0",
24
- "pydantic>=2.12.5",
25
- "python-multipart>=0.0.22",
26
- "vocal-core>=0.3.7",
22
+ "fastapi>=0.163.2",
23
+ "uvicorn[standard]>=0.54.0",
24
+ "pydantic>=2.14.3",
25
+ "python-multipart>=0.0.34",
26
+ "vocal-core>=0.4.0",
27
27
  "aiofiles>=25.1.0",
28
28
  ]
29
29
 
@@ -1,9 +1,9 @@
1
- from .config import settings
2
- from .main import app
3
-
4
- __version__ = settings.VERSION
5
-
6
- __all__ = [
7
- "app",
8
- "settings",
9
- ]
1
+ from .config import settings
2
+ from .main import app
3
+
4
+ __version__ = settings.VERSION
5
+
6
+ __all__ = [
7
+ "app",
8
+ "settings",
9
+ ]
@@ -16,6 +16,9 @@ class Settings(BaseSettings):
16
16
  DEBUG: bool = False
17
17
 
18
18
  CORS_ORIGINS: list[str] = ["*"]
19
+ # Allow browser requests from public origins (e.g. the GitHub Pages
20
+ # console) to this local server — Chrome's Private Network Access.
21
+ CORS_ALLOW_PRIVATE_NETWORK: bool = True
19
22
 
20
23
  MAX_UPLOAD_SIZE: int = 25 * 1024 * 1024
21
24
 
@@ -0,0 +1,166 @@
1
+ import os
2
+ import sys
3
+
4
+ if sys.platform == "win32":
5
+ import ctypes
6
+
7
+ try:
8
+ import torch as _torch
9
+
10
+ _torch_lib = os.path.join(os.path.dirname(_torch.__file__), "lib")
11
+ _cudnn_stub = os.path.join(_torch_lib, "cudnn64_9.dll")
12
+ if os.path.exists(_cudnn_stub):
13
+ ctypes.WinDLL(_cudnn_stub)
14
+ del _torch, _torch_lib, _cudnn_stub
15
+ except Exception:
16
+ pass
17
+ del ctypes
18
+
19
+ from contextlib import asynccontextmanager
20
+ from pathlib import Path
21
+
22
+ from fastapi import FastAPI, Request
23
+ from fastapi.middleware.cors import CORSMiddleware
24
+ from fastapi.openapi.utils import get_openapi
25
+ from fastapi.responses import FileResponse, JSONResponse
26
+ from fastapi.staticfiles import StaticFiles
27
+
28
+ from vocal_core.config import vocal_settings
29
+ from vocal_core.logging import setup_logging
30
+
31
+ from .config import settings
32
+ from .dependencies import get_transcription_service, get_tts_service
33
+ from .routes import (
34
+ models_router,
35
+ realtime_router,
36
+ settings_router,
37
+ stream_router,
38
+ system_router,
39
+ transcription_router,
40
+ tts_router,
41
+ )
42
+ from .routes.settings import load_persisted_settings
43
+
44
+ WEBUI_DIR = Path(__file__).parent / "webui"
45
+
46
+
47
+ @asynccontextmanager
48
+ async def lifespan(app: FastAPI):
49
+ """Initialize services and start background tasks"""
50
+ load_persisted_settings()
51
+ setup_logging(level=vocal_settings.LOG_LEVEL, fmt=vocal_settings.LOG_FORMAT)
52
+
53
+ try:
54
+ from vocal_core.adapters._compat import apply_transformers_shims
55
+
56
+ apply_transformers_shims()
57
+ except Exception as exc:
58
+ import logging
59
+
60
+ logging.getLogger(__name__).warning("Failed to apply transformers shims: %s", exc)
61
+
62
+ transcription_service = get_transcription_service()
63
+ await transcription_service.start_cleanup_task()
64
+
65
+ tts_service = get_tts_service()
66
+ await tts_service.start_cleanup_task()
67
+
68
+ yield
69
+
70
+
71
+ app = FastAPI(
72
+ title="Vocal API",
73
+ description="Generic Speech AI Platform (STT + TTS)",
74
+ version=settings.VERSION,
75
+ docs_url="/docs",
76
+ redoc_url="/redoc",
77
+ lifespan=lifespan,
78
+ )
79
+
80
+ app.add_middleware(
81
+ CORSMiddleware,
82
+ allow_origins=settings.CORS_ORIGINS,
83
+ allow_credentials=True,
84
+ allow_methods=["*"],
85
+ allow_headers=["*"],
86
+ # Lets a publicly hosted console (GitHub Pages) reach this local server
87
+ # from the browser (Chrome Private Network Access preflight).
88
+ allow_private_network=settings.CORS_ALLOW_PRIVATE_NETWORK,
89
+ )
90
+
91
+ app.include_router(transcription_router)
92
+ app.include_router(models_router)
93
+ app.include_router(tts_router)
94
+ app.include_router(system_router)
95
+ app.include_router(settings_router)
96
+ app.include_router(stream_router)
97
+ app.include_router(realtime_router)
98
+
99
+ # Web UI static assets (landing page + console). Served under /static so the
100
+ # HTML entry points below can reference shared CSS/JS without a build step.
101
+ app.mount("/static", StaticFiles(directory=WEBUI_DIR), name="static")
102
+
103
+
104
+ @app.get("/", tags=["health"])
105
+ async def root(request: Request):
106
+ """API health check for clients; landing page for browsers.
107
+
108
+ Browsers send ``Accept: text/html`` and get the landing page. API clients
109
+ (SDK, curl, health checks) send ``*/*`` or ``application/json`` and keep the
110
+ original JSON contract.
111
+ """
112
+ accept = request.headers.get("accept", "")
113
+ if "text/html" in accept:
114
+ return FileResponse(WEBUI_DIR / "index.html", media_type="text/html", headers={"Vary": "Accept"})
115
+ return JSONResponse(
116
+ {
117
+ "status": "ok",
118
+ "message": "Vocal API - Ollama-style voice model management",
119
+ "version": settings.VERSION,
120
+ }
121
+ )
122
+
123
+
124
+ @app.get("/welcome", include_in_schema=False)
125
+ async def welcome():
126
+ """Landing page (explicit route)."""
127
+ return FileResponse(WEBUI_DIR / "index.html", media_type="text/html")
128
+
129
+
130
+ @app.get("/ui", include_in_schema=False)
131
+ async def console():
132
+ """Web console — manage models, run speech pipelines, configure Vocal."""
133
+ return FileResponse(WEBUI_DIR / "app.html", media_type="text/html")
134
+
135
+
136
+ @app.get("/health", tags=["health"])
137
+ async def health():
138
+ """Detailed health check"""
139
+ return {
140
+ "status": "healthy",
141
+ "api_version": settings.VERSION,
142
+ }
143
+
144
+
145
+ def custom_openapi():
146
+ if app.openapi_schema:
147
+ return app.openapi_schema
148
+
149
+ openapi_schema = get_openapi(
150
+ title="Vocal API",
151
+ version=settings.VERSION,
152
+ description="Generic Speech AI Platform (STT + TTS)",
153
+ routes=app.routes,
154
+ )
155
+
156
+ app.openapi_schema = openapi_schema
157
+ return app.openapi_schema
158
+
159
+
160
+ app.openapi = custom_openapi
161
+
162
+ # Fallback static mount: serves webui assets at root-level paths (/theme.css,
163
+ # /js/app.js, ...) so the HTML entry points can use relative URLs. The same
164
+ # files then also work under a GitHub Pages subpath. Mounted LAST so every API
165
+ # route above always wins.
166
+ app.mount("/", StaticFiles(directory=WEBUI_DIR), name="webui")
@@ -25,12 +25,12 @@ class ModelBackend(str, Enum):
25
25
  FASTER_QWEN3_TTS = "faster_qwen3_tts"
26
26
  PIPER = "piper"
27
27
  CHATTERBOX = "chatterbox"
28
- XTTS = "xtts"
29
- FISH_SPEECH = "fish_speech"
30
- ORPHEUS = "orpheus"
31
- DIA = "dia"
32
28
  VOXTRAL_STT = "voxtral_stt"
33
29
  VOXTRAL_TTS = "voxtral_tts"
30
+ OMNIVOICE = "omnivoice"
31
+ SUPERTONIC = "supertonic"
32
+ VOXCPM = "voxcpm"
33
+ PHONON = "phonon"
34
34
  CUSTOM = "custom"
35
35
 
36
36
 
@@ -49,6 +49,21 @@ class ModelTask(str, Enum):
49
49
  TTS = "tts"
50
50
 
51
51
 
52
+ class ModelRuntime(str, Enum):
53
+ """How a model is executed"""
54
+
55
+ IN_PROCESS = "in_process"
56
+ EXTERNAL = "external"
57
+
58
+
59
+ class ModelMaintenanceStatus(str, Enum):
60
+ """Upstream maintenance state of the model"""
61
+
62
+ ACTIVE = "active"
63
+ RETIRED = "retired"
64
+ DEPRECATED = "deprecated"
65
+
66
+
52
67
  class ModelInfo(BaseModel):
53
68
  """Model information schema"""
54
69
 
@@ -66,6 +81,10 @@ class ModelInfo(BaseModel):
66
81
  status: ModelStatus = Field(description="Current model status")
67
82
  source_url: HttpUrl | None = None
68
83
  license: str | None = None
84
+ commercial_use: bool | None = Field(default=None, description="Whether the model weights license permits commercial use")
85
+ runtime: ModelRuntime = Field(default=ModelRuntime.IN_PROCESS, description="'in_process' when Vocal runs the model itself, 'external' when it needs an out-of-process engine")
86
+ runtime_note: str | None = Field(default=None, description="Engine/serving requirement outside Vocal's bundled adapters, if any")
87
+ maintenance_status: ModelMaintenanceStatus = Field(default=ModelMaintenanceStatus.ACTIVE, description="Upstream maintenance state (active/retired/deprecated)")
69
88
  recommended_vram: str | None = None
70
89
  task: ModelTask = Field(description="Task type")
71
90
  local_path: str | None = None
@@ -78,6 +97,7 @@ class ModelInfo(BaseModel):
78
97
  sha: str | None = Field(default=None, description="Git commit SHA")
79
98
  files: list[dict] | None = Field(default=None, description="List of model files")
80
99
  supports_streaming: bool = Field(default=False, description="Whether the model supports true streaming output")
100
+ supports_live_streaming: bool = Field(default=False, description="Whether the model supports true chunk-by-chunk live audio streaming")
81
101
  supports_voice_list: bool = Field(default=False, description="Whether the model exposes selectable voices")
82
102
  supports_voice_clone: bool = Field(default=False, description="Whether the model supports reference-audio voice cloning")
83
103
  supports_voice_design: bool = Field(default=False, description="Whether the model supports prompt/instruction-based voice design")
@@ -86,6 +106,7 @@ class ModelInfo(BaseModel):
86
106
  clone_mode: str | None = Field(default=None, description="How /v1/audio/clone works for this model")
87
107
  reference_audio_min_seconds: float | None = Field(default=None, description="Recommended minimum reference audio length for cloning")
88
108
  reference_audio_max_seconds: float | None = Field(default=None, description="Recommended maximum reference audio length for cloning")
109
+ output_formats: list[str] = Field(default_factory=list, description="Audio formats /v1/audio/speech accepts for this model (empty for STT)")
89
110
 
90
111
 
91
112
  class ModelListResponse(BaseModel):
@@ -1,5 +1,6 @@
1
1
  from .models import router as models_router
2
2
  from .realtime import router as realtime_router
3
+ from .settings import router as settings_router
3
4
  from .stream import router as stream_router
4
5
  from .system import router as system_router
5
6
  from .transcription import router as transcription_router
@@ -10,6 +11,7 @@ __all__ = [
10
11
  "models_router",
11
12
  "tts_router",
12
13
  "system_router",
14
+ "settings_router",
13
15
  "stream_router",
14
16
  "realtime_router",
15
17
  ]
@@ -46,21 +46,6 @@ async def list_catalog(
46
46
  return ModelListResponse(models=models, total=len(models))
47
47
 
48
48
 
49
- @router.get(
50
- "/{model_id:path}",
51
- response_model=ModelInfo,
52
- response_model_exclude_none=True,
53
- summary="Get model info",
54
- description="Get detailed information about a specific model",
55
- )
56
- async def get_model(model_id: str, service: ModelService = Depends(get_model_service)) -> ModelInfo:
57
- """Get detailed model information"""
58
- model = await service.get_model(model_id)
59
- if not model:
60
- raise HTTPException(404, f"Model {model_id} not found")
61
- return model
62
-
63
-
64
49
  @router.post(
65
50
  "/{model_id:path}/download",
66
51
  response_model=ModelDownloadProgress,
@@ -128,6 +113,23 @@ async def get_download_status(model_id: str, service: ModelService = Depends(get
128
113
  return status
129
114
 
130
115
 
116
+ # NOTE: the greedy {model_id:path} routes must be declared AFTER the specific
117
+ # /download and /download/status suffixes, or they swallow those paths whole.
118
+ @router.get(
119
+ "/{model_id:path}",
120
+ response_model=ModelInfo,
121
+ response_model_exclude_none=True,
122
+ summary="Get model info",
123
+ description="Get detailed information about a specific model",
124
+ )
125
+ async def get_model(model_id: str, service: ModelService = Depends(get_model_service)) -> ModelInfo:
126
+ """Get detailed model information"""
127
+ model = await service.get_model(model_id)
128
+ if not model:
129
+ raise HTTPException(404, f"Model {model_id} not found")
130
+ return model
131
+
132
+
131
133
  @router.delete("/{model_id:path}", summary="Delete model", description="Remove a downloaded model")
132
134
  async def delete_model(model_id: str, service: ModelService = Depends(get_model_service)):
133
135
  """Delete a downloaded model"""