Skip to content

Commit 8151a93

Browse files
Implement UtteranceEnd Messages for Live Clients
1 parent 8599980 commit 8151a93

File tree

19 files changed

+256
-32
lines changed

19 files changed

+256
-32
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,26 @@ To make sure our community is safe for all, be sure to review and agree to our
189189
[Code of Conduct](./CODE_OF_CONDUCT.md). Then see the
190190
[Contribution](./CONTRIBUTING.md) guidelines for more information.
191191

192+
## Prerequisites
193+
194+
In order to develop new features for the SDK itself, you first need to uninstall any previous installation of the `deepgram-sdk` and then install/pip the dependencies contained in the `requirements.txt` then instruct python (via pip) to use the SDK by installing it locally.
195+
196+
From the root of the repo, that would entail:
197+
198+
```bash
199+
pip uninstall deepgram-sdk
200+
pip install -r requirements.txt
201+
pip install -e .
202+
```
203+
204+
## Testing
205+
206+
If you are looking to contribute or modify pytest code, then you need to install the following dependencies:
207+
208+
```bash
209+
pip install -r requirements-dev.txt
210+
```
211+
192212
# Getting Help
193213

194214
We love to hear from you so if you have questions, comments or find a bug in the

deepgram/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from .client import (
2020
LiveResultResponse,
2121
MetadataResponse,
22+
UtteranceEndResponse,
2223
ErrorResponse,
2324
)
2425

deepgram/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .clients import (
2222
LiveResultResponse,
2323
MetadataResponse,
24+
UtteranceEndResponse,
2425
ErrorResponse,
2526
)
2627

deepgram/clients/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .live import (
1313
LiveResultResponse,
1414
MetadataResponse,
15+
UtteranceEndResponse,
1516
ErrorResponse,
1617
)
1718

deepgram/clients/listen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from .live.client import (
3636
LiveResultResponse,
3737
MetadataResponse,
38+
UtteranceEndResponse,
3839
ErrorResponse,
3940
)
4041

deepgram/clients/live/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
from .client import (
1111
LiveResultResponse,
1212
MetadataResponse,
13+
UtteranceEndResponse,
1314
ErrorResponse,
1415
)

deepgram/clients/live/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .v1.response import (
1010
LiveResultResponse as LiveResultResponseLatest,
1111
MetadataResponse as MetadataResponseLatest,
12+
UtteranceEndResponse as UtteranceEndResponseLatest,
1213
ErrorResponse as ErrorResponseLatest,
1314
)
1415

@@ -44,6 +45,14 @@ class MetadataResponse(MetadataResponseLatest):
4445
pass
4546

4647

48+
class UtteranceEndResponse(UtteranceEndResponseLatest):
49+
"""
50+
pass through for UtteranceEndResponse based on API version
51+
"""
52+
53+
pass
54+
55+
4756
class ErrorResponse(ErrorResponseLatest):
4857
"""
4958
pass through for ErrorResponse based on API version

deepgram/clients/live/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ class LiveTranscriptionEvents(Enum):
1414
Close = "Close"
1515
Transcript = "Results"
1616
Metadata = "Metadata"
17+
UtteranceEnd = "UtteranceEnd"
1718
Error = "Error"
1819
Warning = "Warning"

deepgram/clients/live/v1/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
from .response import (
1010
LiveResultResponse,
1111
MetadataResponse,
12+
UtteranceEndResponse,
1213
ErrorResponse,
1314
)

deepgram/clients/live/v1/async_client.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .response import (
1515
LiveResultResponse,
1616
MetadataResponse,
17+
UtteranceEndResponse,
1718
ErrorResponse,
1819
)
1920
from .options import LiveOptions
@@ -121,6 +122,19 @@ async def _start(self) -> None:
121122
metadata=result,
122123
**dict(self.kwargs),
123124
)
125+
case LiveTranscriptionEvents.UtteranceEnd.value:
126+
self.logger.debug(
127+
"response_type: %s, data: %s", response_type, data
128+
)
129+
result = UtteranceEndResponse.from_json(message)
130+
if result is None:
131+
self.logger.error("UtteranceEndResponse.from_json is None")
132+
continue
133+
await self._emit(
134+
LiveTranscriptionEvents.UtteranceEnd,
135+
utterance_end=result,
136+
**dict(self.kwargs),
137+
)
124138
case LiveTranscriptionEvents.Error.value:
125139
self.logger.debug(
126140
"response_type: %s, data: %s", response_type, data

0 commit comments

Comments
 (0)