soniox 2.2.0__tar.gz → 2.3.1__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.
- {soniox-2.2.0 → soniox-2.3.1}/CHANGELOG.md +22 -0
- {soniox-2.2.0 → soniox-2.3.1}/PKG-INFO +64 -9
- soniox-2.3.1/README.md +149 -0
- {soniox-2.2.0 → soniox-2.3.1}/docs/async_client.md +136 -3
- soniox-2.3.1/docs/realtime_client.md +2217 -0
- soniox-2.3.1/docs/soniox/__init__.md +282 -0
- soniox-2.3.1/docs/soniox/api/__init__.md +1968 -0
- soniox-2.3.1/docs/soniox/api/api__utils.md +112 -0
- soniox-2.3.1/docs/soniox/api/api_async_auth.md +61 -0
- soniox-2.3.1/docs/soniox/api/api_async_files.md +239 -0
- soniox-2.3.1/docs/soniox/api/api_async_models.md +55 -0
- soniox-2.3.1/docs/soniox/api/api_async_stt.md +595 -0
- soniox-2.3.1/docs/soniox/api/api_async_transcriptions.md +546 -0
- soniox-2.3.1/docs/soniox/api/api_async_webhooks.md +10 -0
- soniox-2.3.1/docs/soniox/api/api_auth.md +61 -0
- soniox-2.3.1/docs/soniox/api/api_files.md +239 -0
- soniox-2.3.1/docs/soniox/api/api_models.md +55 -0
- soniox-2.3.1/docs/soniox/api/api_stt.md +595 -0
- soniox-2.3.1/docs/soniox/api/api_transcriptions.md +546 -0
- soniox-2.3.1/docs/soniox/api/api_webhooks.md +152 -0
- soniox-2.3.1/docs/soniox/realtime/__init__.md +1148 -0
- soniox-2.3.1/docs/soniox/realtime/realtime__utils.md +194 -0
- soniox-2.3.1/docs/soniox/realtime/realtime_async_stt.md +548 -0
- soniox-2.3.1/docs/soniox/realtime/realtime_stt.md +546 -0
- soniox-2.3.1/docs/soniox/soniox_client.md +346 -0
- soniox-2.3.1/docs/soniox/soniox_errors.md +204 -0
- soniox-2.3.1/docs/soniox/soniox_utils.md +195 -0
- soniox-2.3.1/docs/soniox/types/__init__.md +532 -0
- soniox-2.3.1/docs/soniox/types/types_api.md +400 -0
- soniox-2.3.1/docs/soniox/types/types_common.md +34 -0
- soniox-2.3.1/docs/soniox/types/types_realtime.md +112 -0
- soniox-2.3.1/docs/soniox/types/types_webhooks.md +30 -0
- {soniox-2.2.0 → soniox-2.3.1}/docs/types.md +239 -1
- soniox-2.3.1/examples/async_soniox_client/tts_api_example.py +40 -0
- soniox-2.3.1/examples/async_soniox_client/tts_realtime_example.py +65 -0
- soniox-2.3.1/examples/async_soniox_client/tts_realtime_multiplexed_example.py +147 -0
- soniox-2.3.1/examples/soniox_client/tts_api_example.py +38 -0
- soniox-2.3.1/examples/soniox_client/tts_realtime_example.py +67 -0
- soniox-2.3.1/examples/soniox_client/tts_realtime_multiplexed_example.py +147 -0
- {soniox-2.2.0 → soniox-2.3.1}/justfile +0 -1
- {soniox-2.2.0 → soniox-2.3.1}/pyproject.toml +1 -1
- {soniox-2.2.0 → soniox-2.3.1}/scripts/generate_docs.py +13 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/__init__.py +8 -0
- soniox-2.3.1/src/soniox/api/async_tts.py +98 -0
- soniox-2.3.1/src/soniox/api/async_tts_models.py +26 -0
- soniox-2.3.1/src/soniox/api/tts.py +98 -0
- soniox-2.3.1/src/soniox/api/tts_models.py +26 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/client.py +42 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/errors.py +20 -1
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/realtime/__init__.py +41 -1
- soniox-2.3.1/src/soniox/realtime/_constants.py +3 -0
- soniox-2.3.1/src/soniox/realtime/async_tts.py +554 -0
- soniox-2.3.1/src/soniox/realtime/tts.py +546 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/types/__init__.py +26 -1
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/types/api.py +96 -0
- soniox-2.3.1/src/soniox/types/realtime.py +205 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/utils.py +36 -0
- soniox-2.2.0/README.md +0 -94
- soniox-2.2.0/docs/realtime_client.md +0 -899
- soniox-2.2.0/src/soniox/types/realtime.py +0 -103
- {soniox-2.2.0 → soniox-2.3.1}/.gitignore +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/LICENSE +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/assets/coffee_shop.mp3 +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/assets/coffee_shop.pcm_s16le +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/assets/two_way_translation.mp3 +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/assets/two_way_translation.pcm_s16le +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/examples/async_soniox_client/api_example.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/examples/async_soniox_client/realtime_example.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/examples/soniox_client/api_example.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/examples/soniox_client/realtime_example.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/__init__.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/_utils.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/async_auth.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/async_files.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/async_models.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/async_stt.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/async_webhooks.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/auth.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/files.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/models.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/stt.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/api/webhooks.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/realtime/_utils.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/realtime/async_stt.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/realtime/stt.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/types/common.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/src/soniox/types/webhooks.py +0 -0
- {soniox-2.2.0 → soniox-2.3.1}/uv.lock +0 -0
|
@@ -77,6 +77,28 @@ Examples:
|
|
|
77
77
|
|
|
78
78
|
---
|
|
79
79
|
|
|
80
|
+
## [2.3.1] - 29 apr 2026
|
|
81
|
+
|
|
82
|
+
### Changed
|
|
83
|
+
|
|
84
|
+
- Default TTS model is now `tts-rt-v1` (previously `tts-rt-v1-preview`).
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## [2.3.0] - 22 apr 2026
|
|
89
|
+
|
|
90
|
+
### Added
|
|
91
|
+
|
|
92
|
+
- Text-to-Speech (TTS) support, available on both `SonioxClient` and `AsyncSonioxClient`.
|
|
93
|
+
- REST TTS API via `client.tts`: `generate()` returns audio bytes, `generate_to_file()` writes audio to a path or file-like object. Configurable `voice`, `model`, `language`, `audio_format`, `sample_rate`, and `bitrate`.
|
|
94
|
+
- TTS model listing via `client.tts_models.list()`.
|
|
95
|
+
- Realtime TTS over websocket via `client.realtime.tts.connect(...)`: stream text in with `send_text_chunk` / `send_text_chunks` / `finish`, receive audio with `receive_audio_chunks` or raw events with `receive_events`, plus `cancel`, `pause`, `resume`, and `keep_alive`.
|
|
96
|
+
- Multiplexed realtime TTS via `client.realtime.tts.connect_multi_stream()`: run multiple concurrent TTS streams over a single websocket connection using `open_stream`.
|
|
97
|
+
- New TTS examples for sync and async clients (REST, realtime, and multiplexed realtime).
|
|
98
|
+
- `tts_api_base_url` and `tts_websocket_base_url` client options for overriding TTS endpoints.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
80
102
|
## [2.2.0] - 25 feb 2026
|
|
81
103
|
|
|
82
104
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: soniox
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.1
|
|
4
4
|
Summary: The official Python SDK for the Soniox API (STT, REST)
|
|
5
5
|
Project-URL: Homepage, https://sonoix.com
|
|
6
6
|
Project-URL: Documentation, https://soniox.com/docs
|
|
@@ -37,8 +37,10 @@ Description-Content-Type: text/markdown
|
|
|
37
37
|
|
|
38
38
|
# Soniox Python SDK
|
|
39
39
|
|
|
40
|
-
The SDK exposes two clients: `SonioxClient` (sync) and `AsyncSonioxClient
|
|
41
|
-
|
|
40
|
+
The SDK exposes two clients: `SonioxClient` (sync) and `AsyncSonioxClient` (async). Each client supports:
|
|
41
|
+
- STT over REST (`client.stt`) and realtime WebSocket (`client.realtime.stt`)
|
|
42
|
+
- TTS over REST (`client.tts`) and realtime WebSocket (`client.realtime.tts`)
|
|
43
|
+
- auth, file uploads, model listing, webhooks, and typed request/response models
|
|
42
44
|
|
|
43
45
|
## Install
|
|
44
46
|
|
|
@@ -51,9 +53,9 @@ export SONIOX_API_KEY=<your-key>
|
|
|
51
53
|
|
|
52
54
|
Get your API key from the [Soniox Console](https://console.soniox.com) and inject it once per shell session. Both clients read `SONIOX_API_KEY` by default, but you can override it per-client if needed.
|
|
53
55
|
|
|
54
|
-
## Quick run (
|
|
56
|
+
## Quick run (STT + TTS, REST + realtime)
|
|
55
57
|
|
|
56
|
-
1. **REST transcription**: copy this snippet or run [`examples/soniox_client/api_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/soniox_client/api_example.py).
|
|
58
|
+
1. **REST STT transcription**: copy this snippet or run [`examples/soniox_client/api_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/soniox_client/api_example.py).
|
|
57
59
|
|
|
58
60
|
```python
|
|
59
61
|
from soniox import SonioxClient
|
|
@@ -67,7 +69,29 @@ client.stt.wait(transcription.id, timeout_sec=60)
|
|
|
67
69
|
print(client.stt.get_transcript(transcription.id).text[:200])
|
|
68
70
|
```
|
|
69
71
|
|
|
70
|
-
2. **
|
|
72
|
+
2. **REST TTS generation**: convert text to an audio file.
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from soniox import SonioxClient
|
|
76
|
+
from soniox.utils import output_file_for_audio_format
|
|
77
|
+
|
|
78
|
+
client = SonioxClient()
|
|
79
|
+
output_file = output_file_for_audio_format("wav", "tts_sync_output")
|
|
80
|
+
written = client.tts.generate_to_file(
|
|
81
|
+
output_file,
|
|
82
|
+
text="Hello from Soniox Python SDK Text-to-Speech.",
|
|
83
|
+
model="tts-rt-v1",
|
|
84
|
+
language="en",
|
|
85
|
+
voice="Adrian",
|
|
86
|
+
audio_format="wav",
|
|
87
|
+
)
|
|
88
|
+
print(f"Wrote {written} bytes to {output_file.resolve()}")
|
|
89
|
+
client.close()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Run the full example at [`examples/soniox_client/tts_api_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/soniox_client/tts_api_example.py) or async version at [`examples/async_soniox_client/tts_api_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/async_soniox_client/tts_api_example.py).
|
|
93
|
+
|
|
94
|
+
3. **Realtime STT streaming**: open `client.realtime.stt.connect`, call `session.send_byte_chunk` or `session.send_bytes`, then iterate `session.receive_events()` to render tokens:
|
|
71
95
|
|
|
72
96
|
```python
|
|
73
97
|
from soniox import SonioxClient
|
|
@@ -96,15 +120,46 @@ def realtime():
|
|
|
96
120
|
realtime()
|
|
97
121
|
```
|
|
98
122
|
|
|
99
|
-
|
|
123
|
+
See [`examples/soniox_client/realtime_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/soniox_client/realtime_example.py) for the full flow.
|
|
124
|
+
|
|
125
|
+
4. **Realtime TTS streaming**: send text chunks and read generated audio chunks from the session.
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from uuid import uuid4
|
|
129
|
+
|
|
130
|
+
from soniox import SonioxClient
|
|
131
|
+
from soniox.types import RealtimeTTSConfig
|
|
132
|
+
|
|
133
|
+
client = SonioxClient()
|
|
134
|
+
config = RealtimeTTSConfig(
|
|
135
|
+
stream_id=f"sync-{uuid4()}",
|
|
136
|
+
model="tts-rt-v1",
|
|
137
|
+
language="en",
|
|
138
|
+
voice="Adrian",
|
|
139
|
+
audio_format="wav",
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
audio_chunks: list[bytes] = []
|
|
143
|
+
with client.realtime.tts.connect(config=config) as session:
|
|
144
|
+
session.keep_alive()
|
|
145
|
+
session.send_text_chunks(
|
|
146
|
+
["Hello from realtime TTS. ", "This is the final chunk."],
|
|
147
|
+
text_end=True,
|
|
148
|
+
)
|
|
149
|
+
for chunk in session.receive_audio_chunks():
|
|
150
|
+
audio_chunks.append(chunk)
|
|
151
|
+
|
|
152
|
+
print(f"Collected {sum(len(c) for c in audio_chunks)} bytes of audio")
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Run the full example at [`examples/soniox_client/tts_realtime_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/soniox_client/tts_realtime_example.py) or async version at [`examples/async_soniox_client/tts_realtime_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/async_soniox_client/tts_realtime_example.py).
|
|
100
156
|
|
|
101
157
|
## Repository layout
|
|
102
158
|
|
|
103
159
|
- `src/soniox/` – sdk code (clients, http namespaces, real-time/session helpers, types, utils).
|
|
104
|
-
- `examples/soniox_client` & `examples/async_soniox_client` – runnable
|
|
160
|
+
- `examples/soniox_client` & `examples/async_soniox_client` – runnable STT and TTS examples for sync and async clients.
|
|
105
161
|
- `docs/` – markdown outputs (e.g., `docs/python-sdk.md`) that come from `pydoc-markdown`.
|
|
106
162
|
- `assets/` – sample audio referenced by the examples.
|
|
107
|
-
- `tests/` – pytest narratives that describe the public behavior.
|
|
108
163
|
|
|
109
164
|
## Development
|
|
110
165
|
|
soniox-2.3.1/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Soniox Python SDK
|
|
2
|
+
|
|
3
|
+
The SDK exposes two clients: `SonioxClient` (sync) and `AsyncSonioxClient` (async). Each client supports:
|
|
4
|
+
- STT over REST (`client.stt`) and realtime WebSocket (`client.realtime.stt`)
|
|
5
|
+
- TTS over REST (`client.tts`) and realtime WebSocket (`client.realtime.tts`)
|
|
6
|
+
- auth, file uploads, model listing, webhooks, and typed request/response models
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install soniox
|
|
12
|
+
# or if using uv
|
|
13
|
+
uv add soniox
|
|
14
|
+
export SONIOX_API_KEY=<your-key>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Get your API key from the [Soniox Console](https://console.soniox.com) and inject it once per shell session. Both clients read `SONIOX_API_KEY` by default, but you can override it per-client if needed.
|
|
18
|
+
|
|
19
|
+
## Quick run (STT + TTS, REST + realtime)
|
|
20
|
+
|
|
21
|
+
1. **REST STT transcription**: copy this snippet or run [`examples/soniox_client/api_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/soniox_client/api_example.py).
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from soniox import SonioxClient
|
|
25
|
+
|
|
26
|
+
client = SonioxClient()
|
|
27
|
+
transcription = client.stt.transcribe(
|
|
28
|
+
audio_url="https://soniox.com/media/examples/coffee_shop.mp3",
|
|
29
|
+
client_reference_id="docs-quick-start",
|
|
30
|
+
)
|
|
31
|
+
client.stt.wait(transcription.id, timeout_sec=60)
|
|
32
|
+
print(client.stt.get_transcript(transcription.id).text[:200])
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
2. **REST TTS generation**: convert text to an audio file.
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from soniox import SonioxClient
|
|
39
|
+
from soniox.utils import output_file_for_audio_format
|
|
40
|
+
|
|
41
|
+
client = SonioxClient()
|
|
42
|
+
output_file = output_file_for_audio_format("wav", "tts_sync_output")
|
|
43
|
+
written = client.tts.generate_to_file(
|
|
44
|
+
output_file,
|
|
45
|
+
text="Hello from Soniox Python SDK Text-to-Speech.",
|
|
46
|
+
model="tts-rt-v1",
|
|
47
|
+
language="en",
|
|
48
|
+
voice="Adrian",
|
|
49
|
+
audio_format="wav",
|
|
50
|
+
)
|
|
51
|
+
print(f"Wrote {written} bytes to {output_file.resolve()}")
|
|
52
|
+
client.close()
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Run the full example at [`examples/soniox_client/tts_api_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/soniox_client/tts_api_example.py) or async version at [`examples/async_soniox_client/tts_api_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/async_soniox_client/tts_api_example.py).
|
|
56
|
+
|
|
57
|
+
3. **Realtime STT streaming**: open `client.realtime.stt.connect`, call `session.send_byte_chunk` or `session.send_bytes`, then iterate `session.receive_events()` to render tokens:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from soniox import SonioxClient
|
|
61
|
+
from soniox.types import RealtimeSTTConfig, Token
|
|
62
|
+
from soniox.utils import render_tokens, throttle_audio, start_audio_thread
|
|
63
|
+
|
|
64
|
+
DEMO_FILE = "path_to_your_audio_file"
|
|
65
|
+
|
|
66
|
+
client = SonioxClient()
|
|
67
|
+
config = RealtimeSTTConfig(model="stt-rt-v4", audio_format="mp3")
|
|
68
|
+
final_tokens: list[Token] = []
|
|
69
|
+
non_final_tokens: list[Token] = []
|
|
70
|
+
|
|
71
|
+
def realtime():
|
|
72
|
+
with client.realtime.stt.connect(config=config) as session:
|
|
73
|
+
start_audio_thread(session, throttle_audio(DEMO_FILE, delay_seconds=0.1))
|
|
74
|
+
for event in session.receive_events():
|
|
75
|
+
for token in event.tokens:
|
|
76
|
+
if token.is_final:
|
|
77
|
+
final_tokens.append(token)
|
|
78
|
+
else:
|
|
79
|
+
non_final_tokens.append(token)
|
|
80
|
+
print(render_tokens(final_tokens, non_final_tokens))
|
|
81
|
+
non_final_tokens.clear()
|
|
82
|
+
|
|
83
|
+
realtime()
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
See [`examples/soniox_client/realtime_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/soniox_client/realtime_example.py) for the full flow.
|
|
87
|
+
|
|
88
|
+
4. **Realtime TTS streaming**: send text chunks and read generated audio chunks from the session.
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from uuid import uuid4
|
|
92
|
+
|
|
93
|
+
from soniox import SonioxClient
|
|
94
|
+
from soniox.types import RealtimeTTSConfig
|
|
95
|
+
|
|
96
|
+
client = SonioxClient()
|
|
97
|
+
config = RealtimeTTSConfig(
|
|
98
|
+
stream_id=f"sync-{uuid4()}",
|
|
99
|
+
model="tts-rt-v1",
|
|
100
|
+
language="en",
|
|
101
|
+
voice="Adrian",
|
|
102
|
+
audio_format="wav",
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
audio_chunks: list[bytes] = []
|
|
106
|
+
with client.realtime.tts.connect(config=config) as session:
|
|
107
|
+
session.keep_alive()
|
|
108
|
+
session.send_text_chunks(
|
|
109
|
+
["Hello from realtime TTS. ", "This is the final chunk."],
|
|
110
|
+
text_end=True,
|
|
111
|
+
)
|
|
112
|
+
for chunk in session.receive_audio_chunks():
|
|
113
|
+
audio_chunks.append(chunk)
|
|
114
|
+
|
|
115
|
+
print(f"Collected {sum(len(c) for c in audio_chunks)} bytes of audio")
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Run the full example at [`examples/soniox_client/tts_realtime_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/soniox_client/tts_realtime_example.py) or async version at [`examples/async_soniox_client/tts_realtime_example.py`](https://github.com/soniox/soniox-python/blob/main/examples/async_soniox_client/tts_realtime_example.py).
|
|
119
|
+
|
|
120
|
+
## Repository layout
|
|
121
|
+
|
|
122
|
+
- `src/soniox/` – sdk code (clients, http namespaces, real-time/session helpers, types, utils).
|
|
123
|
+
- `examples/soniox_client` & `examples/async_soniox_client` – runnable STT and TTS examples for sync and async clients.
|
|
124
|
+
- `docs/` – markdown outputs (e.g., `docs/python-sdk.md`) that come from `pydoc-markdown`.
|
|
125
|
+
- `assets/` – sample audio referenced by the examples.
|
|
126
|
+
|
|
127
|
+
## Development
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
uv install --with dev
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
This pulls in `ruff`, `pyright`, `pytest`, etc., so you can lint, type-check, test, and regenerate docs locally.
|
|
134
|
+
|
|
135
|
+
## Docs
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
source .venv/bin/activate
|
|
139
|
+
python3 scripts/generate_docs.py
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Docs are output to `/docs` directory.
|
|
143
|
+
|
|
144
|
+
## Resources
|
|
145
|
+
|
|
146
|
+
- [soniox.com/docs](https://soniox.com/docs/stt/SDKs/python-SDK) – official Soniox documentation.
|
|
147
|
+
- [GitHub repo](https://github.com/soniox/soniox-python) – source, examples, and scripts.
|
|
148
|
+
- [PyPI](https://pypi.org/project/soniox/)
|
|
149
|
+
- Support: `support@soniox.com`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Async Client"
|
|
3
3
|
description: "Soniox Python SDK - Async Client Reference"
|
|
4
|
-
keywords: "AsyncSonioxClient, AsyncFilesAPI, AsyncSttAPI, AsyncModelsAPI, AsyncAuthAPI, AsyncSonioxWebhooksAPI"
|
|
4
|
+
keywords: "AsyncSonioxClient, AsyncFilesAPI, AsyncSttAPI, AsyncTtsAPI, AsyncTtsModelsAPI, AsyncModelsAPI, AsyncAuthAPI, AsyncSonioxWebhooksAPI"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
---
|
|
@@ -15,7 +15,7 @@ Asynchronous Soniox REST client exposing HTTP and realtime helpers.
|
|
|
15
15
|
### Constructor
|
|
16
16
|
|
|
17
17
|
```python
|
|
18
|
-
AsyncSonioxClient(api_key: str | None = None, api_base_url: str | None = None, websocket_base_url: str | None = None, timeout_sec: float | None = None, webhook_secret: str | None = None, webhook_signature_header: str | None = None, **client_kwargs: Any)
|
|
18
|
+
AsyncSonioxClient(api_key: str | None = None, api_base_url: str | None = None, websocket_base_url: str | None = None, tts_api_base_url: str | None = None, tts_websocket_base_url: str | None = None, timeout_sec: float | None = None, webhook_secret: str | None = None, webhook_signature_header: str | None = None, **client_kwargs: Any)
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
**Parameters**
|
|
@@ -25,6 +25,8 @@ AsyncSonioxClient(api_key: str | None = None, api_base_url: str | None = None, w
|
|
|
25
25
|
| `api_key` | `str \| None` | API key used for authentication. |
|
|
26
26
|
| `api_base_url` | `str \| None` | Base URL for Soniox REST API requests. |
|
|
27
27
|
| `websocket_base_url` | `str \| None` | Base URL for Soniox realtime WebSocket endpoint. |
|
|
28
|
+
| `tts_api_base_url` | `str \| None` | Base URL for Soniox Text-to-Speech REST API requests. |
|
|
29
|
+
| `tts_websocket_base_url` | `str \| None` | Base URL for Soniox Text-to-Speech realtime WebSocket endpoint. |
|
|
28
30
|
| `timeout_sec` | `float \| None` | Maximum wait time in seconds. |
|
|
29
31
|
| `webhook_secret` | `str \| None` | Webhook secret used for signature verification. |
|
|
30
32
|
| `webhook_signature_header` | `str \| None` | Webhook signature header name. |
|
|
@@ -42,7 +44,9 @@ AsyncSonioxClient(api_key: str | None = None, api_base_url: str | None = None, w
|
|
|
42
44
|
| ------ | ------ | ------ |
|
|
43
45
|
| `files` | `AsyncFilesAPI` | List of uploaded files. |
|
|
44
46
|
| `stt` | `AsyncSttAPI` | Speech-to-text API namespace. |
|
|
45
|
-
| `
|
|
47
|
+
| `tts` | `AsyncTtsAPI` | Text-to-Speech API namespace |
|
|
48
|
+
| `models` | `AsyncModelsAPI` | List of available Text-to-Speech models. |
|
|
49
|
+
| `tts_models` | `AsyncTtsModelsAPI` | - |
|
|
46
50
|
| `auth` | `AsyncAuthAPI` | Authentication API namespace. |
|
|
47
51
|
| `webhooks` | `AsyncSonioxWebhooksAPI` | Webhook utilities API namespace. |
|
|
48
52
|
| `realtime` | `AsyncRealtimeAPI` | Entrypoint for async realtime helpers on AsyncSonioxClient. |
|
|
@@ -929,6 +933,135 @@ Optionally deletes the transcription and uploaded file after completion.
|
|
|
929
933
|
|
|
930
934
|
---
|
|
931
935
|
|
|
936
|
+
## AsyncTtsAPI
|
|
937
|
+
|
|
938
|
+
<a id="asyncttsapi-constructor"></a>
|
|
939
|
+
|
|
940
|
+
### Constructor
|
|
941
|
+
|
|
942
|
+
```python
|
|
943
|
+
AsyncTtsAPI(client: AsyncSonioxClient)
|
|
944
|
+
```
|
|
945
|
+
|
|
946
|
+
**Parameters**
|
|
947
|
+
|
|
948
|
+
| Parameter | Type | Description |
|
|
949
|
+
| ------ | ------ | ------ |
|
|
950
|
+
| `client` | `AsyncSonioxClient` | Soniox client instance. |
|
|
951
|
+
|
|
952
|
+
**Returns**
|
|
953
|
+
|
|
954
|
+
`None`
|
|
955
|
+
|
|
956
|
+
<a id="asyncttsapi-generate"></a>
|
|
957
|
+
|
|
958
|
+
### generate()
|
|
959
|
+
|
|
960
|
+
```python
|
|
961
|
+
generate(*, text: str, voice: str, model: str = DEFAULT_MODEL, language: str = DEFAULT_LANGUAGE, audio_format: TtsAudioFormat = DEFAULT_AUDIO_FORMAT, sample_rate: TtsSampleRate | None = None, bitrate: TtsBitrate | None = None, config: CreateTtsConfig | None = None) -> bytes
|
|
962
|
+
```
|
|
963
|
+
|
|
964
|
+
Generate speech audio from text and return raw audio bytes.
|
|
965
|
+
|
|
966
|
+
Performs a POST request to the TTS REST endpoint.
|
|
967
|
+
|
|
968
|
+
**Parameters**
|
|
969
|
+
|
|
970
|
+
| Parameter | Type | Description |
|
|
971
|
+
| ------ | ------ | ------ |
|
|
972
|
+
| `text` | `str` | Longer free-form background text, prior interaction history, reference documents, or meeting notes. |
|
|
973
|
+
| `voice` | `str` | Voice identifier to generate speech audio with. |
|
|
974
|
+
| `model` | `str` | Speech-to-text model to use. |
|
|
975
|
+
| `language` | `str` | Language code for Text-to-Speech (e.g., "en"). |
|
|
976
|
+
| `audio_format` | `TtsAudioFormat` | Audio format for realtime transcription. |
|
|
977
|
+
| `sample_rate` | `TtsSampleRate \| None` | Audio sample rate in Hz. |
|
|
978
|
+
| `bitrate` | `TtsBitrate \| None` | Output bitrate in bits-per-second for compressed formats. |
|
|
979
|
+
| `config` | `CreateTtsConfig \| None` | Configuration options for this operation. |
|
|
980
|
+
|
|
981
|
+
**Returns**
|
|
982
|
+
|
|
983
|
+
`bytes`
|
|
984
|
+
|
|
985
|
+
**Raises**
|
|
986
|
+
|
|
987
|
+
- `SonioxAPIError` When the API returns an error.
|
|
988
|
+
|
|
989
|
+
***
|
|
990
|
+
|
|
991
|
+
<a id="asyncttsapi-generate_to_file"></a>
|
|
992
|
+
|
|
993
|
+
### generate_to_file()
|
|
994
|
+
|
|
995
|
+
```python
|
|
996
|
+
generate_to_file(output: BinaryIO | Path | str, *, text: str, voice: str = DEFAULT_VOICE, model: str = DEFAULT_MODEL, language: str = DEFAULT_LANGUAGE, audio_format: TtsAudioFormat = DEFAULT_AUDIO_FORMAT, sample_rate: TtsSampleRate | None = None, bitrate: TtsBitrate | None = None, config: CreateTtsConfig | None = None) -> int
|
|
997
|
+
```
|
|
998
|
+
|
|
999
|
+
Generate speech audio from text and write the audio bytes to a file-like output.
|
|
1000
|
+
|
|
1001
|
+
**Parameters**
|
|
1002
|
+
|
|
1003
|
+
| Parameter | Type | Description |
|
|
1004
|
+
| ------ | ------ | ------ |
|
|
1005
|
+
| `output` | `BinaryIO \| Path \| str` | - |
|
|
1006
|
+
| `text` | `str` | Longer free-form background text, prior interaction history, reference documents, or meeting notes. |
|
|
1007
|
+
| `voice` | `str` | Voice identifier to generate speech audio with. |
|
|
1008
|
+
| `model` | `str` | Speech-to-text model to use. |
|
|
1009
|
+
| `language` | `str` | Language code for Text-to-Speech (e.g., "en"). |
|
|
1010
|
+
| `audio_format` | `TtsAudioFormat` | Audio format for realtime transcription. |
|
|
1011
|
+
| `sample_rate` | `TtsSampleRate \| None` | Audio sample rate in Hz. |
|
|
1012
|
+
| `bitrate` | `TtsBitrate \| None` | Output bitrate in bits-per-second for compressed formats. |
|
|
1013
|
+
| `config` | `CreateTtsConfig \| None` | Configuration options for this operation. |
|
|
1014
|
+
|
|
1015
|
+
**Returns**
|
|
1016
|
+
|
|
1017
|
+
`int`
|
|
1018
|
+
|
|
1019
|
+
Number of bytes written.
|
|
1020
|
+
|
|
1021
|
+
---
|
|
1022
|
+
|
|
1023
|
+
## AsyncTtsModelsAPI
|
|
1024
|
+
|
|
1025
|
+
<a id="asyncttsmodelsapi-constructor"></a>
|
|
1026
|
+
|
|
1027
|
+
### Constructor
|
|
1028
|
+
|
|
1029
|
+
```python
|
|
1030
|
+
AsyncTtsModelsAPI(client: AsyncSonioxClient)
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
**Parameters**
|
|
1034
|
+
|
|
1035
|
+
| Parameter | Type | Description |
|
|
1036
|
+
| ------ | ------ | ------ |
|
|
1037
|
+
| `client` | `AsyncSonioxClient` | Soniox client instance. |
|
|
1038
|
+
|
|
1039
|
+
**Returns**
|
|
1040
|
+
|
|
1041
|
+
`None`
|
|
1042
|
+
|
|
1043
|
+
<a id="asyncttsmodelsapi-list"></a>
|
|
1044
|
+
|
|
1045
|
+
### list()
|
|
1046
|
+
|
|
1047
|
+
```python
|
|
1048
|
+
list() -> GetTtsModelsResponse
|
|
1049
|
+
```
|
|
1050
|
+
|
|
1051
|
+
List available Text-to-Speech models.
|
|
1052
|
+
|
|
1053
|
+
Performs a GET request to ``/tts-models``.
|
|
1054
|
+
|
|
1055
|
+
**Returns**
|
|
1056
|
+
|
|
1057
|
+
`GetTtsModelsResponse`
|
|
1058
|
+
|
|
1059
|
+
**Raises**
|
|
1060
|
+
|
|
1061
|
+
- `SonioxAPIError` When the API returns an error.
|
|
1062
|
+
|
|
1063
|
+
---
|
|
1064
|
+
|
|
932
1065
|
## AsyncModelsAPI
|
|
933
1066
|
|
|
934
1067
|
<a id="asyncmodelsapi-constructor"></a>
|