soniox 2.1.0__tar.gz → 2.3.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 (88) hide show
  1. {soniox-2.1.0 → soniox-2.3.0}/CHANGELOG.md +22 -0
  2. {soniox-2.1.0 → soniox-2.3.0}/PKG-INFO +64 -9
  3. soniox-2.3.0/README.md +149 -0
  4. soniox-2.3.0/docs/async_client.md +1157 -0
  5. soniox-2.3.0/docs/realtime_client.md +2217 -0
  6. soniox-2.3.0/docs/types.md +807 -0
  7. soniox-2.3.0/examples/async_soniox_client/tts_api_example.py +40 -0
  8. soniox-2.3.0/examples/async_soniox_client/tts_realtime_example.py +65 -0
  9. soniox-2.3.0/examples/async_soniox_client/tts_realtime_multiplexed_example.py +147 -0
  10. soniox-2.3.0/examples/soniox_client/tts_api_example.py +38 -0
  11. soniox-2.3.0/examples/soniox_client/tts_realtime_example.py +67 -0
  12. soniox-2.3.0/examples/soniox_client/tts_realtime_multiplexed_example.py +147 -0
  13. {soniox-2.1.0 → soniox-2.3.0}/justfile +0 -1
  14. {soniox-2.1.0 → soniox-2.3.0}/pyproject.toml +1 -1
  15. soniox-2.3.0/scripts/generate_docs.py +1135 -0
  16. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/__init__.py +8 -0
  17. soniox-2.3.0/src/soniox/api/async_tts.py +98 -0
  18. soniox-2.3.0/src/soniox/api/async_tts_models.py +26 -0
  19. soniox-2.3.0/src/soniox/api/tts.py +98 -0
  20. soniox-2.3.0/src/soniox/api/tts_models.py +26 -0
  21. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/client.py +42 -0
  22. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/errors.py +20 -1
  23. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/realtime/__init__.py +41 -1
  24. soniox-2.3.0/src/soniox/realtime/_constants.py +3 -0
  25. soniox-2.3.0/src/soniox/realtime/async_tts.py +554 -0
  26. soniox-2.3.0/src/soniox/realtime/tts.py +546 -0
  27. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/types/__init__.py +26 -1
  28. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/types/api.py +119 -4
  29. soniox-2.3.0/src/soniox/types/realtime.py +205 -0
  30. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/utils.py +36 -0
  31. {soniox-2.1.0 → soniox-2.3.0}/uv.lock +1 -1
  32. soniox-2.1.0/README.md +0 -94
  33. soniox-2.1.0/scripts/generate_docs.py +0 -144
  34. soniox-2.1.0/src/soniox/types/realtime.py +0 -92
  35. {soniox-2.1.0 → soniox-2.3.0}/.gitignore +0 -0
  36. {soniox-2.1.0 → soniox-2.3.0}/LICENSE +0 -0
  37. {soniox-2.1.0 → soniox-2.3.0}/assets/coffee_shop.mp3 +0 -0
  38. {soniox-2.1.0 → soniox-2.3.0}/assets/coffee_shop.pcm_s16le +0 -0
  39. {soniox-2.1.0 → soniox-2.3.0}/assets/two_way_translation.mp3 +0 -0
  40. {soniox-2.1.0 → soniox-2.3.0}/assets/two_way_translation.pcm_s16le +0 -0
  41. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/__init__.md +0 -0
  42. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/__init__.md +0 -0
  43. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api__utils.md +0 -0
  44. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_async_auth.md +0 -0
  45. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_async_files.md +0 -0
  46. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_async_models.md +0 -0
  47. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_async_stt.md +0 -0
  48. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_async_transcriptions.md +0 -0
  49. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_async_webhooks.md +0 -0
  50. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_auth.md +0 -0
  51. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_files.md +0 -0
  52. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_models.md +0 -0
  53. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_stt.md +0 -0
  54. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_transcriptions.md +0 -0
  55. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/api/api_webhooks.md +0 -0
  56. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/realtime/__init__.md +0 -0
  57. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/realtime/realtime__utils.md +0 -0
  58. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/realtime/realtime_async_stt.md +0 -0
  59. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/realtime/realtime_stt.md +0 -0
  60. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/soniox_client.md +0 -0
  61. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/soniox_errors.md +0 -0
  62. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/soniox_utils.md +0 -0
  63. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/types/__init__.md +0 -0
  64. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/types/types_api.md +0 -0
  65. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/types/types_common.md +0 -0
  66. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/types/types_realtime.md +0 -0
  67. {soniox-2.1.0 → soniox-2.3.0}/docs/soniox/types/types_webhooks.md +0 -0
  68. {soniox-2.1.0 → soniox-2.3.0}/examples/async_soniox_client/api_example.py +0 -0
  69. {soniox-2.1.0 → soniox-2.3.0}/examples/async_soniox_client/realtime_example.py +0 -0
  70. {soniox-2.1.0 → soniox-2.3.0}/examples/soniox_client/api_example.py +0 -0
  71. {soniox-2.1.0 → soniox-2.3.0}/examples/soniox_client/realtime_example.py +0 -0
  72. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/__init__.py +0 -0
  73. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/_utils.py +0 -0
  74. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/async_auth.py +0 -0
  75. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/async_files.py +0 -0
  76. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/async_models.py +0 -0
  77. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/async_stt.py +0 -0
  78. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/async_webhooks.py +0 -0
  79. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/auth.py +0 -0
  80. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/files.py +0 -0
  81. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/models.py +0 -0
  82. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/stt.py +0 -0
  83. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/api/webhooks.py +0 -0
  84. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/realtime/_utils.py +0 -0
  85. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/realtime/async_stt.py +0 -0
  86. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/realtime/stt.py +0 -0
  87. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/types/common.py +0 -0
  88. {soniox-2.1.0 → soniox-2.3.0}/src/soniox/types/webhooks.py +0 -0
@@ -77,6 +77,28 @@ Examples:
77
77
 
78
78
  ---
79
79
 
80
+ ## [3.0.0] - 22 apr 2026
81
+
82
+ ### Added
83
+
84
+ - Added TTS support for REST and websocket APIs.
85
+
86
+ ---
87
+
88
+ ## [2.2.0] - 25 feb 2026
89
+
90
+ ### Added
91
+
92
+ - max_endpoint_delay_ms parameter (v4 model only)
93
+ - fin (<fin>) and end (<end>) constants
94
+ - validation for TranslationConfig
95
+
96
+ ### Changed
97
+
98
+ - Improved docs generating script
99
+
100
+ ---
101
+
80
102
  ## [2.1.0] - 18 feb 2026
81
103
 
82
104
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soniox
3
- Version: 2.1.0
3
+ Version: 2.3.0
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`. Client can hit every Soniox REST endpoint or open a real-time websocket session, so you can focus on building features instead of dealing with boilerplate.
41
- Auth, file uploads, transcription polling, webhook helpers, and real-time stream helpers all live in one typed package.
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 (rest + real-time)
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. **Real-time streaming**: the real-time helpers mirror the sync rest sample—open `client.realtime.stt.connect`, call `session.send_byte_chunk` or `session.send_bytes`, then iterate `session.receive_events()` to render tokens. example:
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-preview",
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
- 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.
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-preview",
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 rest + real-time flows for sync and async.
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.0/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-preview",
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-preview",
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`.