livekit-plugins-deepgram 1.0.19__py3-none-any.whl → 1.0.21__py3-none-any.whl
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.
- livekit/plugins/deepgram/__init__.py +21 -0
- livekit/plugins/deepgram/_utils.py +21 -0
- livekit/plugins/deepgram/stt.py +4 -23
- livekit/plugins/deepgram/tts.py +4 -19
- livekit/plugins/deepgram/version.py +1 -1
- {livekit_plugins_deepgram-1.0.19.dist-info → livekit_plugins_deepgram-1.0.21.dist-info}/METADATA +6 -4
- livekit_plugins_deepgram-1.0.21.dist-info/RECORD +11 -0
- livekit_plugins_deepgram-1.0.19.dist-info/RECORD +0 -11
- {livekit_plugins_deepgram-1.0.19.dist-info → livekit_plugins_deepgram-1.0.21.dist-info}/WHEEL +0 -0
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright 2025 LiveKit, Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
"""Deepgram plugin for LiveKit Agents
|
16
|
+
|
17
|
+
Support for speech-to-text with [Deepgram](https://deepgram.com/).
|
18
|
+
|
19
|
+
See https://docs.livekit.io/agents/integrations/stt/deepgram/ for more information.
|
20
|
+
"""
|
21
|
+
|
1
22
|
from .stt import STT, AudioEnergyFilter, SpeechStream
|
2
23
|
from .tts import TTS
|
3
24
|
from .version import __version__
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import time
|
2
2
|
from typing import Callable, Generic, Optional, TypeVar
|
3
|
+
from urllib.parse import urlencode
|
3
4
|
|
4
5
|
T = TypeVar("T")
|
5
6
|
|
@@ -34,3 +35,23 @@ class PeriodicCollector(Generic[T]):
|
|
34
35
|
self._callback(self._total)
|
35
36
|
self._total = None
|
36
37
|
self._last_flush_time = time.monotonic()
|
38
|
+
|
39
|
+
|
40
|
+
def _to_deepgram_url(opts: dict, base_url: str, *, websocket: bool) -> str:
|
41
|
+
# don't modify the original opts
|
42
|
+
opts = opts.copy()
|
43
|
+
if opts.get("keywords"):
|
44
|
+
# convert keywords to a list of "keyword:intensifier"
|
45
|
+
opts["keywords"] = [
|
46
|
+
f"{keyword}:{intensifier}" for (keyword, intensifier) in opts["keywords"]
|
47
|
+
]
|
48
|
+
|
49
|
+
# lowercase bools
|
50
|
+
opts = {k: str(v).lower() if isinstance(v, bool) else v for k, v in opts.items()}
|
51
|
+
|
52
|
+
if websocket and base_url.startswith("http"):
|
53
|
+
base_url = base_url.replace("http", "ws", 1)
|
54
|
+
|
55
|
+
elif not websocket and base_url.startswith("ws"):
|
56
|
+
base_url = base_url.replace("ws", "http", 1)
|
57
|
+
return f"{base_url}?{urlencode(opts, doseq=True)}"
|
livekit/plugins/deepgram/stt.py
CHANGED
@@ -22,7 +22,6 @@ import weakref
|
|
22
22
|
from dataclasses import dataclass
|
23
23
|
from enum import Enum
|
24
24
|
from typing import Any
|
25
|
-
from urllib.parse import urlencode
|
26
25
|
|
27
26
|
import aiohttp
|
28
27
|
import numpy as np
|
@@ -43,7 +42,7 @@ from livekit.agents.types import (
|
|
43
42
|
)
|
44
43
|
from livekit.agents.utils import AudioBuffer, is_given
|
45
44
|
|
46
|
-
from ._utils import PeriodicCollector
|
45
|
+
from ._utils import PeriodicCollector, _to_deepgram_url
|
47
46
|
from .log import logger
|
48
47
|
from .models import DeepgramLanguages, DeepgramModels
|
49
48
|
|
@@ -566,10 +565,11 @@ class SpeechStream(stt.SpeechStream):
|
|
566
565
|
asyncio.create_task(recv_task(ws)),
|
567
566
|
asyncio.create_task(keepalive_task(ws)),
|
568
567
|
]
|
568
|
+
tasks_group = asyncio.gather(*tasks)
|
569
569
|
wait_reconnect_task = asyncio.create_task(self._reconnect_event.wait())
|
570
570
|
try:
|
571
571
|
done, _ = await asyncio.wait(
|
572
|
-
[
|
572
|
+
[tasks_group, wait_reconnect_task],
|
573
573
|
return_when=asyncio.FIRST_COMPLETED,
|
574
574
|
) # type: ignore
|
575
575
|
|
@@ -584,6 +584,7 @@ class SpeechStream(stt.SpeechStream):
|
|
584
584
|
self._reconnect_event.clear()
|
585
585
|
finally:
|
586
586
|
await utils.aio.gracefully_cancel(*tasks, wait_reconnect_task)
|
587
|
+
await tasks_group
|
587
588
|
finally:
|
588
589
|
if ws is not None:
|
589
590
|
await ws.close()
|
@@ -751,26 +752,6 @@ def prerecorded_transcription_to_speech_event(
|
|
751
752
|
)
|
752
753
|
|
753
754
|
|
754
|
-
def _to_deepgram_url(opts: dict, base_url: str, *, websocket: bool) -> str:
|
755
|
-
# don't modify the original opts
|
756
|
-
opts = opts.copy()
|
757
|
-
if opts.get("keywords"):
|
758
|
-
# convert keywords to a list of "keyword:intensifier"
|
759
|
-
opts["keywords"] = [
|
760
|
-
f"{keyword}:{intensifier}" for (keyword, intensifier) in opts["keywords"]
|
761
|
-
]
|
762
|
-
|
763
|
-
# lowercase bools
|
764
|
-
opts = {k: str(v).lower() if isinstance(v, bool) else v for k, v in opts.items()}
|
765
|
-
|
766
|
-
if websocket and base_url.startswith("http"):
|
767
|
-
base_url = base_url.replace("http", "ws", 1)
|
768
|
-
|
769
|
-
elif not websocket and base_url.startswith("ws"):
|
770
|
-
base_url = base_url.replace("ws", "http", 1)
|
771
|
-
return f"{base_url}?{urlencode(opts, doseq=True)}"
|
772
|
-
|
773
|
-
|
774
755
|
def _validate_model(
|
775
756
|
model: DeepgramModels | str, language: NotGivenOr[DeepgramLanguages | str]
|
776
757
|
) -> DeepgramModels | str:
|
livekit/plugins/deepgram/tts.py
CHANGED
@@ -5,7 +5,6 @@ import json
|
|
5
5
|
import os
|
6
6
|
import weakref
|
7
7
|
from dataclasses import dataclass
|
8
|
-
from urllib.parse import urlencode
|
9
8
|
|
10
9
|
import aiohttp
|
11
10
|
|
@@ -25,6 +24,7 @@ from livekit.agents.types import (
|
|
25
24
|
)
|
26
25
|
from livekit.agents.utils import is_given
|
27
26
|
|
27
|
+
from ._utils import _to_deepgram_url
|
28
28
|
from .log import logger
|
29
29
|
|
30
30
|
BASE_URL = "https://api.deepgram.com/v1/speak"
|
@@ -44,7 +44,7 @@ class TTS(tts.TTS):
|
|
44
44
|
def __init__(
|
45
45
|
self,
|
46
46
|
*,
|
47
|
-
model: str = "aura-
|
47
|
+
model: str = "aura-2-andromeda-en",
|
48
48
|
encoding: str = "linear16",
|
49
49
|
sample_rate: int = 24000,
|
50
50
|
api_key: NotGivenOr[str] = NOT_GIVEN,
|
@@ -57,7 +57,7 @@ class TTS(tts.TTS):
|
|
57
57
|
Create a new instance of Deepgram TTS.
|
58
58
|
|
59
59
|
Args:
|
60
|
-
model (str): TTS model to use. Defaults to "aura-
|
60
|
+
model (str): TTS model to use. Defaults to "aura-2-andromeda-en".
|
61
61
|
encoding (str): Audio encoding to use. Defaults to "linear16".
|
62
62
|
sample_rate (int): Sample rate of audio. Defaults to 24000.
|
63
63
|
api_key (str): Deepgram API key. If not provided, will look for DEEPGRAM_API_KEY in environment.
|
@@ -221,7 +221,7 @@ class ChunkedStream(tts.ChunkedStream):
|
|
221
221
|
"Content-Type": "application/json",
|
222
222
|
},
|
223
223
|
json={"text": self._input_text},
|
224
|
-
timeout=self._conn_options.timeout,
|
224
|
+
timeout=aiohttp.ClientTimeout(connect=self._conn_options.timeout, total=30),
|
225
225
|
) as res:
|
226
226
|
if res.status != 200:
|
227
227
|
raise APIStatusError(
|
@@ -436,18 +436,3 @@ class SynthesizeStream(tts.SynthesizeStream):
|
|
436
436
|
finally:
|
437
437
|
if ws is not None and not ws.closed:
|
438
438
|
await ws.close()
|
439
|
-
|
440
|
-
|
441
|
-
def _to_deepgram_url(
|
442
|
-
opts: dict,
|
443
|
-
base_url: str,
|
444
|
-
*,
|
445
|
-
websocket: bool,
|
446
|
-
) -> str:
|
447
|
-
if websocket and base_url.startswith("http"):
|
448
|
-
base_url = base_url.replace("http", "ws", 1)
|
449
|
-
|
450
|
-
elif not websocket and base_url.startswith("ws"):
|
451
|
-
base_url = base_url.replace("ws", "http", 1)
|
452
|
-
|
453
|
-
return f"{base_url}?{urlencode(opts, doseq=True)}"
|
{livekit_plugins_deepgram-1.0.19.dist-info → livekit_plugins_deepgram-1.0.21.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: livekit-plugins-deepgram
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.21
|
4
4
|
Summary: Agent Framework plugin for services using Deepgram's API.
|
5
5
|
Project-URL: Documentation, https://docs.livekit.io
|
6
6
|
Project-URL: Website, https://livekit.io/
|
@@ -18,13 +18,15 @@ Classifier: Topic :: Multimedia :: Sound/Audio
|
|
18
18
|
Classifier: Topic :: Multimedia :: Video
|
19
19
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
20
20
|
Requires-Python: >=3.9.0
|
21
|
-
Requires-Dist: livekit-agents[codecs]>=1.0.
|
21
|
+
Requires-Dist: livekit-agents[codecs]>=1.0.21
|
22
22
|
Requires-Dist: numpy>=1.26
|
23
23
|
Description-Content-Type: text/markdown
|
24
24
|
|
25
|
-
# LiveKit
|
25
|
+
# Deepgram plugin for LiveKit Agents
|
26
26
|
|
27
|
-
|
27
|
+
Support for speech-to-text with [Deepgram](https://deepgram.com/).
|
28
|
+
|
29
|
+
See [https://docs.livekit.io/agents/integrations/stt/deepgram/](https://docs.livekit.io/agents/integrations/stt/deepgram/) for more information.
|
28
30
|
|
29
31
|
## Installation
|
30
32
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
livekit/plugins/deepgram/__init__.py,sha256=7sCI3vSCelS8mjtjaIZP_tt61S8KKncEBnuf0urNejw,1358
|
2
|
+
livekit/plugins/deepgram/_utils.py,sha256=NgeR4qKZOeqs1wr8v4G2Q_KPZ5xUSFDE4f2N6WXnZH4,2041
|
3
|
+
livekit/plugins/deepgram/log.py,sha256=isjd2-ROJXiDFhRRnqRmYxv16U5H9dBV6ut2g5bU7q0,71
|
4
|
+
livekit/plugins/deepgram/models.py,sha256=dVguYc9AfjlexreN_O1C0NxX3q-ZK9k8s5B3hWsbtZ0,1236
|
5
|
+
livekit/plugins/deepgram/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
livekit/plugins/deepgram/stt.py,sha256=snDTVjK6r0QJraLL0HzyvCqcy-bAJwuMNWlbJMLFybs,32025
|
7
|
+
livekit/plugins/deepgram/tts.py,sha256=PgQfOJFcBoWzOhTJZEnipGo0hxhBzZNqZhtVW9txmUw,15415
|
8
|
+
livekit/plugins/deepgram/version.py,sha256=5lzQkS1jEPqreexacwMd18b2EOx7R5m8AQMKtQRBgC4,601
|
9
|
+
livekit_plugins_deepgram-1.0.21.dist-info/METADATA,sha256=yt3zUCbuCeQvdAYHu5fFpRDyaLh7sv8H-Q0yl53ApRc,1450
|
10
|
+
livekit_plugins_deepgram-1.0.21.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
11
|
+
livekit_plugins_deepgram-1.0.21.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
livekit/plugins/deepgram/__init__.py,sha256=o1BgJLSoxrTkSUHXkKrFMl9e0bF6am2TFrDMV4U6j7g,584
|
2
|
-
livekit/plugins/deepgram/_utils.py,sha256=0O3O77qURXjYYCenl5McE85fcBApaQvQl5zKQzvYfR8,1276
|
3
|
-
livekit/plugins/deepgram/log.py,sha256=isjd2-ROJXiDFhRRnqRmYxv16U5H9dBV6ut2g5bU7q0,71
|
4
|
-
livekit/plugins/deepgram/models.py,sha256=dVguYc9AfjlexreN_O1C0NxX3q-ZK9k8s5B3hWsbtZ0,1236
|
5
|
-
livekit/plugins/deepgram/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
livekit/plugins/deepgram/stt.py,sha256=1O1jbfQRRX9WrpL2sCuKNb5bKvuE8bVsd9goA0td_FE,32692
|
7
|
-
livekit/plugins/deepgram/tts.py,sha256=SX7vdMz4AZoZv2o_0EVwym5WMbFzy44nNGEyw2s9XFA,15728
|
8
|
-
livekit/plugins/deepgram/version.py,sha256=UDC8ahmGgRkv-qMQUY3QibuuVevGMQ9Fd4yIhcQBZwA,601
|
9
|
-
livekit_plugins_deepgram-1.0.19.dist-info/METADATA,sha256=LOmgHOZx7QUh6LDSL3PhoBSY4P4-UdEQY4_1bHdVN1Q,1350
|
10
|
-
livekit_plugins_deepgram-1.0.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
11
|
-
livekit_plugins_deepgram-1.0.19.dist-info/RECORD,,
|
{livekit_plugins_deepgram-1.0.19.dist-info → livekit_plugins_deepgram-1.0.21.dist-info}/WHEEL
RENAMED
File without changes
|