Skip to content

Commit 4f18682

Browse files
fix listen
1 parent 94fbfc6 commit 4f18682

Some content is hidden

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

72 files changed

+1911
-1491
lines changed

deepgram/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
SpeakWebSocketSource,
8989
SpeakSource,
9090
)
91+
from .client import SpeakWebSocketEvents
9192

9293
## speak REST
9394
from .client import (

deepgram/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
SpeakWebSocketSource,
8484
SpeakSource,
8585
)
86+
from .clients import SpeakWebSocketEvents
8687

8788
## speak REST
8889
from .clients import (

deepgram/clients/__init__.py

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,49 @@
1212
Sentiment,
1313
)
1414

15-
# listen
1615
from .listen_router import Listen
1716
from .read_router import Read
1817
from .speak_router import Speak
1918

20-
# live
21-
from .live import LiveClient, AsyncLiveClient
22-
from .live import LiveOptions
23-
from .live import LiveTranscriptionEvents
19+
# listen
20+
from .listen import LiveTranscriptionEvents
21+
22+
## backward compat
23+
from .prerecorded import (
24+
PreRecordedClient,
25+
AsyncPreRecordedClient,
26+
)
2427
from .live import (
28+
LiveClient,
29+
AsyncLiveClient,
30+
)
31+
32+
# rest
33+
## input
34+
from .listen import (
35+
PrerecordedOptions,
36+
PreRecordedStreamSource,
37+
UrlSource,
38+
FileSource,
39+
PrerecordedSource,
40+
)
41+
42+
## output
43+
from .listen import (
44+
AsyncPrerecordedResponse,
45+
PrerecordedResponse,
46+
SyncPrerecordedResponse,
47+
)
48+
49+
50+
# websocket
51+
## input
52+
from .listen import (
53+
LiveOptions,
54+
)
55+
56+
## output
57+
from .listen import (
2558
OpenResponse,
2659
LiveResultResponse,
2760
MetadataResponse,
@@ -32,19 +65,13 @@
3265
UnhandledResponse,
3366
)
3467

35-
# prerecorded
36-
from .prerecorded import PreRecordedClient, AsyncPreRecordedClient
37-
from .prerecorded import PrerecordedOptions
38-
from .prerecorded import (
39-
PreRecordedStreamSource,
40-
PrerecordedSource,
41-
)
42-
from .prerecorded import (
43-
AsyncPrerecordedResponse,
44-
PrerecordedResponse,
45-
SyncPrerecordedResponse,
68+
## clients
69+
from .listen import (
70+
ListenWebSocketClient,
71+
AsyncListenWebSocketClient,
4672
)
4773

74+
4875
# read
4976
from .analyze import ReadClient, AsyncReadClient
5077
from .analyze import AnalyzeClient, AsyncAnalyzeClient
@@ -60,14 +87,17 @@
6087
)
6188

6289
# speak
90+
## common
6391
from .speak import (
6492
SpeakOptions,
6593
FileSource,
6694
SpeakWebSocketSource,
6795
SpeakSource,
6896
)
6997

70-
# speak REST
98+
from .speak import SpeakWebSocketEvents
99+
100+
## speak REST
71101
from .speak import (
72102
SpeakClient, # backward compat
73103
SpeakRESTClient,
@@ -79,7 +109,7 @@
79109
SpeakRESTResponse,
80110
)
81111

82-
# speak WebSocket
112+
## speak WebSocket
83113
from .speak import (
84114
SpeakWebSocketClient,
85115
AsyncSpeakWebSocketClient,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved.
2+
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+
# SPDX-License-Identifier: MIT
4+
5+
from .enums import LiveTranscriptionEvents
6+
from ...options import DeepgramClientOptions, ClientOptionsFromEnv
7+
8+
# backward compat
9+
from .client import (
10+
PreRecordedClient,
11+
AsyncPreRecordedClient,
12+
LiveClient,
13+
AsyncLiveClient,
14+
)
15+
16+
# rest
17+
## input
18+
from .client import (
19+
PrerecordedOptions,
20+
PreRecordedStreamSource,
21+
UrlSource,
22+
FileSource,
23+
PrerecordedSource,
24+
)
25+
26+
## output
27+
from .client import (
28+
AsyncPrerecordedResponse,
29+
PrerecordedResponse,
30+
SyncPrerecordedResponse,
31+
)
32+
33+
34+
# websocket
35+
## input
36+
from .client import (
37+
LiveOptions,
38+
)
39+
40+
## output
41+
from .client import (
42+
OpenResponse,
43+
LiveResultResponse,
44+
MetadataResponse,
45+
SpeechStartedResponse,
46+
UtteranceEndResponse,
47+
CloseResponse,
48+
ErrorResponse,
49+
UnhandledResponse,
50+
)
51+
52+
# clients
53+
from .client import (
54+
ListenWebSocketClient,
55+
AsyncListenWebSocketClient,
56+
)

deepgram/clients/listen/client.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved.
2+
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+
# SPDX-License-Identifier: MIT
4+
5+
6+
from ...options import DeepgramClientOptions, ClientOptionsFromEnv
7+
8+
# rest
9+
from .v1 import (
10+
ListenRESTClient as ListenRESTClientLatest,
11+
AsyncListenRESTClient as AsyncListenRESTClientLatest,
12+
)
13+
from .v1 import PrerecordedOptions as PrerecordedOptionsLatest
14+
15+
from .v1 import (
16+
UrlSource as UrlSourceLatest,
17+
FileSource as FileSourceLatest,
18+
PreRecordedStreamSource as PreRecordedStreamSourceLatest,
19+
PrerecordedSource as PrerecordedSourceLatest,
20+
)
21+
from .v1 import (
22+
AsyncPrerecordedResponse as AsyncPrerecordedResponseLatest,
23+
PrerecordedResponse as PrerecordedResponseLatest,
24+
SyncPrerecordedResponse as SyncPrerecordedResponseLatest,
25+
)
26+
27+
# websocket
28+
from .v1 import (
29+
ListenWebSocketClient as ListenWebSocketClientLatest,
30+
AsyncListenWebSocketClient as AsyncListenWebSocketClientLatest,
31+
)
32+
from .v1 import LiveOptions as LiveOptionsLatest, LiveOptions as SteamingOptionsLatest
33+
from .v1 import (
34+
OpenResponse as OpenResponseLatest,
35+
LiveResultResponse as LiveResultResponseLatest,
36+
MetadataResponse as MetadataResponseLatest,
37+
SpeechStartedResponse as SpeechStartedResponseLatest,
38+
UtteranceEndResponse as UtteranceEndResponseLatest,
39+
CloseResponse as CloseResponseLatest,
40+
ErrorResponse as ErrorResponseLatest,
41+
UnhandledResponse as UnhandledResponseLatest,
42+
)
43+
44+
# The vX/client.py points to the current supported version in the SDK.
45+
# Older versions are supported in the SDK for backwards compatibility.
46+
47+
48+
# backward compat
49+
PreRecordedClient = ListenRESTClientLatest
50+
AsyncPreRecordedClient = AsyncListenRESTClientLatest
51+
LiveClient = ListenWebSocketClientLatest
52+
AsyncLiveClient = ListenWebSocketClientLatest
53+
54+
# rest
55+
## input
56+
PrerecordedOptions = PrerecordedOptionsLatest
57+
PreRecordedStreamSource = PreRecordedStreamSourceLatest
58+
UrlSource = UrlSourceLatest
59+
FileSource = FileSourceLatest
60+
PrerecordedSource = PrerecordedSourceLatest
61+
62+
## output
63+
AsyncPrerecordedResponse = AsyncPrerecordedResponseLatest
64+
PrerecordedResponse = PrerecordedResponseLatest
65+
SyncPrerecordedResponse = SyncPrerecordedResponseLatest
66+
67+
68+
# websocket
69+
## input
70+
LiveOptions = LiveOptionsLatest
71+
72+
## output
73+
OpenResponse = OpenResponseLatest
74+
LiveResultResponse = LiveResultResponseLatest
75+
MetadataResponse = MetadataResponseLatest
76+
SpeechStartedResponse = SpeechStartedResponseLatest
77+
UtteranceEndResponse = UtteranceEndResponseLatest
78+
CloseResponse = CloseResponseLatest
79+
ErrorResponse = ErrorResponseLatest
80+
UnhandledResponse = UnhandledResponseLatest
81+
82+
83+
# clients
84+
ListenWebSocketClient = ListenWebSocketClientLatest
85+
AsyncListenWebSocketClient = AsyncListenWebSocketClientLatest
File renamed without changes.

deepgram/clients/live/errors.py renamed to deepgram/clients/listen/errors.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ def __str__(self):
2020
return f"{self.name}: {self.message}"
2121

2222

23+
class DeepgramTypeError(Exception):
24+
"""
25+
Exception raised for unknown errors related to unknown Types for Transcription.
26+
27+
Attributes:
28+
message (str): The error message describing the exception.
29+
"""
30+
31+
def __init__(self, message: str):
32+
super().__init__(message)
33+
self.name = "DeepgramTypeError"
34+
self.message = message
35+
36+
def __str__(self):
37+
return f"{self.name}: {self.message}"
38+
39+
2340
class DeepgramWebsocketError(Exception):
2441
"""
2542
Exception raised for known errors related to Websocket library.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2024 Deepgram SDK contributors. All Rights Reserved.
2+
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+
# SPDX-License-Identifier: MIT
4+
5+
from ....options import DeepgramClientOptions, ClientOptionsFromEnv
6+
7+
# backward compat
8+
from .rest import (
9+
ListenRESTClient as PreRecordedClient,
10+
AsyncListenRESTClient as AsyncPreRecordedClient,
11+
)
12+
from .websocket import (
13+
ListenWebSocketClient as LiveClient,
14+
AsyncListenWebSocketClient as AsyncLiveClient,
15+
)
16+
17+
# rest
18+
from .rest import ListenRESTClient, AsyncListenRESTClient
19+
from .rest import PrerecordedOptions
20+
from .rest import (
21+
UrlSource,
22+
FileSource,
23+
PreRecordedStreamSource,
24+
PrerecordedSource,
25+
)
26+
from .rest import (
27+
AsyncPrerecordedResponse,
28+
PrerecordedResponse,
29+
SyncPrerecordedResponse,
30+
)
31+
32+
# websocket
33+
from .websocket import ListenWebSocketClient, AsyncListenWebSocketClient
34+
from .websocket import LiveOptions, LiveOptions as SteamingOptions
35+
from .websocket import (
36+
OpenResponse,
37+
LiveResultResponse,
38+
MetadataResponse,
39+
SpeechStartedResponse,
40+
UtteranceEndResponse,
41+
CloseResponse,
42+
ErrorResponse,
43+
UnhandledResponse,
44+
)
File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved.
2+
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+
# SPDX-License-Identifier: MIT
4+
5+
from .client import ListenRESTClient
6+
from .async_client import AsyncListenRESTClient
7+
from .options import (
8+
PrerecordedOptions,
9+
FileSource,
10+
UrlSource,
11+
PreRecordedStreamSource,
12+
PrerecordedSource,
13+
)
14+
from .response import (
15+
AsyncPrerecordedResponse,
16+
PrerecordedResponse,
17+
SyncPrerecordedResponse,
18+
Sentiment,
19+
)
20+
21+
from .....options import DeepgramClientOptions, ClientOptionsFromEnv

0 commit comments

Comments
 (0)