livekit-plugins-fal 0.2.3__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.
Potentially problematic release.
This version of livekit-plugins-fal might be problematic. Click here for more details.
- livekit_plugins_fal-0.2.3/PKG-INFO +47 -0
- livekit_plugins_fal-0.2.3/README.md +13 -0
- livekit_plugins_fal-0.2.3/livekit/plugins/fal/__init__.py +46 -0
- livekit_plugins_fal-0.2.3/livekit/plugins/fal/log.py +3 -0
- livekit_plugins_fal-0.2.3/livekit/plugins/fal/py.typed +0 -0
- livekit_plugins_fal-0.2.3/livekit/plugins/fal/stt.py +108 -0
- livekit_plugins_fal-0.2.3/livekit/plugins/fal/version.py +15 -0
- livekit_plugins_fal-0.2.3/livekit_plugins_fal.egg-info/PKG-INFO +47 -0
- livekit_plugins_fal-0.2.3/livekit_plugins_fal.egg-info/SOURCES.txt +13 -0
- livekit_plugins_fal-0.2.3/livekit_plugins_fal.egg-info/dependency_links.txt +1 -0
- livekit_plugins_fal-0.2.3/livekit_plugins_fal.egg-info/requires.txt +2 -0
- livekit_plugins_fal-0.2.3/livekit_plugins_fal.egg-info/top_level.txt +1 -0
- livekit_plugins_fal-0.2.3/pyproject.toml +3 -0
- livekit_plugins_fal-0.2.3/setup.cfg +4 -0
- livekit_plugins_fal-0.2.3/setup.py +57 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: livekit-plugins-fal
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: fal plugin template for LiveKit Agents
|
|
5
|
+
Home-page: https://github.com/livekit/agents
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Documentation, https://docs.livekit.io
|
|
8
|
+
Project-URL: Website, https://livekit.io/
|
|
9
|
+
Project-URL: Source, https://github.com/livekit/agents
|
|
10
|
+
Keywords: webrtc,realtime,audio,video,livekit
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
14
|
+
Classifier: Topic :: Multimedia :: Video
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Requires-Python: >=3.9.0
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: livekit-agents>=0.12.3
|
|
23
|
+
Requires-Dist: fal_client
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: description-content-type
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: keywords
|
|
29
|
+
Dynamic: license
|
|
30
|
+
Dynamic: project-url
|
|
31
|
+
Dynamic: requires-dist
|
|
32
|
+
Dynamic: requires-python
|
|
33
|
+
Dynamic: summary
|
|
34
|
+
|
|
35
|
+
# LiveKit Plugins Fal
|
|
36
|
+
|
|
37
|
+
This plugin provides a simple way to integrate FAL models into the LiveKit Agent Framework. currently supports Whizper model for STT
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install livekit-plugins-fal
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Pre-requisites
|
|
46
|
+
|
|
47
|
+
You'll need an API key from FAL. It can be set as an environment variable: `FAL_KEY`
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# LiveKit Plugins Fal
|
|
2
|
+
|
|
3
|
+
This plugin provides a simple way to integrate FAL models into the LiveKit Agent Framework. currently supports Whizper model for STT
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install livekit-plugins-fal
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Pre-requisites
|
|
12
|
+
|
|
13
|
+
You'll need an API key from FAL. It can be set as an environment variable: `FAL_KEY`
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright 2023 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
|
+
# Copyright 2023 LiveKit, Inc.
|
|
16
|
+
#
|
|
17
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
18
|
+
# you may not use this file except in compliance with the License.
|
|
19
|
+
# You may obtain a copy of the License at
|
|
20
|
+
#
|
|
21
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
#
|
|
23
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
24
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
25
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
26
|
+
# See the License for the specific language governing permissions and
|
|
27
|
+
# limitations under the License.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
from .stt import WizperSTT
|
|
31
|
+
from .version import __version__
|
|
32
|
+
|
|
33
|
+
__all__ = ["WizperSTT", "__version__"]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
from livekit.agents import Plugin
|
|
37
|
+
|
|
38
|
+
from .log import logger
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class FalPlugin(Plugin):
|
|
42
|
+
def __init__(self):
|
|
43
|
+
super().__init__(__name__, __version__, __package__, logger)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
Plugin.register_plugin(FalPlugin())
|
|
File without changes
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
import os
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
8
|
+
import fal_client
|
|
9
|
+
from livekit import rtc
|
|
10
|
+
from livekit.agents import (
|
|
11
|
+
APIConnectionError,
|
|
12
|
+
APIConnectOptions,
|
|
13
|
+
stt,
|
|
14
|
+
)
|
|
15
|
+
from livekit.agents.stt import SpeechEventType, STTCapabilities
|
|
16
|
+
from livekit.agents.utils import AudioBuffer
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class _STTOptions:
|
|
21
|
+
language: str
|
|
22
|
+
task: str
|
|
23
|
+
chunk_level: str
|
|
24
|
+
version: str
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class WizperSTT(stt.STT):
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
*,
|
|
31
|
+
language: Optional[str] = "en",
|
|
32
|
+
task: Optional[str] = "transcribe",
|
|
33
|
+
chunk_level: Optional[str] = "segment",
|
|
34
|
+
version: Optional[str] = "3",
|
|
35
|
+
):
|
|
36
|
+
super().__init__(
|
|
37
|
+
capabilities=STTCapabilities(streaming=False, interim_results=True)
|
|
38
|
+
)
|
|
39
|
+
self._api_key = os.getenv("FAL_KEY")
|
|
40
|
+
self._opts = _STTOptions(
|
|
41
|
+
language=language or "en",
|
|
42
|
+
task=task or "transcribe",
|
|
43
|
+
chunk_level=chunk_level or "segment",
|
|
44
|
+
version=version or "3",
|
|
45
|
+
)
|
|
46
|
+
self._fal_client = fal_client.AsyncClient()
|
|
47
|
+
|
|
48
|
+
if not self._api_key:
|
|
49
|
+
raise ValueError(
|
|
50
|
+
"FAL AI API key is required. It should be set with env FAL_KEY"
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
def update_options(self, *, language: Optional[str] = None) -> None:
|
|
54
|
+
self._opts.language = language or self._opts.language
|
|
55
|
+
|
|
56
|
+
def _sanitize_options(
|
|
57
|
+
self,
|
|
58
|
+
*,
|
|
59
|
+
language: Optional[str] = None,
|
|
60
|
+
task: Optional[str] = None,
|
|
61
|
+
chunk_level: Optional[str] = None,
|
|
62
|
+
version: Optional[str] = None,
|
|
63
|
+
) -> _STTOptions:
|
|
64
|
+
config = dataclasses.replace(self._opts)
|
|
65
|
+
config.language = language or config.language
|
|
66
|
+
config.task = task or config.task
|
|
67
|
+
config.chunk_level = chunk_level or config.chunk_level
|
|
68
|
+
config.version = version or config.version
|
|
69
|
+
return config
|
|
70
|
+
|
|
71
|
+
async def _recognize_impl(
|
|
72
|
+
self,
|
|
73
|
+
buffer: AudioBuffer,
|
|
74
|
+
*,
|
|
75
|
+
language: str | None,
|
|
76
|
+
conn_options: APIConnectOptions,
|
|
77
|
+
) -> stt.SpeechEvent:
|
|
78
|
+
try:
|
|
79
|
+
config = self._sanitize_options(language=language)
|
|
80
|
+
data_uri = fal_client.encode(
|
|
81
|
+
rtc.combine_audio_frames(buffer).to_wav_bytes(), "audio/x-wav"
|
|
82
|
+
)
|
|
83
|
+
response = await self._fal_client.run(
|
|
84
|
+
"fal-ai/wizper",
|
|
85
|
+
arguments={
|
|
86
|
+
"audio_url": data_uri,
|
|
87
|
+
"task": config.task,
|
|
88
|
+
"language": config.language,
|
|
89
|
+
"chunk_level": config.chunk_level,
|
|
90
|
+
"version": config.version,
|
|
91
|
+
},
|
|
92
|
+
timeout=conn_options.timeout,
|
|
93
|
+
)
|
|
94
|
+
text = response.get("text", "")
|
|
95
|
+
return self._transcription_to_speech_event(text=text)
|
|
96
|
+
except fal_client.client.FalClientError as e:
|
|
97
|
+
raise APIConnectionError() from e
|
|
98
|
+
|
|
99
|
+
def _transcription_to_speech_event(
|
|
100
|
+
self, event_type=SpeechEventType.FINAL_TRANSCRIPT, text=None
|
|
101
|
+
) -> stt.SpeechEvent:
|
|
102
|
+
return stt.SpeechEvent(
|
|
103
|
+
type=event_type,
|
|
104
|
+
alternatives=[stt.SpeechData(text=text, language=self._opts.language)],
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
async def aclose(self) -> None:
|
|
108
|
+
await self._fal_client._client.aclose()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Copyright 2023 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
|
+
__version__ = "0.2.3"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: livekit-plugins-fal
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: fal plugin template for LiveKit Agents
|
|
5
|
+
Home-page: https://github.com/livekit/agents
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Documentation, https://docs.livekit.io
|
|
8
|
+
Project-URL: Website, https://livekit.io/
|
|
9
|
+
Project-URL: Source, https://github.com/livekit/agents
|
|
10
|
+
Keywords: webrtc,realtime,audio,video,livekit
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
14
|
+
Classifier: Topic :: Multimedia :: Video
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Requires-Python: >=3.9.0
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: livekit-agents>=0.12.3
|
|
23
|
+
Requires-Dist: fal_client
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: description-content-type
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: keywords
|
|
29
|
+
Dynamic: license
|
|
30
|
+
Dynamic: project-url
|
|
31
|
+
Dynamic: requires-dist
|
|
32
|
+
Dynamic: requires-python
|
|
33
|
+
Dynamic: summary
|
|
34
|
+
|
|
35
|
+
# LiveKit Plugins Fal
|
|
36
|
+
|
|
37
|
+
This plugin provides a simple way to integrate FAL models into the LiveKit Agent Framework. currently supports Whizper model for STT
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install livekit-plugins-fal
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Pre-requisites
|
|
46
|
+
|
|
47
|
+
You'll need an API key from FAL. It can be set as an environment variable: `FAL_KEY`
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
setup.py
|
|
4
|
+
livekit/plugins/fal/__init__.py
|
|
5
|
+
livekit/plugins/fal/log.py
|
|
6
|
+
livekit/plugins/fal/py.typed
|
|
7
|
+
livekit/plugins/fal/stt.py
|
|
8
|
+
livekit/plugins/fal/version.py
|
|
9
|
+
livekit_plugins_fal.egg-info/PKG-INFO
|
|
10
|
+
livekit_plugins_fal.egg-info/SOURCES.txt
|
|
11
|
+
livekit_plugins_fal.egg-info/dependency_links.txt
|
|
12
|
+
livekit_plugins_fal.egg-info/requires.txt
|
|
13
|
+
livekit_plugins_fal.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
livekit
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Copyright 2023 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
|
+
import os
|
|
16
|
+
import pathlib
|
|
17
|
+
|
|
18
|
+
import setuptools
|
|
19
|
+
import setuptools.command.build_py
|
|
20
|
+
|
|
21
|
+
here = pathlib.Path(__file__).parent.resolve()
|
|
22
|
+
about = {}
|
|
23
|
+
with open(os.path.join(here, "livekit", "plugins", "fal", "version.py"), "r") as f:
|
|
24
|
+
exec(f.read(), about)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
setuptools.setup(
|
|
28
|
+
name="livekit-plugins-fal",
|
|
29
|
+
version=about["__version__"],
|
|
30
|
+
description="fal plugin template for LiveKit Agents",
|
|
31
|
+
long_description=(here / "README.md").read_text(encoding="utf-8"),
|
|
32
|
+
long_description_content_type="text/markdown",
|
|
33
|
+
url="https://github.com/livekit/agents",
|
|
34
|
+
cmdclass={},
|
|
35
|
+
classifiers=[
|
|
36
|
+
"Intended Audience :: Developers",
|
|
37
|
+
"License :: OSI Approved :: Apache Software License",
|
|
38
|
+
"Topic :: Multimedia :: Sound/Audio",
|
|
39
|
+
"Topic :: Multimedia :: Video",
|
|
40
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
41
|
+
"Programming Language :: Python :: 3",
|
|
42
|
+
"Programming Language :: Python :: 3.9",
|
|
43
|
+
"Programming Language :: Python :: 3.10",
|
|
44
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
45
|
+
],
|
|
46
|
+
keywords=["webrtc", "realtime", "audio", "video", "livekit"],
|
|
47
|
+
license="Apache-2.0",
|
|
48
|
+
packages=setuptools.find_namespace_packages(include=["livekit.*"]),
|
|
49
|
+
python_requires=">=3.9.0",
|
|
50
|
+
install_requires=["livekit-agents>=0.12.3", "fal_client"],
|
|
51
|
+
package_data={"livekit.plugins.fal": ["py.typed"]},
|
|
52
|
+
project_urls={
|
|
53
|
+
"Documentation": "https://docs.livekit.io",
|
|
54
|
+
"Website": "https://livekit.io/",
|
|
55
|
+
"Source": "https://github.com/livekit/agents",
|
|
56
|
+
},
|
|
57
|
+
)
|