-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add livekit-plugins-funasr (FunASR/SenseVoice local STT) #6176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LauraGPT
wants to merge
23
commits into
livekit:main
Choose a base branch
from
LauraGPT:add-funasr-stt-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
816f892
Add livekit-plugins-funasr: pyproject.toml
LauraGPT e6eb02a
Add livekit-plugins-funasr: README.md
LauraGPT b93bd6d
Add livekit-plugins-funasr: __init__.py
LauraGPT ba6a1cb
Add livekit-plugins-funasr: stt.py
LauraGPT df3adcc
Add livekit-plugins-funasr: version.py
LauraGPT 6cf385d
Add livekit-plugins-funasr: log.py
LauraGPT be69daf
Register livekit-plugins-funasr workspace source
LauraGPT 576bf71
Fix CI: ruff format, type annotations, LanguageCode for SpeechData
LauraGPT 6a8949f
Add py.typed marker so the package is type-checkable
LauraGPT f6163a7
Address review: real model name, drop nospeech as language, thread-sa…
LauraGPT 161ab6c
Address FunASR STT review feedback
LauraGPT eeacb61
fix(funasr): complete plugin packaging
LauraGPT ed0dae1
Align FunASR plugin version with agents extra
LauraGPT 63e4ab8
Fix LiveKit CI dependency locks after upstream merge
LauraGPT bf71537
Fix FunASR model loading lifecycle
LauraGPT 59c4f5c
Keep FunASR inference serialized after cancellation
LauraGPT 7732eeb
chore(deps): lock FunASR plugin dependencies
LauraGPT 727f524
fix(funasr): snapshot request options and redact model logs
LauraGPT df6df9a
fix(funasr): align dependency and telemetry contracts
LauraGPT 48e340e
fix(funasr): align plugin with LiveKit 1.8.0
LauraGPT 3d9808e
fix(funasr): redact inference errors and model telemetry
LauraGPT 67c9489
fix(funasr): preserve model identity across private telemetry
LauraGPT 45925ac
fix: resolve current STT metadata for each user-turn span
LauraGPT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # LiveKit Plugins FunASR | ||
|
|
||
| Agent Framework plugin for local speech-to-text with [FunASR](https://github.com/modelscope/FunASR) models such as [SenseVoice](https://github.com/FunAudioLLM/SenseVoice). | ||
|
|
||
| SenseVoice is an open-source, fully-local, non-autoregressive multilingual ASR model (Chinese, Cantonese, English, Japanese, Korean and more) with leading Chinese accuracy and fast inference. The model runs locally, so no API key is required. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install livekit-plugins-funasr | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```python | ||
| from livekit.plugins import funasr | ||
|
|
||
| stt = funasr.STT(model="iic/SenseVoiceSmall") | ||
| ``` | ||
|
|
||
| The first run downloads the model from ModelScope/Hugging Face. Use `language=None` (default) for automatic language detection, or set e.g. `language="zh"`. | ||
|
|
||
| CPU inference works with the default installation. For GPU inference, install a | ||
| PyTorch and torchaudio build that matches your CUDA runtime, then pass | ||
| `device="cuda"`. |
44 changes: 44 additions & 0 deletions
44
livekit-plugins/livekit-plugins-funasr/livekit/plugins/funasr/__init__.py
|
devin-ai-integration[bot] marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright 2024 LiveKit, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """FunASR plugin for LiveKit Agents. | ||
|
|
||
| Local, fully-offline multilingual speech-to-text using FunASR models such as | ||
| SenseVoice (Chinese, Cantonese, English, Japanese, Korean and more). | ||
| See https://github.com/modelscope/FunASR for more information. | ||
| """ | ||
|
|
||
| from .stt import _DEFAULT_MODEL, FunASRSTT, FunASRSTT as STT, _load_model | ||
| from .version import __version__ | ||
|
|
||
| __all__ = ["FunASRSTT", "STT", "__version__"] | ||
|
|
||
| from livekit.agents import Plugin | ||
|
|
||
| from .log import logger | ||
|
|
||
|
|
||
| class FunASRPlugin(Plugin): | ||
| """Register the FunASR integration and its model-download hook.""" | ||
|
|
||
| def __init__(self) -> None: | ||
| """Create the LiveKit plugin registration.""" | ||
| super().__init__(__name__, __version__, __package__, logger) | ||
|
|
||
| def download_files(self) -> None: | ||
| """Download the default SenseVoice model for offline agent startup.""" | ||
| _load_model(_DEFAULT_MODEL, "cpu") | ||
|
|
||
|
|
||
| Plugin.register_plugin(FunASRPlugin()) |
3 changes: 3 additions & 0 deletions
3
livekit-plugins/livekit-plugins-funasr/livekit/plugins/funasr/log.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import logging | ||
|
|
||
| logger = logging.getLogger("livekit.plugins.funasr") |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.