ringglabs 0.0.2__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.
Potentially problematic release.
This version of ringglabs might be problematic. Click here for more details.
- ringglabs-0.0.2/LICENSE +21 -0
- ringglabs-0.0.2/PKG-INFO +375 -0
- ringglabs-0.0.2/README.md +343 -0
- ringglabs-0.0.2/pyproject.toml +58 -0
- ringglabs-0.0.2/setup.cfg +4 -0
- ringglabs-0.0.2/src/ringglabs/__init__.py +3 -0
- ringglabs-0.0.2/src/ringglabs/py.typed +1 -0
- ringglabs-0.0.2/src/ringglabs/stt/__init__.py +58 -0
- ringglabs-0.0.2/src/ringglabs/stt/_http.py +238 -0
- ringglabs-0.0.2/src/ringglabs/stt/_io.py +30 -0
- ringglabs-0.0.2/src/ringglabs/stt/_serialization.py +151 -0
- ringglabs-0.0.2/src/ringglabs/stt/_ws_async.py +152 -0
- ringglabs-0.0.2/src/ringglabs/stt/_ws_sync.py +156 -0
- ringglabs-0.0.2/src/ringglabs/stt/async_client.py +170 -0
- ringglabs-0.0.2/src/ringglabs/stt/client.py +170 -0
- ringglabs-0.0.2/src/ringglabs/stt/config.py +131 -0
- ringglabs-0.0.2/src/ringglabs/stt/enums.py +25 -0
- ringglabs-0.0.2/src/ringglabs/stt/errors.py +46 -0
- ringglabs-0.0.2/src/ringglabs/stt/models.py +156 -0
- ringglabs-0.0.2/src/ringglabs/stt/retry.py +64 -0
- ringglabs-0.0.2/src/ringglabs.egg-info/PKG-INFO +375 -0
- ringglabs-0.0.2/src/ringglabs.egg-info/SOURCES.txt +29 -0
- ringglabs-0.0.2/src/ringglabs.egg-info/dependency_links.txt +1 -0
- ringglabs-0.0.2/src/ringglabs.egg-info/requires.txt +6 -0
- ringglabs-0.0.2/src/ringglabs.egg-info/top_level.txt +1 -0
- ringglabs-0.0.2/tests/test_config.py +27 -0
- ringglabs-0.0.2/tests/test_release_metadata.py +50 -0
- ringglabs-0.0.2/tests/test_rest_client.py +130 -0
- ringglabs-0.0.2/tests/test_serialization.py +34 -0
- ringglabs-0.0.2/tests/test_validation.py +37 -0
- ringglabs-0.0.2/tests/test_ws_session.py +131 -0
ringglabs-0.0.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RinggLabs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ringglabs-0.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ringglabs
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Production-grade Python SDK for RinggLabs STT over REST and WebSocket.
|
|
5
|
+
Author-email: RinggLabs <support@ringg.ai>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Stonkr/ringglabs-sdk
|
|
8
|
+
Project-URL: Documentation, https://github.com/Stonkr/ringglabs-sdk/tree/main/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/Stonkr/ringglabs-sdk
|
|
10
|
+
Project-URL: Issues, https://github.com/Stonkr/ringglabs-sdk/issues
|
|
11
|
+
Keywords: stt,speech-to-text,asr,websocket,ringglabs
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
20
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
21
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: httpx<1.0.0,>=0.27.0
|
|
27
|
+
Requires-Dist: websockets<16.0,>=12.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest<9.0,>=8.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-asyncio<1.0,>=0.23; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<img src="assets/logo/image.png" alt="RinggLabs" width="1000" />
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
# RinggLabs Python SDK
|
|
38
|
+
|
|
39
|
+
`ringglabs` is the Python SDK for RinggLabs-compatible STT services over REST and WebSocket.
|
|
40
|
+
|
|
41
|
+
## What it supports
|
|
42
|
+
|
|
43
|
+
- Sync and async clients
|
|
44
|
+
- Stream modes: `stream` and `on_final`
|
|
45
|
+
- Optional client VAD event signaling
|
|
46
|
+
- Typed response/event objects with full raw server payloads
|
|
47
|
+
- Configurable HTTP and WebSocket timeouts
|
|
48
|
+
- No implicit retries (opt-in retry helpers are available)
|
|
49
|
+
|
|
50
|
+
## Compatibility
|
|
51
|
+
|
|
52
|
+
- Python: `3.10+`
|
|
53
|
+
- Windows: `10+`
|
|
54
|
+
- macOS: `11+`
|
|
55
|
+
- Ubuntu: `20.04+`
|
|
56
|
+
|
|
57
|
+
## Install
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install ringglabs
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## API reference
|
|
64
|
+
|
|
65
|
+
### Core clients
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from ringglabs.stt import Client, AsyncClient
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`Client` constructor:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
Client(
|
|
75
|
+
base_url: str | None = None,
|
|
76
|
+
rest_endpoint: str | None = None,
|
|
77
|
+
ws_endpoint: str | None = None,
|
|
78
|
+
api_key: str | None = None,
|
|
79
|
+
timeout: TimeoutConfig | None = None,
|
|
80
|
+
rest_path: str = "/parrot-stt/v1/transcriptions",
|
|
81
|
+
ws_path: str = "/parrot-stt/v1/stream",
|
|
82
|
+
default_headers: dict[str, str] | None = None,
|
|
83
|
+
)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`AsyncClient` has the same constructor parameters.
|
|
87
|
+
|
|
88
|
+
`Client` public methods:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
transcribe(...)
|
|
92
|
+
stream(...)
|
|
93
|
+
health(...)
|
|
94
|
+
close()
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`AsyncClient` public methods:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
await transcribe(...)
|
|
101
|
+
stream(...)
|
|
102
|
+
await health(...)
|
|
103
|
+
await close()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Health check example
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from ringglabs.stt import Client
|
|
110
|
+
|
|
111
|
+
client = Client(base_url="http://localhost:7860")
|
|
112
|
+
health = client.health()
|
|
113
|
+
print(health)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Streaming parameters (public API)
|
|
117
|
+
|
|
118
|
+
These are the parameters accepted by `stream(...)` on both `Client` and `AsyncClient`.
|
|
119
|
+
|
|
120
|
+
| Parameter | Type | Default | Description |
|
|
121
|
+
|---|---|---|---|
|
|
122
|
+
| `sample_rate` | `int` | `16000` | Audio sample rate for stream config. |
|
|
123
|
+
| `encoding` | `str` | `"int16"` | Audio encoding (`int16`, `linear16`, `float32`, `int32`). |
|
|
124
|
+
| `language` | `str` | `"hi"` | Language sent to server. |
|
|
125
|
+
| `mode` | `str` | `"stream"` | Streaming mode (`stream` or `on_final`). |
|
|
126
|
+
| `vad_tail_sil_ms` | `int` | `200` | Server VAD tail silence duration in ms. |
|
|
127
|
+
| `vad_confidence` | `float` | `0.55` | Server VAD confidence threshold. |
|
|
128
|
+
| `enable_cap_punc` | `bool` | `True` | Request punctuation/capitalization from server. |
|
|
129
|
+
| `accept_client_vad_events` | `bool` | `False` | Whether client sends speaking boundary events. |
|
|
130
|
+
| `api_key` | `str \| None` | `None` | Per-session API key override. |
|
|
131
|
+
|
|
132
|
+
### Streaming behavior and client VAD events
|
|
133
|
+
|
|
134
|
+
- `mode="stream"`:
|
|
135
|
+
- Server emits segment-level final transcripts during the session.
|
|
136
|
+
- `mode="on_final"`:
|
|
137
|
+
- Server emits partial transcript updates and a final transcript at finalization boundaries.
|
|
138
|
+
- `accept_client_vad_events=False`:
|
|
139
|
+
- You only send audio chunks and `end()`.
|
|
140
|
+
- Server-side logic controls segmentation/finalization behavior.
|
|
141
|
+
- `accept_client_vad_events=True`:
|
|
142
|
+
- Call `start_speaking()` when user starts speech and `stop_speaking()` when user stops.
|
|
143
|
+
- This explicitly marks speech spans and improves control over finalization timing.
|
|
144
|
+
|
|
145
|
+
## Streaming examples
|
|
146
|
+
|
|
147
|
+
### Sync streaming (`mode="stream"`, no client VAD events)
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from ringglabs.stt import Client
|
|
151
|
+
|
|
152
|
+
client = Client(
|
|
153
|
+
ws_endpoint="wss://your-host/parrot-stt/v1/stream",
|
|
154
|
+
api_key="rk_live_xxx",
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
with client.stream(
|
|
158
|
+
language="en",
|
|
159
|
+
mode="stream",
|
|
160
|
+
accept_client_vad_events=False,
|
|
161
|
+
) as session:
|
|
162
|
+
session.send_audio(b"...pcm chunk 1...")
|
|
163
|
+
session.send_audio(b"...pcm chunk 2...")
|
|
164
|
+
session.end()
|
|
165
|
+
|
|
166
|
+
for event in session.events():
|
|
167
|
+
print(event.type, event.raw)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Sync streaming (`mode="on_final"` with client VAD events)
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from ringglabs.stt import Client
|
|
174
|
+
|
|
175
|
+
client = Client(
|
|
176
|
+
ws_endpoint="wss://your-host/parrot-stt/v1/stream",
|
|
177
|
+
api_key="rk_live_xxx",
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
with client.stream(
|
|
181
|
+
language="hi",
|
|
182
|
+
mode="on_final",
|
|
183
|
+
vad_tail_sil_ms=200,
|
|
184
|
+
vad_confidence=0.55,
|
|
185
|
+
enable_cap_punc=True,
|
|
186
|
+
accept_client_vad_events=True,
|
|
187
|
+
) as session:
|
|
188
|
+
session.start_speaking()
|
|
189
|
+
session.send_audio(b"...speech chunk 1...")
|
|
190
|
+
session.send_audio(b"...speech chunk 2...")
|
|
191
|
+
session.stop_speaking()
|
|
192
|
+
session.end()
|
|
193
|
+
|
|
194
|
+
for event in session.events():
|
|
195
|
+
print(event.type, event.raw)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Async streaming (`mode="on_final"` with client VAD events)
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
import asyncio
|
|
202
|
+
from ringglabs.stt import AsyncClient
|
|
203
|
+
|
|
204
|
+
async def main():
|
|
205
|
+
client = AsyncClient(
|
|
206
|
+
ws_endpoint="wss://your-host/parrot-stt/v1/stream",
|
|
207
|
+
api_key="rk_live_xxx",
|
|
208
|
+
)
|
|
209
|
+
async with client.stream(
|
|
210
|
+
language="en",
|
|
211
|
+
mode="on_final",
|
|
212
|
+
vad_tail_sil_ms=200,
|
|
213
|
+
vad_confidence=0.55,
|
|
214
|
+
accept_client_vad_events=True,
|
|
215
|
+
) as session:
|
|
216
|
+
await session.start_speaking()
|
|
217
|
+
await session.send_audio(b"...speech chunk...")
|
|
218
|
+
await session.stop_speaking()
|
|
219
|
+
await session.end()
|
|
220
|
+
|
|
221
|
+
async for event in session.events():
|
|
222
|
+
print(event.type, event.raw)
|
|
223
|
+
|
|
224
|
+
asyncio.run(main())
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## REST parameters (public API)
|
|
228
|
+
|
|
229
|
+
These parameters are accepted by `transcribe(...)`.
|
|
230
|
+
|
|
231
|
+
| Parameter | Type | Default | Description |
|
|
232
|
+
|---|---|---|---|
|
|
233
|
+
| `language` | `str` | `"hi"` | Language sent to server. |
|
|
234
|
+
| `enable_cap_punc` | `bool` | `True` | Request punctuation/capitalization in output. |
|
|
235
|
+
| `api_key` | `str \| None` | `None` | Per-request API key override. |
|
|
236
|
+
| `content_type` | `str` | `"audio/wav"` | Multipart file content type. |
|
|
237
|
+
| `filename` | `str \| None` | Auto-detected, fallback `"audio.wav"` | Multipart filename used in upload. |
|
|
238
|
+
|
|
239
|
+
`source` accepted by `transcribe(...)`:
|
|
240
|
+
- file path (`str` / `pathlib.Path`)
|
|
241
|
+
- raw bytes (`bytes` / `bytearray`)
|
|
242
|
+
- file-like object (`BinaryIO`)
|
|
243
|
+
|
|
244
|
+
## REST `/file` examples
|
|
245
|
+
|
|
246
|
+
### Sync REST file transcription
|
|
247
|
+
|
|
248
|
+
```python
|
|
249
|
+
from ringglabs.stt import Client
|
|
250
|
+
|
|
251
|
+
client = Client(
|
|
252
|
+
rest_endpoint="https://your-host/parrot-stt/v1/transcriptions",
|
|
253
|
+
api_key="rk_live_xxx",
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
result = client.transcribe(
|
|
257
|
+
"sample.wav",
|
|
258
|
+
language="en",
|
|
259
|
+
enable_cap_punc=True,
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
print(result.transcription)
|
|
263
|
+
print(result.request_id)
|
|
264
|
+
print(result.raw) # full server response
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Async REST file transcription
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
import asyncio
|
|
271
|
+
from ringglabs.stt import AsyncClient
|
|
272
|
+
|
|
273
|
+
async def main():
|
|
274
|
+
async with AsyncClient(
|
|
275
|
+
rest_endpoint="https://your-host/parrot-stt/v1/transcriptions",
|
|
276
|
+
api_key="rk_live_xxx",
|
|
277
|
+
) as client:
|
|
278
|
+
result = await client.transcribe(
|
|
279
|
+
"sample.wav",
|
|
280
|
+
language="hi",
|
|
281
|
+
enable_cap_punc=True,
|
|
282
|
+
)
|
|
283
|
+
print(result.transcription)
|
|
284
|
+
print(result.request_id)
|
|
285
|
+
print(result.raw)
|
|
286
|
+
|
|
287
|
+
asyncio.run(main())
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Response reference
|
|
291
|
+
|
|
292
|
+
### REST result (`RestTranscriptionResult`)
|
|
293
|
+
|
|
294
|
+
- `status`
|
|
295
|
+
- `transcription`
|
|
296
|
+
- `is_final`
|
|
297
|
+
- `language`
|
|
298
|
+
- `duration_seconds`
|
|
299
|
+
- `processing_time_seconds`
|
|
300
|
+
- `request_id`
|
|
301
|
+
- `raw` (full server JSON payload)
|
|
302
|
+
|
|
303
|
+
### WebSocket event types
|
|
304
|
+
|
|
305
|
+
- `ready`
|
|
306
|
+
- `transcript`
|
|
307
|
+
- `ack`
|
|
308
|
+
- `pong`
|
|
309
|
+
- `error`
|
|
310
|
+
|
|
311
|
+
All parsed events include `raw` with the original server payload.
|
|
312
|
+
|
|
313
|
+
`transcript` events can include:
|
|
314
|
+
- `transcription`
|
|
315
|
+
- `is_final`
|
|
316
|
+
- `language`
|
|
317
|
+
- `request_id`
|
|
318
|
+
- `segment_idx`
|
|
319
|
+
- `segments`
|
|
320
|
+
- `compute_latency_ms`
|
|
321
|
+
- `audio_duration_sec`
|
|
322
|
+
- `transcribed_audio_duration_sec`
|
|
323
|
+
- `processing_time_ms`
|
|
324
|
+
|
|
325
|
+
## Error handling
|
|
326
|
+
|
|
327
|
+
```python
|
|
328
|
+
from ringglabs.stt import Client, ApiError, TimeoutError, TransportError
|
|
329
|
+
|
|
330
|
+
client = Client(rest_endpoint="https://your-host/parrot-stt/v1/transcriptions", api_key="...")
|
|
331
|
+
|
|
332
|
+
try:
|
|
333
|
+
result = client.transcribe("sample.wav")
|
|
334
|
+
except TimeoutError:
|
|
335
|
+
print("request timed out")
|
|
336
|
+
except TransportError:
|
|
337
|
+
print("network/connection failure")
|
|
338
|
+
except ApiError as exc:
|
|
339
|
+
print(exc.status_code, exc.code, exc.message)
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Notes
|
|
343
|
+
|
|
344
|
+
- SDK forwards request parameters to server; server is source of truth for validation.
|
|
345
|
+
- Configure connection budgets via `TimeoutConfig` (`connect`, `read`, `write`, `pool`, `ws_open`, `ws_recv`, `ws_close`).
|
|
346
|
+
- SDK does not auto-retry by default; use explicit retry helpers only where safe.
|
|
347
|
+
|
|
348
|
+
## E2E test script
|
|
349
|
+
|
|
350
|
+
Use the bundled script to validate all SDK flows (sync/async REST + sync/async WS `stream` + sync/async WS `on_final` with client VAD events).
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
python examples/test_stt_e2e.py \
|
|
354
|
+
--ws-url ws://localhost:7860/parrot-stt/v1/stream \
|
|
355
|
+
--rest-url http://localhost:7860/parrot-stt/v1/transcriptions \
|
|
356
|
+
--audio-dir /path/to/wav/audio_dir \
|
|
357
|
+
--max-files 3
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Optional auth:
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
RINGGLABS_API_KEY=<your_key> python examples/test_stt_e2e.py
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Or set audio dir via env:
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
RINGGLABS_AUDIO_DIR=/path/to/wav/audio_dir python examples/test_stt_e2e.py
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Additional docs
|
|
373
|
+
|
|
374
|
+
- [Production patterns](docs/production-patterns.md)
|
|
375
|
+
- [Public PyPI release guide](docs/release-public-pypi.md)
|