livekit-plugins-fal 0.2.3__py3-none-any.whl → 1.0.0__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.
Potentially problematic release.
This version of livekit-plugins-fal might be problematic. Click here for more details.
- livekit/plugins/fal/stt.py +30 -58
- livekit/plugins/fal/version.py +1 -1
- {livekit_plugins_fal-0.2.3.dist-info → livekit_plugins_fal-1.0.0.dist-info}/METADATA +14 -24
- livekit_plugins_fal-1.0.0.dist-info/RECORD +8 -0
- {livekit_plugins_fal-0.2.3.dist-info → livekit_plugins_fal-1.0.0.dist-info}/WHEEL +1 -2
- livekit_plugins_fal-0.2.3.dist-info/RECORD +0 -9
- livekit_plugins_fal-0.2.3.dist-info/top_level.txt +0 -1
livekit/plugins/fal/stt.py
CHANGED
|
@@ -1,82 +1,56 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import dataclasses
|
|
4
3
|
import os
|
|
5
4
|
from dataclasses import dataclass
|
|
6
|
-
from typing import Optional
|
|
7
5
|
|
|
8
6
|
import fal_client
|
|
7
|
+
|
|
9
8
|
from livekit import rtc
|
|
10
|
-
from livekit.agents import
|
|
11
|
-
APIConnectionError,
|
|
12
|
-
APIConnectOptions,
|
|
13
|
-
stt,
|
|
14
|
-
)
|
|
9
|
+
from livekit.agents import APIConnectionError, APIConnectOptions, stt
|
|
15
10
|
from livekit.agents.stt import SpeechEventType, STTCapabilities
|
|
16
|
-
from livekit.agents.
|
|
11
|
+
from livekit.agents.types import (
|
|
12
|
+
NOT_GIVEN,
|
|
13
|
+
NotGivenOr,
|
|
14
|
+
)
|
|
15
|
+
from livekit.agents.utils import AudioBuffer, is_given
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
@dataclass
|
|
20
19
|
class _STTOptions:
|
|
21
|
-
language: str
|
|
22
|
-
task: str
|
|
23
|
-
chunk_level: str
|
|
24
|
-
version: str
|
|
20
|
+
language: str = "en"
|
|
21
|
+
task: str = "transcribe"
|
|
22
|
+
chunk_level: str = "segment"
|
|
23
|
+
version: str = "3"
|
|
25
24
|
|
|
26
25
|
|
|
27
26
|
class WizperSTT(stt.STT):
|
|
28
27
|
def __init__(
|
|
29
28
|
self,
|
|
30
29
|
*,
|
|
31
|
-
language:
|
|
32
|
-
|
|
33
|
-
chunk_level: Optional[str] = "segment",
|
|
34
|
-
version: Optional[str] = "3",
|
|
30
|
+
language: NotGivenOr[str] = NOT_GIVEN,
|
|
31
|
+
api_key: NotGivenOr[str] = NOT_GIVEN,
|
|
35
32
|
):
|
|
36
|
-
super().__init__(
|
|
37
|
-
|
|
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
|
-
|
|
33
|
+
super().__init__(capabilities=STTCapabilities(streaming=False, interim_results=True))
|
|
34
|
+
self._api_key = api_key if is_given(api_key) else os.getenv("FAL_KEY")
|
|
48
35
|
if not self._api_key:
|
|
49
|
-
raise ValueError(
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
raise ValueError("fal AI API key is required. It should be set with env FAL_KEY")
|
|
37
|
+
self._opts = _STTOptions(language=language)
|
|
38
|
+
self._fal_client = fal_client.AsyncClient(key=self._api_key)
|
|
52
39
|
|
|
53
|
-
def update_options(self, *, language:
|
|
54
|
-
|
|
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
|
|
40
|
+
def update_options(self, *, language: NotGivenOr[str] = NOT_GIVEN) -> None:
|
|
41
|
+
if is_given(language):
|
|
42
|
+
self._opts.language = language
|
|
70
43
|
|
|
71
44
|
async def _recognize_impl(
|
|
72
45
|
self,
|
|
73
46
|
buffer: AudioBuffer,
|
|
74
47
|
*,
|
|
75
|
-
language: str
|
|
48
|
+
language: NotGivenOr[str] = NOT_GIVEN,
|
|
76
49
|
conn_options: APIConnectOptions,
|
|
77
50
|
) -> stt.SpeechEvent:
|
|
78
51
|
try:
|
|
79
|
-
|
|
52
|
+
if is_given(language):
|
|
53
|
+
self._opts.language = language
|
|
80
54
|
data_uri = fal_client.encode(
|
|
81
55
|
rtc.combine_audio_frames(buffer).to_wav_bytes(), "audio/x-wav"
|
|
82
56
|
)
|
|
@@ -84,10 +58,10 @@ class WizperSTT(stt.STT):
|
|
|
84
58
|
"fal-ai/wizper",
|
|
85
59
|
arguments={
|
|
86
60
|
"audio_url": data_uri,
|
|
87
|
-
"task":
|
|
88
|
-
"language":
|
|
89
|
-
"chunk_level":
|
|
90
|
-
"version":
|
|
61
|
+
"task": self._opts.task,
|
|
62
|
+
"language": self._opts.language,
|
|
63
|
+
"chunk_level": self._opts.chunk_level,
|
|
64
|
+
"version": self._opts.version,
|
|
91
65
|
},
|
|
92
66
|
timeout=conn_options.timeout,
|
|
93
67
|
)
|
|
@@ -96,11 +70,9 @@ class WizperSTT(stt.STT):
|
|
|
96
70
|
except fal_client.client.FalClientError as e:
|
|
97
71
|
raise APIConnectionError() from e
|
|
98
72
|
|
|
99
|
-
def _transcription_to_speech_event(
|
|
100
|
-
self, event_type=SpeechEventType.FINAL_TRANSCRIPT, text=None
|
|
101
|
-
) -> stt.SpeechEvent:
|
|
73
|
+
def _transcription_to_speech_event(self, text: str) -> stt.SpeechEvent:
|
|
102
74
|
return stt.SpeechEvent(
|
|
103
|
-
type=
|
|
75
|
+
type=SpeechEventType.FINAL_TRANSCRIPT,
|
|
104
76
|
alternatives=[stt.SpeechData(text=text, language=self._opts.language)],
|
|
105
77
|
)
|
|
106
78
|
|
livekit/plugins/fal/version.py
CHANGED
|
@@ -1,40 +1,30 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: livekit-plugins-fal
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: fal plugin template for LiveKit Agents
|
|
5
|
-
Home-page: https://github.com/livekit/agents
|
|
6
|
-
License: Apache-2.0
|
|
7
5
|
Project-URL: Documentation, https://docs.livekit.io
|
|
8
6
|
Project-URL: Website, https://livekit.io/
|
|
9
7
|
Project-URL: Source, https://github.com/livekit/agents
|
|
10
|
-
|
|
8
|
+
Author: LiveKit
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
Keywords: audio,livekit,realtime,video,webrtc
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
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
13
|
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.9
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
-
Classifier:
|
|
17
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
18
|
+
Classifier: Topic :: Multimedia :: Video
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
20
|
Requires-Python: >=3.9.0
|
|
21
|
+
Requires-Dist: fal-client
|
|
22
|
+
Requires-Dist: livekit-agents>=1.0.0
|
|
21
23
|
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
24
|
|
|
35
|
-
# LiveKit Plugins
|
|
25
|
+
# LiveKit Plugins fal
|
|
36
26
|
|
|
37
|
-
This plugin provides a simple way to integrate
|
|
27
|
+
This plugin provides a simple way to integrate fal.ai models into the LiveKit Agent Framework. currently supports Wizper model for STT.
|
|
38
28
|
|
|
39
29
|
## Installation
|
|
40
30
|
|
|
@@ -44,4 +34,4 @@ pip install livekit-plugins-fal
|
|
|
44
34
|
|
|
45
35
|
## Pre-requisites
|
|
46
36
|
|
|
47
|
-
You'll need an API key from
|
|
37
|
+
You'll need an API key from fal. It can be set as an environment variable: `FAL_KEY`
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
livekit/plugins/fal/__init__.py,sha256=2yFGbnRBL846WEDry3a4CTTwWSiLSI4Otqhlo6g4Lf4,1476
|
|
2
|
+
livekit/plugins/fal/log.py,sha256=E03cKaUVgXY2O7RpX33IQIaRCpFJ_nJMSkRCvCxX5fc,66
|
|
3
|
+
livekit/plugins/fal/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
livekit/plugins/fal/stt.py,sha256=i7kWKvftNbOZFaJzsrTz3gcO06m1dUnfQaWG8vAGSBo,2688
|
|
5
|
+
livekit/plugins/fal/version.py,sha256=IXTajzAuMAW4EojJB_UdbQh6qGhB8Ud5EP6JVK2om3g,599
|
|
6
|
+
livekit_plugins_fal-1.0.0.dist-info/METADATA,sha256=VKD1h-d5uha2r5u_j1I5LBJJ1-Tx4ZoHRlp0NVkfXdQ,1279
|
|
7
|
+
livekit_plugins_fal-1.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
8
|
+
livekit_plugins_fal-1.0.0.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
livekit/plugins/fal/__init__.py,sha256=2yFGbnRBL846WEDry3a4CTTwWSiLSI4Otqhlo6g4Lf4,1476
|
|
2
|
-
livekit/plugins/fal/log.py,sha256=E03cKaUVgXY2O7RpX33IQIaRCpFJ_nJMSkRCvCxX5fc,66
|
|
3
|
-
livekit/plugins/fal/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
livekit/plugins/fal/stt.py,sha256=HGOX_E-W6MCpefQFGj_UPw8X9gvsmoVLAO65FAz6-Es,3348
|
|
5
|
-
livekit/plugins/fal/version.py,sha256=hlkazOSjHhPITxXYBxVrCPGHhRf5IltBTWpXAL6jTfw,599
|
|
6
|
-
livekit_plugins_fal-0.2.3.dist-info/METADATA,sha256=Gu-XJuqmc0C1MKfsWvlvZGx9wmCj8rJRRLGKPbpvNpc,1510
|
|
7
|
-
livekit_plugins_fal-0.2.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
8
|
-
livekit_plugins_fal-0.2.3.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
|
|
9
|
-
livekit_plugins_fal-0.2.3.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
livekit
|