Tool

Generate Speech from Text with ElevenLabs

LlamaIndex tool that integrates Elevenlabs.io text-to-speech API to let AI agents generate audio files from text strings with voice selection.

Works with elevenlabsopenai

75
Spark score
out of 100
Updated 3 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Leverage ElevenLabs' advanced text-to-speech capabilities to automatically generate high-quality audio files from written content. This asset enables seamless integration into agent workflows for dynamic speech synthesis.

Outcomes

What it gets done

01

Synthesize audio from input text using ElevenLabs.

02

List available ElevenLabs voices.

03

Integrate text-to-speech functionality into agent workflows.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-tool-tools-elevenlabs | bash

Overview

Elevenlabs.io Tool

The Elevenlabs.io Tool is a LlamaIndex integration that connects AI agents to the Elevenlabs.io text-to-speech API. It provides two functions: text_to_speech takes an input string and synthesizes audio to play on the users computer, and get_voices retrieves available voice models as Pydantic objects. The tool is designed to be used as a way to load data as a Tool in a Agent. Use this tool when you want to integrate Elevenlabs.io text-to-speech capabilities into LlamaIndex agents. Consult the Elevenlabs.io documentation and your specific requirements to determine if this integration approach fits your needs.

What it does

The Elevenlabs.io Tool enables LlamaIndex agents to convert text into speech audio files using the Elevenlabs.io text-to-speech API. It provides two core functions: synthesizing audio from input strings and retrieving available voice models.

When to use - and when NOT to

Use this tool when you want to integrate Elevenlabs.io text-to-speech capabilities into LlamaIndex agents.

Consult the Elevenlabs.io documentation and your specific requirements to determine if this integration approach fits your needs.

Inputs and outputs

Users provide an Elevenlabs.io API key during initialization and text strings for conversion. The text_to_speech function takes an input string and synthesizes audio to play on the users computer. The get_voices function returns Pydantic models listing all available Elevenlabs.io voices.

Integrations

This tool integrates with LlamaIndex's FunctionAgent and agent workflow system, allowing it to be loaded as part of an agent's tool list. It works alongside LlamaIndex LLMs such as OpenAI models (e.g., gpt-4.1). The tool is designed to be used as a way to load data as a Tool in a Agent.

from llama_index.tools.elevenlabs import ElevenLabsToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

speech_tool = ElevenLabsToolSpec(api_key="your-key")

agent = FunctionAgent(
    tools=speech_tool.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)
print(
    await agent.run(
        'Create speech from the following text "Hello world!" and output the file to "speech.wav"'
    )
)

Who it's for

This tool is for developers working with LlamaIndex agents who want to add Elevenlabs.io text-to-speech functionality. It abstracts Elevenlabs.io API complexity into agent-compatible functions for developers familiar with LlamaIndex's agent framework.

Source README

Elevenlabs.io Tool

This tool allows Agents to use Elevenlabs.io text-to-speech to create audio files from text. To see more and get started, visit https://elevenlabs.io/

Usage

This tool has a more extensive example usage documented in a Jupyter notebook here

from llama_index.tools.elevenlabs import ElevenLabsToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

speech_tool = ElevenLabsToolSpec(api_key="your-key")

agent = FunctionAgent(
    tools=speech_tool.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)
print(
    await agent.run(
        'Create speech from the following text "Hello world!" and output the file to "speech.wav"'
    )
)

text_to_speech: Takes an input string and synthesizes audio to play on the users computer
get_voices: Lists the dumped Pydantic models for all available elevenlabs.io voices

This loader is designed to be used as a way to load data as a Tool in a Agent.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.