-
Notifications
You must be signed in to change notification settings - Fork 6.5k
ElevenLabs integration #18967
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
ElevenLabs integration #18967
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| llama_index/_static | ||
| .DS_Store | ||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
|
|
||
| # C extensions | ||
| *.so | ||
|
|
||
| # Distribution / packaging | ||
| .Python | ||
| bin/ | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| etc/ | ||
| include/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| share/ | ||
| var/ | ||
| wheels/ | ||
| pip-wheel-metadata/ | ||
| share/python-wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
| MANIFEST | ||
|
|
||
| # PyInstaller | ||
| # Usually these files are written by a python script from a template | ||
| # before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
| *.manifest | ||
| *.spec | ||
|
|
||
| # Installer logs | ||
| pip-log.txt | ||
| pip-delete-this-directory.txt | ||
|
|
||
| # Unit test / coverage reports | ||
| htmlcov/ | ||
| .tox/ | ||
| .nox/ | ||
| .coverage | ||
| .coverage.* | ||
| .cache | ||
| nosetests.xml | ||
| coverage.xml | ||
| *.cover | ||
| *.py,cover | ||
| .hypothesis/ | ||
| .pytest_cache/ | ||
| .ruff_cache | ||
|
|
||
| # Translations | ||
| *.mo | ||
| *.pot | ||
|
|
||
| # Django stuff: | ||
| *.log | ||
| local_settings.py | ||
| db.sqlite3 | ||
| db.sqlite3-journal | ||
|
|
||
| # Flask stuff: | ||
| instance/ | ||
| .webassets-cache | ||
|
|
||
| # Scrapy stuff: | ||
| .scrapy | ||
|
|
||
| # Sphinx documentation | ||
| docs/_build/ | ||
|
|
||
| # PyBuilder | ||
| target/ | ||
|
|
||
| # Jupyter Notebook | ||
| .ipynb_checkpoints | ||
| notebooks/ | ||
|
|
||
| # IPython | ||
| profile_default/ | ||
| ipython_config.py | ||
|
|
||
| # pyenv | ||
| .python-version | ||
|
|
||
| # pipenv | ||
| # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
| # However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
| # having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
| # install all needed dependencies. | ||
| #Pipfile.lock | ||
|
|
||
| # PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
| __pypackages__/ | ||
|
|
||
| # Celery stuff | ||
| celerybeat-schedule | ||
| celerybeat.pid | ||
|
|
||
| # SageMath parsed files | ||
| *.sage.py | ||
|
|
||
| # Environments | ||
| .env | ||
| .venv | ||
| env/ | ||
| venv/ | ||
| ENV/ | ||
| env.bak/ | ||
| venv.bak/ | ||
| pyvenv.cfg | ||
|
|
||
| # Spyder project settings | ||
| .spyderproject | ||
| .spyproject | ||
|
|
||
| # Rope project settings | ||
| .ropeproject | ||
|
|
||
| # mkdocs documentation | ||
| /site | ||
|
|
||
| # mypy | ||
| .mypy_cache/ | ||
| .dmypy.json | ||
| dmypy.json | ||
|
|
||
| # Pyre type checker | ||
| .pyre/ | ||
|
|
||
| # Jetbrains | ||
| .idea | ||
| modules/ | ||
| *.swp | ||
|
|
||
| # VsCode | ||
| .vscode | ||
|
|
||
| # pipenv | ||
| Pipfile | ||
| Pipfile.lock | ||
|
|
||
| # pyright | ||
| pyrightconfig.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| The MIT License | ||
|
|
||
| Copyright (c) Jerry Liu | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| GIT_ROOT ?= $(shell git rev-parse --show-toplevel) | ||
|
|
||
| help: ## Show all Makefile targets. | ||
| @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
|
||
| format: ## Run code autoformatters (black). | ||
| pre-commit install | ||
| git ls-files | xargs pre-commit run black --files | ||
|
|
||
| lint: ## Run linters: pre-commit (black, ruff, codespell) and mypy | ||
| pre-commit install && git ls-files | xargs pre-commit run --show-diff-on-failure --files | ||
|
|
||
| test: ## Run tests via pytest. | ||
| pytest tests | ||
|
|
||
| watch-docs: ## Build and watch documentation. | ||
| sphinx-autobuild docs/ docs/_build/html --open-browser --watch $(GIT_ROOT)/llama_index/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # LlamaIndex x ElevenLabs integration | ||
|
|
||
| This package is an integration for ElevenLabs realtime conversation with agents. | ||
|
|
||
| To install the package, run: | ||
|
|
||
| ```bash | ||
| python3 -m pip install llama-index-voice-elevenlabs | ||
| ``` | ||
|
|
||
| And, if you want to run it, you can refer to the simple example down here (in this case, the audio input/output are the same as the local device you are running the script on): | ||
|
|
||
| ```python | ||
| import os | ||
| import signal | ||
|
|
||
| from base import ElevenLabsConversation | ||
| from dotenv import load_dotenv | ||
| from elevenlabs.client import ElevenLabs | ||
| from elevenlabs.conversational_ai.default_audio_interface import ( | ||
| DefaultAudioInterface, | ||
| ) | ||
|
|
||
|
|
||
| load_dotenv() | ||
| AGENT_ID = os.environ.get("AGENT_ID") | ||
| API_KEY = os.environ.get("ELEVENLABS_API_KEY") | ||
|
|
||
| if __name__ == "__main__": | ||
| client = ElevenLabs(api_key=API_KEY) | ||
| conversation = ElevenLabsConversation( | ||
| client, | ||
| AGENT_ID, | ||
| requires_auth=bool(API_KEY), | ||
| audio_interface=DefaultAudioInterface(), | ||
| ) | ||
| conversation.start_session() | ||
|
|
||
| # RUN UNTIL CTRL+C IS HIT | ||
| signal.signal(signal.SIGINT, lambda sig, frame: conversation.end_session()) | ||
|
||
| # GET MESSAGES IN llama-index ChatMessage FORMAT | ||
| messages = conversation.get_messages() | ||
| # GET AVERAGE LATENCY | ||
| latency = conversation.get_average_latency() | ||
| conversation_id = conversation.wait_for_session_end() | ||
| print(f"Messages: {messages}") | ||
| print(f"Latency: {latency}") | ||
| print(f"Conversation ID: {conversation_id}") | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from .base import ElevenLabsConversation | ||
|
|
||
| __all__ = ["ElevenLabsConversation"] |
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.
Just thinking for the future, we might need to design (or use existing) our own audio interface across voice integrations
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.
With the callback functions defined in utils, we already do use AudioBlock :)
I'm planning on scaling the support across the various integrations