dominus-sdk-python 2.3.0__tar.gz → 2.5.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.
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/PKG-INFO +21 -6
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/README.md +9 -5
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/__init__.py +82 -5
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/helpers/cache.py +12 -4
- dominus_sdk_python-2.5.0/dominus/namespaces/oracle/__init__.py +120 -0
- dominus_sdk_python-2.5.0/dominus/namespaces/oracle/audio_capture.py +382 -0
- dominus_sdk_python-2.5.0/dominus/namespaces/oracle/oracle_websocket.py +230 -0
- dominus_sdk_python-2.5.0/dominus/namespaces/oracle/session.py +252 -0
- dominus_sdk_python-2.5.0/dominus/namespaces/oracle/types.py +127 -0
- dominus_sdk_python-2.5.0/dominus/namespaces/oracle/vad_gate.py +276 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/start.py +26 -32
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus_sdk_python.egg-info/PKG-INFO +21 -6
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus_sdk_python.egg-info/SOURCES.txt +6 -4
- dominus_sdk_python-2.5.0/dominus_sdk_python.egg-info/requires.txt +23 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/pyproject.toml +14 -1
- dominus_sdk_python-2.3.0/dominus/namespaces/_deprecated_crossover.py +0 -10
- dominus_sdk_python-2.3.0/dominus/namespaces/_deprecated_sql.py +0 -1341
- dominus_sdk_python-2.3.0/dominus/services/_deprecated_architect.py +0 -323
- dominus_sdk_python-2.3.0/dominus/services/_deprecated_sovereign.py +0 -93
- dominus_sdk_python-2.3.0/dominus_sdk_python.egg-info/requires.txt +0 -10
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/config/__init__.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/config/endpoints.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/errors.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/helpers/__init__.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/helpers/auth.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/helpers/core.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/helpers/crypto.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/__init__.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/admin.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/auth.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/courier.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/db.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/ddl.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/fastapi.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/files.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/health.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/logs.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/open.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/portal.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/redis.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/secrets.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/namespaces/secure.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus/services/__init__.py +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus_sdk_python.egg-info/dependency_links.txt +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/dominus_sdk_python.egg-info/top_level.txt +0 -0
- {dominus_sdk_python-2.3.0 → dominus_sdk_python-2.5.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dominus-sdk-python
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: Python SDK for the Dominus Orchestrator Platform
|
|
5
5
|
Author-email: CareBridge Systems <dev@carebridge.io>
|
|
6
6
|
License: Proprietary
|
|
@@ -25,9 +25,20 @@ Requires-Dist: bcrypt>=4.0.0
|
|
|
25
25
|
Requires-Dist: cryptography>=41.0.0
|
|
26
26
|
Provides-Extra: jwt
|
|
27
27
|
Requires-Dist: PyJWT>=2.8.0; extra == "jwt"
|
|
28
|
+
Provides-Extra: oracle
|
|
29
|
+
Requires-Dist: websockets>=12.0; extra == "oracle"
|
|
30
|
+
Requires-Dist: sounddevice>=0.4.6; extra == "oracle"
|
|
31
|
+
Requires-Dist: numpy>=1.24.0; extra == "oracle"
|
|
32
|
+
Requires-Dist: webrtcvad>=2.0.10; extra == "oracle"
|
|
28
33
|
Provides-Extra: dev
|
|
29
34
|
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
30
35
|
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
36
|
+
Provides-Extra: all
|
|
37
|
+
Requires-Dist: PyJWT>=2.8.0; extra == "all"
|
|
38
|
+
Requires-Dist: websockets>=12.0; extra == "all"
|
|
39
|
+
Requires-Dist: sounddevice>=0.4.6; extra == "all"
|
|
40
|
+
Requires-Dist: numpy>=1.24.0; extra == "all"
|
|
41
|
+
Requires-Dist: webrtcvad>=2.0.10; extra == "all"
|
|
31
42
|
|
|
32
43
|
# CB Dominus SDK for Python
|
|
33
44
|
|
|
@@ -417,8 +428,8 @@ from dominus import (
|
|
|
417
428
|
ConflictError,
|
|
418
429
|
ServiceError,
|
|
419
430
|
SecureTableError,
|
|
420
|
-
|
|
421
|
-
|
|
431
|
+
DominusConnectionError, # Renamed to avoid shadowing built-in
|
|
432
|
+
DominusTimeoutError, # Renamed to avoid shadowing built-in
|
|
422
433
|
)
|
|
423
434
|
|
|
424
435
|
try:
|
|
@@ -445,6 +456,7 @@ except DominusError as e:
|
|
|
445
456
|
|
|
446
457
|
| Error | Status | Description |
|
|
447
458
|
|-------|--------|-------------|
|
|
459
|
+
| `DominusError` | - | Base class for all SDK errors |
|
|
448
460
|
| `AuthenticationError` | 401 | Invalid or missing token |
|
|
449
461
|
| `AuthorizationError` | 403 | Insufficient permissions |
|
|
450
462
|
| `NotFoundError` | 404 | Resource not found |
|
|
@@ -452,8 +464,8 @@ except DominusError as e:
|
|
|
452
464
|
| `ConflictError` | 409 | Duplicate or version conflict |
|
|
453
465
|
| `ServiceError` | 5xx | Backend service error |
|
|
454
466
|
| `SecureTableError` | 403 | Missing reason for secure table |
|
|
455
|
-
| `
|
|
456
|
-
| `
|
|
467
|
+
| `DominusConnectionError` | - | Network connection failed |
|
|
468
|
+
| `DominusTimeoutError` | 504 | Request timed out |
|
|
457
469
|
|
|
458
470
|
## Configuration
|
|
459
471
|
|
|
@@ -551,10 +563,13 @@ async def get_all_users(page_size: int = 100):
|
|
|
551
563
|
|
|
552
564
|
## Version
|
|
553
565
|
|
|
554
|
-
**v2.
|
|
566
|
+
**v2.4.0** - Full namespace parity with Node.js SDK
|
|
555
567
|
|
|
556
568
|
### Changelog
|
|
557
569
|
|
|
570
|
+
- **v2.4.0** - Full parity with Node.js SDK: all namespaces properly initialized, error classes exported, cache utilities exposed
|
|
571
|
+
- **v2.3.0** - Add comprehensive auth namespace with 100+ methods
|
|
572
|
+
- **v2.2.0** - Add DDL schema builder and migration methods
|
|
558
573
|
- **v2.1.6** - Fix navigation routes and add page scope methods
|
|
559
574
|
- **v2.1.5** - Add PSK-only client login
|
|
560
575
|
- **v2.1.4** - Make `tenant_id` optional in login methods
|
|
@@ -386,8 +386,8 @@ from dominus import (
|
|
|
386
386
|
ConflictError,
|
|
387
387
|
ServiceError,
|
|
388
388
|
SecureTableError,
|
|
389
|
-
|
|
390
|
-
|
|
389
|
+
DominusConnectionError, # Renamed to avoid shadowing built-in
|
|
390
|
+
DominusTimeoutError, # Renamed to avoid shadowing built-in
|
|
391
391
|
)
|
|
392
392
|
|
|
393
393
|
try:
|
|
@@ -414,6 +414,7 @@ except DominusError as e:
|
|
|
414
414
|
|
|
415
415
|
| Error | Status | Description |
|
|
416
416
|
|-------|--------|-------------|
|
|
417
|
+
| `DominusError` | - | Base class for all SDK errors |
|
|
417
418
|
| `AuthenticationError` | 401 | Invalid or missing token |
|
|
418
419
|
| `AuthorizationError` | 403 | Insufficient permissions |
|
|
419
420
|
| `NotFoundError` | 404 | Resource not found |
|
|
@@ -421,8 +422,8 @@ except DominusError as e:
|
|
|
421
422
|
| `ConflictError` | 409 | Duplicate or version conflict |
|
|
422
423
|
| `ServiceError` | 5xx | Backend service error |
|
|
423
424
|
| `SecureTableError` | 403 | Missing reason for secure table |
|
|
424
|
-
| `
|
|
425
|
-
| `
|
|
425
|
+
| `DominusConnectionError` | - | Network connection failed |
|
|
426
|
+
| `DominusTimeoutError` | 504 | Request timed out |
|
|
426
427
|
|
|
427
428
|
## Configuration
|
|
428
429
|
|
|
@@ -520,10 +521,13 @@ async def get_all_users(page_size: int = 100):
|
|
|
520
521
|
|
|
521
522
|
## Version
|
|
522
523
|
|
|
523
|
-
**v2.
|
|
524
|
+
**v2.4.0** - Full namespace parity with Node.js SDK
|
|
524
525
|
|
|
525
526
|
### Changelog
|
|
526
527
|
|
|
528
|
+
- **v2.4.0** - Full parity with Node.js SDK: all namespaces properly initialized, error classes exported, cache utilities exposed
|
|
529
|
+
- **v2.3.0** - Add comprehensive auth namespace with 100+ methods
|
|
530
|
+
- **v2.2.0** - Add DDL schema builder and migration methods
|
|
527
531
|
- **v2.1.6** - Fix navigation routes and add page scope methods
|
|
528
532
|
- **v2.1.5** - Add PSK-only client login
|
|
529
533
|
- **v2.1.4** - Make `tenant_id` optional in login methods
|
|
@@ -8,6 +8,10 @@ Ultra-Flat API:
|
|
|
8
8
|
value = await dominus.get("DB_URL")
|
|
9
9
|
await dominus.upsert("KEY", "value")
|
|
10
10
|
|
|
11
|
+
# Secrets namespace
|
|
12
|
+
value = await dominus.secrets.get("DB_URL")
|
|
13
|
+
await dominus.secrets.upsert("KEY", "value")
|
|
14
|
+
|
|
11
15
|
# Database (namespace-based)
|
|
12
16
|
tables = await dominus.db.tables()
|
|
13
17
|
rows = await dominus.db.query("users", filters={"status": "active"})
|
|
@@ -23,6 +27,16 @@ Ultra-Flat API:
|
|
|
23
27
|
# Files (namespace-based)
|
|
24
28
|
result = await dominus.files.upload(data=file_bytes, filename="report.pdf", category="reports")
|
|
25
29
|
|
|
30
|
+
# Redis caching
|
|
31
|
+
await dominus.redis.set("key", "value", ttl=3600)
|
|
32
|
+
value = await dominus.redis.get("key")
|
|
33
|
+
|
|
34
|
+
# Logging
|
|
35
|
+
await dominus.logs.info("Operation complete", {"user_id": user_id})
|
|
36
|
+
|
|
37
|
+
# Email
|
|
38
|
+
await dominus.courier.send("welcome", to="user@example.com", from_email="hello@app.com", model={})
|
|
39
|
+
|
|
26
40
|
# Secure table access with audit logging
|
|
27
41
|
rows = await dominus.db_secure.query("patients", context=SecureAccessContext(
|
|
28
42
|
reason="Reviewing chart",
|
|
@@ -35,11 +49,14 @@ Ultra-Flat API:
|
|
|
35
49
|
# Portal authentication
|
|
36
50
|
session = await dominus.portal.login("user@example.com", "password", "tenant-id")
|
|
37
51
|
|
|
38
|
-
# Open DSN
|
|
52
|
+
# Open DSN and raw SQL
|
|
39
53
|
dsn = await dominus.open.dsn()
|
|
54
|
+
result = await dominus.open.execute("SELECT * FROM users WHERE id = $1", {"1": user_id})
|
|
40
55
|
|
|
41
56
|
# Health
|
|
42
57
|
status = await dominus.health.check()
|
|
58
|
+
await dominus.health.ping()
|
|
59
|
+
await dominus.health.warmup()
|
|
43
60
|
|
|
44
61
|
Backward Compatible APIs:
|
|
45
62
|
# String-based API
|
|
@@ -76,11 +93,45 @@ from .namespaces.files import FilesNamespace
|
|
|
76
93
|
from .namespaces.portal import PortalNamespace
|
|
77
94
|
from .namespaces.admin import AdminNamespace
|
|
78
95
|
from .namespaces.secure import SecureNamespace, SecureAccessContext
|
|
96
|
+
from .namespaces.secrets import SecretsNamespace
|
|
97
|
+
from .namespaces.redis import RedisNamespace
|
|
98
|
+
from .namespaces.logs import LogsNamespace
|
|
99
|
+
from .namespaces.courier import CourierNamespace
|
|
100
|
+
from .namespaces.health import HealthNamespace
|
|
101
|
+
from .namespaces.open import OpenNamespace
|
|
102
|
+
|
|
103
|
+
# Export Oracle namespace for speech-to-text
|
|
104
|
+
from .namespaces.oracle import (
|
|
105
|
+
OracleNamespace,
|
|
106
|
+
OracleSession,
|
|
107
|
+
OracleSessionOptions,
|
|
108
|
+
VADState,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# Export cache and resilience utilities
|
|
112
|
+
from .helpers.cache import (
|
|
113
|
+
dominus_cache,
|
|
114
|
+
CircuitBreaker,
|
|
115
|
+
DominusCache,
|
|
116
|
+
orchestrator_circuit_breaker,
|
|
117
|
+
exponential_backoff_with_jitter,
|
|
118
|
+
)
|
|
79
119
|
|
|
80
|
-
# Export
|
|
81
|
-
from .
|
|
120
|
+
# Export error classes
|
|
121
|
+
from .errors import (
|
|
122
|
+
DominusError,
|
|
123
|
+
AuthenticationError,
|
|
124
|
+
AuthorizationError,
|
|
125
|
+
NotFoundError,
|
|
126
|
+
ValidationError,
|
|
127
|
+
ConflictError,
|
|
128
|
+
ServiceError,
|
|
129
|
+
SecureTableError,
|
|
130
|
+
ConnectionError as DominusConnectionError,
|
|
131
|
+
TimeoutError as DominusTimeoutError,
|
|
132
|
+
)
|
|
82
133
|
|
|
83
|
-
__version__ = "2.
|
|
134
|
+
__version__ = "2.5.0"
|
|
84
135
|
__all__ = [
|
|
85
136
|
# Main SDK instance
|
|
86
137
|
"dominus",
|
|
@@ -103,6 +154,32 @@ __all__ = [
|
|
|
103
154
|
"AdminNamespace",
|
|
104
155
|
"SecureNamespace",
|
|
105
156
|
"SecureAccessContext",
|
|
106
|
-
|
|
157
|
+
"SecretsNamespace",
|
|
158
|
+
"RedisNamespace",
|
|
159
|
+
"LogsNamespace",
|
|
160
|
+
"CourierNamespace",
|
|
161
|
+
"HealthNamespace",
|
|
162
|
+
"OpenNamespace",
|
|
163
|
+
# Oracle namespace for speech-to-text
|
|
164
|
+
"OracleNamespace",
|
|
165
|
+
"OracleSession",
|
|
166
|
+
"OracleSessionOptions",
|
|
167
|
+
"VADState",
|
|
168
|
+
# Cache and resilience utilities
|
|
107
169
|
"dominus_cache",
|
|
170
|
+
"CircuitBreaker",
|
|
171
|
+
"DominusCache",
|
|
172
|
+
"orchestrator_circuit_breaker",
|
|
173
|
+
"exponential_backoff_with_jitter",
|
|
174
|
+
# Error classes
|
|
175
|
+
"DominusError",
|
|
176
|
+
"AuthenticationError",
|
|
177
|
+
"AuthorizationError",
|
|
178
|
+
"NotFoundError",
|
|
179
|
+
"ValidationError",
|
|
180
|
+
"ConflictError",
|
|
181
|
+
"ServiceError",
|
|
182
|
+
"SecureTableError",
|
|
183
|
+
"DominusConnectionError",
|
|
184
|
+
"DominusTimeoutError",
|
|
108
185
|
]
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Internal cache with automatic encryption and circuit breaker.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Exports:
|
|
5
|
+
- CircuitBreaker: Circuit breaker class for resilience
|
|
6
|
+
- DominusCache: Encrypted cache class
|
|
7
|
+
- dominus_cache: Singleton cache instance
|
|
8
|
+
- orchestrator_circuit_breaker: Circuit breaker for orchestrator
|
|
9
|
+
- exponential_backoff_with_jitter: Backoff calculation utility
|
|
5
10
|
"""
|
|
6
11
|
import time
|
|
7
12
|
import json
|
|
@@ -181,12 +186,15 @@ class DominusCache:
|
|
|
181
186
|
return count
|
|
182
187
|
|
|
183
188
|
|
|
184
|
-
#
|
|
189
|
+
# Singleton instances
|
|
185
190
|
dominus_cache = DominusCache(default_ttl=300)
|
|
186
191
|
|
|
187
|
-
# Circuit
|
|
188
|
-
|
|
192
|
+
# Circuit breaker for orchestrator (prevents retry storms)
|
|
193
|
+
orchestrator_circuit_breaker = CircuitBreaker(
|
|
189
194
|
failure_threshold=5, # Open after 5 consecutive failures
|
|
190
195
|
recovery_timeout=30.0, # Try again after 30 seconds
|
|
191
196
|
half_open_max_calls=1 # Allow 1 test call in half-open state
|
|
192
197
|
)
|
|
198
|
+
|
|
199
|
+
# Backward compatibility alias
|
|
200
|
+
sovereign_circuit_breaker = orchestrator_circuit_breaker
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Oracle Namespace - Real-time streaming speech-to-text.
|
|
3
|
+
|
|
4
|
+
Provides WebSocket-based streaming transcription via Deepgram,
|
|
5
|
+
with built-in VAD (Voice Activity Detection) for cost optimization.
|
|
6
|
+
|
|
7
|
+
Key features:
|
|
8
|
+
- Automatic microphone capture and 16kHz resampling
|
|
9
|
+
- VAD gating: only sends audio when speech is detected
|
|
10
|
+
- 4-state VAD machine: IDLE -> ARMED -> SPEAKING -> TRAILING
|
|
11
|
+
- Pre-roll buffer captures word onsets
|
|
12
|
+
- Ping/pong keepalive during IDLE
|
|
13
|
+
- NO send_audio() exposed - VAD handles everything
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
session = dominus.oracle.create_session(user_jwt)
|
|
17
|
+
|
|
18
|
+
session.on_ready = lambda: set_listening(True)
|
|
19
|
+
session.on_interim = lambda text: set_live_transcript(text)
|
|
20
|
+
session.on_utterance = lambda text: send_to_curator(text)
|
|
21
|
+
session.on_vad_state_change = lambda state: set_mic_state(state)
|
|
22
|
+
session.on_error = lambda error: show_error(error)
|
|
23
|
+
|
|
24
|
+
await session.start()
|
|
25
|
+
# ... user speaks, transcripts flow back ...
|
|
26
|
+
await session.stop()
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
from typing import Optional, TYPE_CHECKING
|
|
30
|
+
|
|
31
|
+
from .types import (
|
|
32
|
+
VADState,
|
|
33
|
+
OracleSessionOptions,
|
|
34
|
+
ResolvedOracleSessionOptions,
|
|
35
|
+
DEFAULT_OPTIONS,
|
|
36
|
+
AUDIO_CONFIG,
|
|
37
|
+
)
|
|
38
|
+
from .session import OracleSession
|
|
39
|
+
|
|
40
|
+
if TYPE_CHECKING:
|
|
41
|
+
from ...start import Dominus
|
|
42
|
+
|
|
43
|
+
# Re-export public types
|
|
44
|
+
__all__ = [
|
|
45
|
+
"OracleNamespace",
|
|
46
|
+
"OracleSession",
|
|
47
|
+
"OracleSessionOptions",
|
|
48
|
+
"VADState",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class OracleNamespace:
|
|
53
|
+
"""
|
|
54
|
+
OracleNamespace - Factory for creating streaming transcription sessions.
|
|
55
|
+
|
|
56
|
+
The Oracle namespace provides a simple API for real-time speech-to-text:
|
|
57
|
+
- create_session() creates a new transcription session
|
|
58
|
+
- Sessions handle mic capture, VAD, WebSocket, and transcripts internally
|
|
59
|
+
- NO raw audio access - VAD is mandatory for cost control
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
def __init__(self, client: "Dominus"):
|
|
63
|
+
from ...config.endpoints import BASE_URL
|
|
64
|
+
self._base_url = BASE_URL
|
|
65
|
+
self._client = client
|
|
66
|
+
|
|
67
|
+
def create_session(
|
|
68
|
+
self,
|
|
69
|
+
user_token: str,
|
|
70
|
+
options: Optional[OracleSessionOptions] = None
|
|
71
|
+
) -> OracleSession:
|
|
72
|
+
"""
|
|
73
|
+
Create a streaming transcription session.
|
|
74
|
+
|
|
75
|
+
The session handles everything internally:
|
|
76
|
+
- Microphone access and audio capture
|
|
77
|
+
- Resampling to 16kHz mono PCM
|
|
78
|
+
- VAD gating (only sends speech, not silence)
|
|
79
|
+
- WebSocket connection to Oracle
|
|
80
|
+
- Reconnection on connection loss
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
user_token: User JWT from portal.login()
|
|
84
|
+
options: Optional configuration overrides
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
OracleSession ready to start()
|
|
88
|
+
|
|
89
|
+
Example:
|
|
90
|
+
session = dominus.oracle.create_session(user_jwt, OracleSessionOptions(
|
|
91
|
+
preroll_ms=320, # Capture 320ms before speech
|
|
92
|
+
postroll_ms=400, # Continue 400ms after speech
|
|
93
|
+
armed_confirm_ms=80, # Require 80ms to confirm speech
|
|
94
|
+
))
|
|
95
|
+
|
|
96
|
+
session.on_utterance = lambda text: send_to_curator(text)
|
|
97
|
+
|
|
98
|
+
await session.start()
|
|
99
|
+
"""
|
|
100
|
+
# Merge options with defaults
|
|
101
|
+
if options:
|
|
102
|
+
resolved_options = ResolvedOracleSessionOptions(
|
|
103
|
+
preroll_ms=options.preroll_ms if options.preroll_ms != DEFAULT_OPTIONS.preroll_ms else DEFAULT_OPTIONS.preroll_ms,
|
|
104
|
+
postroll_ms=options.postroll_ms if options.postroll_ms != DEFAULT_OPTIONS.postroll_ms else DEFAULT_OPTIONS.postroll_ms,
|
|
105
|
+
armed_confirm_ms=options.armed_confirm_ms if options.armed_confirm_ms != DEFAULT_OPTIONS.armed_confirm_ms else DEFAULT_OPTIONS.armed_confirm_ms,
|
|
106
|
+
vad_threshold=options.vad_threshold if options.vad_threshold != DEFAULT_OPTIONS.vad_threshold else DEFAULT_OPTIONS.vad_threshold,
|
|
107
|
+
energy_threshold=options.energy_threshold if options.energy_threshold != DEFAULT_OPTIONS.energy_threshold else DEFAULT_OPTIONS.energy_threshold,
|
|
108
|
+
ping_interval_ms=options.ping_interval_ms if options.ping_interval_ms != DEFAULT_OPTIONS.ping_interval_ms else DEFAULT_OPTIONS.ping_interval_ms,
|
|
109
|
+
)
|
|
110
|
+
else:
|
|
111
|
+
resolved_options = ResolvedOracleSessionOptions(
|
|
112
|
+
preroll_ms=DEFAULT_OPTIONS.preroll_ms,
|
|
113
|
+
postroll_ms=DEFAULT_OPTIONS.postroll_ms,
|
|
114
|
+
armed_confirm_ms=DEFAULT_OPTIONS.armed_confirm_ms,
|
|
115
|
+
vad_threshold=DEFAULT_OPTIONS.vad_threshold,
|
|
116
|
+
energy_threshold=DEFAULT_OPTIONS.energy_threshold,
|
|
117
|
+
ping_interval_ms=DEFAULT_OPTIONS.ping_interval_ms,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
return OracleSession(self._base_url, user_token, resolved_options)
|