Skip to content

Commit d045d2e

Browse files
SDK regeneration
1 parent ec86a78 commit d045d2e

File tree

337 files changed

+11477
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+11477
-102
lines changed

.fern/metadata.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"cliVersion": "3.51.3",
2+
"cliVersion": "3.77.1",
33
"generatorName": "fernapi/fern-python-sdk",
4-
"generatorVersion": "4.53.0",
4+
"generatorVersion": "4.57.2",
55
"generatorConfig": {
66
"client": {
77
"class_name": "BaseClient",
@@ -13,5 +13,5 @@
1313
"should_generate_websocket_clients": true,
1414
"enable_wire_tests": true
1515
},
16-
"sdkVersion": "5.3.2"
16+
"sdkVersion": "5.3.3"
1717
}

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Power your apps with world-class speech and Language AI models
1717
- [Async Client](#async-client)
1818
- [Exception Handling](#exception-handling)
1919
- [Advanced Features](#advanced-features)
20+
- [Websockets](#websockets)
2021
- [Advanced](#advanced)
2122
- [Access Raw Response Data](#access-raw-response-data)
2223
- [Retries](#retries)
@@ -205,6 +206,62 @@ response = client.listen.v1.media.transcribe_file(
205206
)
206207
```
207208

209+
## Websockets
210+
211+
The SDK supports both sync and async websocket connections for real-time, low-latency communication. Sockets can be created using the `connect` method, which returns a context manager.
212+
You can either iterate through the returned `SocketClient` to process messages as they arrive, or attach handlers to respond to specific events.
213+
214+
```python
215+
216+
# Connect to the websocket (Sync)
217+
import threading
218+
219+
from deepgram import DeepgramClient
220+
221+
client = DeepgramClient(...)
222+
223+
with client.v1.connect() as socket:
224+
# Iterate over the messages as they arrive
225+
for message in socket
226+
print(message)
227+
228+
# Or, attach handlers to specific events
229+
socket.on(EventType.OPEN, lambda _: print("open"))
230+
socket.on(EventType.MESSAGE, lambda message: print("received message", message))
231+
socket.on(EventType.CLOSE, lambda _: print("close"))
232+
socket.on(EventType.ERROR, lambda error: print("error", error))
233+
234+
235+
# Start the listening loop in a background thread
236+
listener_thread = threading.Thread(target=socket.start_listening, daemon=True)
237+
listener_thread.start()
238+
```
239+
240+
```python
241+
242+
# Connect to the websocket (Async)
243+
import asyncio
244+
245+
from deepgram import AsyncDeepgramClient
246+
247+
client = AsyncDeepgramClient(...)
248+
249+
async with client.v1.connect() as socket:
250+
# Iterate over the messages as they arrive
251+
async for message in socket
252+
print(message)
253+
254+
# Or, attach handlers to specific events
255+
socket.on(EventType.OPEN, lambda _: print("open"))
256+
socket.on(EventType.MESSAGE, lambda message: print("received message", message))
257+
socket.on(EventType.CLOSE, lambda _: print("close"))
258+
socket.on(EventType.ERROR, lambda error: print("error", error))
259+
260+
261+
# Start listening for events in an asyncio task
262+
listen_task = asyncio.create_task(socket.start_listening())
263+
```
264+
208265
## Advanced
209266

210267
### Access Raw Response Data
@@ -220,6 +277,7 @@ client = DeepgramClient(
220277
)
221278
response = client.listen.v1.media.with_raw_response.transcribe_file(...)
222279
print(response.headers) # access the response headers
280+
print(response.status_code) # access the response status code
223281
print(response.data) # access the underlying object
224282
```
225283

poetry.lock

Lines changed: 96 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dynamic = ["version"]
44

55
[tool.poetry]
66
name = "deepgram-sdk"
7-
version = "5.3.2"
7+
version = "5.3.3"
88
description = ""
99
readme = "README.md"
1010
authors = []
@@ -19,6 +19,9 @@ classifiers = [
1919
"Programming Language :: Python :: 3.10",
2020
"Programming Language :: Python :: 3.11",
2121
"Programming Language :: Python :: 3.12",
22+
"Programming Language :: Python :: 3.13",
23+
"Programming Language :: Python :: 3.14",
24+
"Programming Language :: Python :: 3.15",
2225
"Operating System :: OS Independent",
2326
"Operating System :: POSIX",
2427
"Operating System :: MacOS",
@@ -41,6 +44,7 @@ httpx = ">=0.21.2"
4144
pydantic = ">= 1.9.2"
4245
pydantic-core = ">=2.18.2"
4346
typing_extensions = ">= 4.0.0"
47+
websockets = ">=12.0"
4448

4549
[tool.poetry.group.dev.dependencies]
4650
mypy = "==1.13.0"

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ httpx>=0.21.2
22
pydantic>= 1.9.2
33
pydantic-core>=2.18.2
44
typing_extensions>= 4.0.0
5+
websockets>=12.0

0 commit comments

Comments
 (0)