-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Adding InyaAI plugin #4512
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
Gnani-AI-Mintlify
wants to merge
3
commits into
livekit:main
Choose a base branch
from
Gnani-AI-Mintlify:main
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
Adding InyaAI plugin #4512
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| # LiveKit Gnani Plugin | ||
|
|
||
| This plugin provides Speech-to-Text functionality for LiveKit Agents using Gnani's (Vachana) multilingual STT engine with strong support for Indian languages. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install livekit-plugins-gnani | ||
| ``` | ||
|
|
||
| ## Features | ||
|
|
||
| - **Multilingual Support**: Transcribe audio in multiple Indian languages including Hindi, Tamil, Telugu, Kannada, Bengali, Gujarati, Marathi, Malayalam, Punjabi, and English (Indian accent) | ||
| - **Code-Switching**: Support for mixed language conversations (e.g., English-Hindi) | ||
| - **High-Quality Transcription**: Optimized for Indian accents and languages | ||
| - **Simple REST API**: Easy to integrate non-streaming transcription | ||
|
|
||
| ## Supported Languages | ||
|
|
||
| - `en-IN` - English (India) | ||
| - `hi-IN` - Hindi | ||
| - `gu-IN` - Gujarati | ||
| - `ta-IN` - Tamil | ||
| - `kn-IN` - Kannada | ||
| - `te-IN` - Telugu | ||
| - `mr-IN` - Marathi | ||
| - `bn-IN` - Bengali | ||
| - `ml-IN` - Malayalam | ||
| - `pa-IN` - Punjabi | ||
| - `en-IN,hi-IN` - English-Hindi (code-switching) | ||
|
|
||
| ## Configuration | ||
|
|
||
| You'll need to set up your Gnani credentials. You can do this via environment variables: | ||
|
|
||
| ```bash | ||
| export GNANI_API_KEY="your-api-key" | ||
| export GNANI_ORG_ID="your-organization-id" | ||
| export GNANI_USER_ID="your-user-id" | ||
| ``` | ||
|
|
||
| Or pass them directly when initializing the STT instance. | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Basic Usage | ||
|
|
||
| ```python | ||
| from livekit.agents import AutoSubscribe, JobContext, WorkerOptions, cli, llm | ||
| from livekit.plugins import gnani | ||
|
|
||
| async def entrypoint(ctx: JobContext): | ||
| # Initialize Gnani STT | ||
| stt_instance = gnani.STT( | ||
| language="hi-IN", # Hindi | ||
| ) | ||
|
|
||
| # Use with voice assistant | ||
| assistant = VoiceAssistant( | ||
| vad=silero.VAD.load(), | ||
| stt=stt_instance, | ||
| llm=llm.openai.LLM(), | ||
| tts=tts.openai.TTS(), | ||
| ) | ||
|
|
||
| await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY) | ||
| assistant.start(ctx.room) | ||
|
|
||
| if __name__ == "__main__": | ||
| cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint)) | ||
| ``` | ||
|
|
||
| ### With Explicit Credentials | ||
|
|
||
| ```python | ||
| from livekit.plugins import gnani | ||
|
|
||
| stt_instance = gnani.STT( | ||
| language="en-IN", | ||
| api_key="your-api-key", | ||
| organization_id="your-org-id", | ||
| user_id="your-user-id", | ||
| ) | ||
| ``` | ||
|
|
||
| ### Code-Switching (Multiple Languages) | ||
|
|
||
| ```python | ||
| from livekit.plugins import gnani | ||
|
|
||
| # Support English-Hindi code-switching | ||
| stt_instance = gnani.STT( | ||
| language="en-IN,hi-IN", | ||
| ) | ||
| ``` | ||
|
|
||
| ### Direct Recognition | ||
|
|
||
| ```python | ||
| from livekit.plugins import gnani | ||
| from livekit import rtc | ||
|
|
||
| stt_instance = gnani.STT(language="ta-IN") # Tamil | ||
|
|
||
| # Recognize from audio buffer | ||
| event = await stt_instance.recognize(buffer=audio_frames) | ||
| print(f"Transcript: {event.alternatives[0].text}") | ||
| ``` | ||
|
|
||
| ## API Details | ||
|
|
||
| The Gnani STT plugin uses the Gnani Vachana API v3 endpoint: | ||
|
|
||
| - **Endpoint**: `https://api.vachana.ai/stt/v3` | ||
| - **Method**: POST (multipart/form-data) | ||
| - **Authentication**: Via API headers | ||
| - **Audio Formats**: WAV, MP3, FLAC, OGG, M4A | ||
| - **Sample Rates**: 8 kHz – 44.1 kHz (mono recommended) | ||
| - **Max Duration**: Up to 60 seconds per request | ||
|
|
||
| ## Limitations | ||
|
|
||
| - **Non-Streaming**: This plugin uses the REST API which does not support streaming recognition. For streaming use cases, consider using `StreamAdapter` with a VAD. | ||
| - **Audio Duration**: Maximum 60 seconds per request | ||
| - **No Interim Results**: Only final transcripts are returned | ||
|
|
||
| ## Links | ||
|
|
||
| - [LiveKit Documentation](https://docs.livekit.io) | ||
| - [Gnani Vachana Platform](https://vachana.ai) | ||
| - [GitHub Repository](https://github.com/livekit/agents) | ||
|
|
||
| ## License | ||
|
|
||
| Apache License 2.0 |
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,2 @@ | ||
| # Namespace package | ||
| __path__ = __import__("pkgutil").extend_path(__path__, __name__) |
2 changes: 2 additions & 0 deletions
2
livekit-plugins/livekit-plugins-gnani/livekit/plugins/__init__.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,2 @@ | ||
| # Namespace package | ||
| __path__ = __import__("pkgutil").extend_path(__path__, __name__) |
48 changes: 48 additions & 0 deletions
48
livekit-plugins/livekit-plugins-gnani/livekit/plugins/gnani/__init__.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,48 @@ | ||
| # Copyright 2025 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. | ||
|
|
||
| """Gnani (Vachana) plugin for LiveKit Agents | ||
|
|
||
| This plugin provides Speech-to-Text functionality using Gnani's multilingual STT engine, | ||
| with support for Indian languages. | ||
|
|
||
| See https://vachana.ai for more information. | ||
| """ | ||
|
|
||
| from .stt import STT | ||
| from .version import __version__ | ||
|
|
||
| __all__ = ["STT", "__version__"] | ||
|
|
||
|
|
||
| from livekit.agents import Plugin | ||
|
|
||
| from .log import logger | ||
|
|
||
|
|
||
| class GnaniPlugin(Plugin): | ||
| def __init__(self) -> None: | ||
| super().__init__(__name__, __version__, __package__, logger) | ||
|
|
||
|
|
||
| Plugin.register_plugin(GnaniPlugin()) | ||
|
|
||
| # Cleanup docs of unexported modules | ||
| _module = dir() | ||
| NOT_IN_ALL = [m for m in _module if m not in __all__] | ||
|
|
||
| __pdoc__ = {} | ||
|
|
||
| for n in NOT_IN_ALL: | ||
| __pdoc__[n] = False |
17 changes: 17 additions & 0 deletions
17
livekit-plugins/livekit-plugins-gnani/livekit/plugins/gnani/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,17 @@ | ||
| # Copyright 2025 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. | ||
|
|
||
| import logging | ||
|
|
||
| logger = logging.getLogger("livekit.plugins.gnani") |
29 changes: 29 additions & 0 deletions
29
livekit-plugins/livekit-plugins-gnani/livekit/plugins/gnani/models.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,29 @@ | ||
| # Copyright 2025 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. | ||
|
|
||
| from typing import Literal | ||
|
|
||
| GnaniLanguages = Literal[ | ||
| "en-IN", # English (India) | ||
| "hi-IN", # Hindi | ||
| "gu-IN", # Gujarati | ||
| "ta-IN", # Tamil | ||
| "kn-IN", # Kannada | ||
| "te-IN", # Telugu | ||
| "mr-IN", # Marathi | ||
| "bn-IN", # Bengali | ||
| "ml-IN", # Malayalam | ||
| "pa-IN", # Punjabi | ||
| "en-IN,hi-IN", # English-Hindi (code-switching) | ||
| ] |
1 change: 1 addition & 0 deletions
1
livekit-plugins/livekit-plugins-gnani/livekit/plugins/gnani/py.typed
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 @@ | ||
| # Marker file for PEP 561 |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: livekit/agents
Length of output: 2358
🏁 Script executed:
Repository: livekit/agents
Length of output: 3735
🏁 Script executed:
Repository: livekit/agents
Length of output: 2433
Change
livekit.plugins.inyaaitolivekit.plugins.gnani.The plugin module is
livekit.plugins.gnani(from the livekit-plugins-gnani package), notlivekit.plugins.inyaai. This reference will cause mypy to fail. Note thattests/test_plugin_inyaai_stt.pyalso has the incorrect import path and will need to be updated.🤖 Prompt for AI Agents