livekit-plugins-gladia 1.0.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.
@@ -0,0 +1,168 @@
1
+ **/.vscode
2
+ **/.DS_Store
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ share/python-wheels/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+ MANIFEST
31
+
32
+ # PyInstaller
33
+ # Usually these files are written by a python script from a template
34
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+ *.manifest
36
+ *.spec
37
+
38
+ # Installer logs
39
+ pip-log.txt
40
+ pip-delete-this-directory.txt
41
+
42
+ # Unit test / coverage reports
43
+ htmlcov/
44
+ .tox/
45
+ .nox/
46
+ .coverage
47
+ .coverage.*
48
+ .cache
49
+ nosetests.xml
50
+ coverage.xml
51
+ *.cover
52
+ *.py,cover
53
+ .hypothesis/
54
+ .pytest_cache/
55
+ cover/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ .pybuilder/
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the code is
90
+ # intended to run in multiple environments; otherwise, check them in:
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ #Pipfile.lock
99
+
100
+ # poetry
101
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
102
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
103
+ # commonly ignored for libraries.
104
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
105
+ #poetry.lock
106
+
107
+ # pdm
108
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
109
+ #pdm.lock
110
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
111
+ # in version control.
112
+ # https://pdm.fming.dev/#use-with-ide
113
+ .pdm.toml
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ .idea/
164
+
165
+ node_modules
166
+
167
+ credentials.json
168
+ pyrightconfig.json
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: livekit-plugins-gladia
3
+ Version: 1.0.0
4
+ Summary: Agent Framework plugin for services using Gladia's API.
5
+ Project-URL: Documentation, https://docs.livekit.io
6
+ Project-URL: Website, https://livekit.io/
7
+ Project-URL: Source, https://github.com/livekit/agents
8
+ Author-email: LiveKit <support@livekit.io>
9
+ License-Expression: Apache-2.0
10
+ Keywords: audio,gladia,livekit,realtime,speech-to-text,video,webrtc
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Topic :: Multimedia :: Sound/Audio
18
+ Classifier: Topic :: Multimedia :: Video
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Requires-Python: >=3.9.0
21
+ Requires-Dist: aiohttp>=3.8.0
22
+ Requires-Dist: livekit-agents[codecs]>=1.0.0
23
+ Requires-Dist: numpy>=1.26
24
+ Description-Content-Type: text/markdown
25
+
26
+ # Gladia plugin for LiveKit
27
+
28
+ Agent Framework plugin for speech-to-text with [Gladia](https://gladia.io/)'s API. Currently supports streaming speech-to-text with optional translation.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install livekit-plugins-gladia
34
+ ```
35
+
36
+ ## Pre-requisites
37
+
38
+ You'll need an API key from Gladia. It can be set as an environment variable: `GLADIA_API_KEY`
39
+
40
+ ## Features
41
+
42
+ - Streaming speech-to-text
43
+ - Multi-language support
44
+ - Code-switching between languages
45
+ - Interim results (partial transcriptions)
46
+ - Voice activity detection with energy filtering
47
+ - Optional real-time translation
48
+ - Customizable audio parameters (sample rate, bit depth, channels, encoding)
49
+
50
+ ## Example Usage
51
+
52
+ ```python
53
+ from livekit.stt import STT
54
+ from livekit.plugins.gladia.stt import STT as GladiaSTT
55
+
56
+ # Basic initialization
57
+ stt = GladiaSTT(
58
+ api_key="your-api-key-here", # or use GLADIA_API_KEY env var
59
+ interim_results=True
60
+ )
61
+
62
+ # With more options
63
+ stt = GladiaSTT(
64
+ languages=["en", "fr"], # Specify languages or let Gladia auto-detect
65
+ code_switching=True, # Allow switching between languages during recognition
66
+ sample_rate=16000, # Audio sample rate in Hz
67
+ bit_depth=16, # Audio bit depth
68
+ channels=1, # Number of audio channels
69
+ encoding="wav/pcm", # Audio encoding format
70
+ energy_filter=True, # Enable voice activity detection
71
+ translation_enabled=True,
72
+ translation_target_languages=["en"],
73
+ translation_model="base",
74
+ translation_match_original_utterances=True
75
+ )
76
+
77
+ # Update options after initialization
78
+ stt.update_options(
79
+ languages=["ja", "en"],
80
+ translation_enabled=True,
81
+ translation_target_languages=["fr"]
82
+ )
83
+ ```
84
+
85
+ ## Using with LiveKit Agents Framework
86
+
87
+ ```python
88
+ from livekit.agents import Agent
89
+ from livekit.plugins.gladia.stt import STT as GladiaSTT
90
+
91
+ agent = Agent(
92
+ stt=GladiaSTT(
93
+ api_key="your-api-key-here",
94
+ languages=["en"],
95
+ translation_enabled=True,
96
+ translation_target_languages=["es"]
97
+ )
98
+ )
99
+
100
+ # Rest of your agent setup...
101
+ ```
@@ -0,0 +1,76 @@
1
+ # Gladia plugin for LiveKit
2
+
3
+ Agent Framework plugin for speech-to-text with [Gladia](https://gladia.io/)'s API. Currently supports streaming speech-to-text with optional translation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install livekit-plugins-gladia
9
+ ```
10
+
11
+ ## Pre-requisites
12
+
13
+ You'll need an API key from Gladia. It can be set as an environment variable: `GLADIA_API_KEY`
14
+
15
+ ## Features
16
+
17
+ - Streaming speech-to-text
18
+ - Multi-language support
19
+ - Code-switching between languages
20
+ - Interim results (partial transcriptions)
21
+ - Voice activity detection with energy filtering
22
+ - Optional real-time translation
23
+ - Customizable audio parameters (sample rate, bit depth, channels, encoding)
24
+
25
+ ## Example Usage
26
+
27
+ ```python
28
+ from livekit.stt import STT
29
+ from livekit.plugins.gladia.stt import STT as GladiaSTT
30
+
31
+ # Basic initialization
32
+ stt = GladiaSTT(
33
+ api_key="your-api-key-here", # or use GLADIA_API_KEY env var
34
+ interim_results=True
35
+ )
36
+
37
+ # With more options
38
+ stt = GladiaSTT(
39
+ languages=["en", "fr"], # Specify languages or let Gladia auto-detect
40
+ code_switching=True, # Allow switching between languages during recognition
41
+ sample_rate=16000, # Audio sample rate in Hz
42
+ bit_depth=16, # Audio bit depth
43
+ channels=1, # Number of audio channels
44
+ encoding="wav/pcm", # Audio encoding format
45
+ energy_filter=True, # Enable voice activity detection
46
+ translation_enabled=True,
47
+ translation_target_languages=["en"],
48
+ translation_model="base",
49
+ translation_match_original_utterances=True
50
+ )
51
+
52
+ # Update options after initialization
53
+ stt.update_options(
54
+ languages=["ja", "en"],
55
+ translation_enabled=True,
56
+ translation_target_languages=["fr"]
57
+ )
58
+ ```
59
+
60
+ ## Using with LiveKit Agents Framework
61
+
62
+ ```python
63
+ from livekit.agents import Agent
64
+ from livekit.plugins.gladia.stt import STT as GladiaSTT
65
+
66
+ agent = Agent(
67
+ stt=GladiaSTT(
68
+ api_key="your-api-key-here",
69
+ languages=["en"],
70
+ translation_enabled=True,
71
+ translation_target_languages=["es"]
72
+ )
73
+ )
74
+
75
+ # Rest of your agent setup...
76
+ ```
@@ -0,0 +1,25 @@
1
+ from .stt import STT, AudioEnergyFilter, SpeechStream
2
+ from .version import __version__
3
+
4
+ __all__ = ["STT", "SpeechStream", "AudioEnergyFilter", "__version__"]
5
+
6
+
7
+ from livekit.agents import Plugin
8
+
9
+ from .log import logger
10
+
11
+
12
+ class GladiaPlugin(Plugin):
13
+ def __init__(self):
14
+ super().__init__(__name__, __version__, __package__, logger)
15
+
16
+
17
+ Plugin.register_plugin(GladiaPlugin())
18
+
19
+ _module = dir()
20
+ NOT_IN_ALL = [m for m in _module if m not in __all__]
21
+
22
+ __pdoc__ = {}
23
+
24
+ for n in NOT_IN_ALL:
25
+ __pdoc__[n] = False
@@ -0,0 +1,36 @@
1
+ import time
2
+ from typing import Callable, Generic, Optional, TypeVar
3
+
4
+ T = TypeVar("T")
5
+
6
+
7
+ class PeriodicCollector(Generic[T]):
8
+ def __init__(self, callback: Callable[[T], None], *, duration: float) -> None:
9
+ """
10
+ Create a new periodic collector that accumulates values and calls the callback
11
+ after the specified duration if there are values to report.
12
+
13
+ Args:
14
+ duration: Time in seconds between callback invocations
15
+ callback: Function to call with accumulated value when duration expires
16
+ """
17
+ self._duration = duration
18
+ self._callback = callback
19
+ self._last_flush_time = time.monotonic()
20
+ self._total: Optional[T] = None
21
+
22
+ def push(self, value: T) -> None:
23
+ """Add a value to the accumulator"""
24
+ if self._total is None:
25
+ self._total = value
26
+ else:
27
+ self._total += value
28
+ if time.monotonic() - self._last_flush_time >= self._duration:
29
+ self.flush()
30
+
31
+ def flush(self) -> None:
32
+ """Force callback to be called with current total if non-zero"""
33
+ if self._total is not None:
34
+ self._callback(self._total)
35
+ self._total = None
36
+ self._last_flush_time = time.monotonic()
@@ -0,0 +1,3 @@
1
+ import logging
2
+
3
+ logger = logging.getLogger("livekit.plugins.gladia")
@@ -0,0 +1,121 @@
1
+ from typing import Literal
2
+
3
+ GladiaModels = Literal["base"]
4
+
5
+ GladiaLanguages = Literal[
6
+ "af",
7
+ "sq",
8
+ "am",
9
+ "ar",
10
+ "hy",
11
+ "as",
12
+ "ast",
13
+ "az",
14
+ "ba",
15
+ "eu",
16
+ "be",
17
+ "bn",
18
+ "bs",
19
+ "br",
20
+ "bg",
21
+ "my",
22
+ "es",
23
+ "ca",
24
+ "ceb",
25
+ "zh",
26
+ "hr",
27
+ "cs",
28
+ "da",
29
+ "nl",
30
+ "en",
31
+ "et",
32
+ "fo",
33
+ "fi",
34
+ "fr",
35
+ "fy",
36
+ "ff",
37
+ "gd",
38
+ "gl",
39
+ "lg",
40
+ "ka",
41
+ "de",
42
+ "el",
43
+ "gu",
44
+ "ht",
45
+ "ha",
46
+ "haw",
47
+ "he",
48
+ "hi",
49
+ "hu",
50
+ "is",
51
+ "ig",
52
+ "ilo",
53
+ "id",
54
+ "ga",
55
+ "it",
56
+ "ja",
57
+ "jv",
58
+ "kn",
59
+ "kk",
60
+ "km",
61
+ "ko",
62
+ "lo",
63
+ "la",
64
+ "lv",
65
+ "lb",
66
+ "ln",
67
+ "lt",
68
+ "mk",
69
+ "mg",
70
+ "ms",
71
+ "ml",
72
+ "mt",
73
+ "mi",
74
+ "mr",
75
+ "mo",
76
+ "mn",
77
+ "ne",
78
+ "no",
79
+ "nn",
80
+ "oc",
81
+ "or",
82
+ "pa",
83
+ "ps",
84
+ "fa",
85
+ "pl",
86
+ "pt",
87
+ "ro",
88
+ "ru",
89
+ "sa",
90
+ "sr",
91
+ "sn",
92
+ "sd",
93
+ "si",
94
+ "sk",
95
+ "sl",
96
+ "so",
97
+ "su",
98
+ "sw",
99
+ "ss",
100
+ "sv",
101
+ "tl",
102
+ "tg",
103
+ "ta",
104
+ "tt",
105
+ "te",
106
+ "th",
107
+ "bo",
108
+ "tn",
109
+ "tr",
110
+ "tk",
111
+ "uk",
112
+ "ur",
113
+ "uz",
114
+ "vi",
115
+ "cy",
116
+ "wo",
117
+ "xh",
118
+ "yi",
119
+ "yo",
120
+ "zu",
121
+ ]