dapr-agents/quickstarts/02_llm_call_elevenlabs
Yaron Schneider d993f9090b
update quickstarts dependencies (#166)
Signed-off-by: yaron2 <schneider.yaron@live.com>
2025-07-28 13:52:37 -07:00
..
README.md ElevenLabs Python SDK updates and advanced TTS support (#154) 2025-07-20 19:29:28 -07:00
requirements.txt update quickstarts dependencies (#166) 2025-07-28 13:52:37 -07:00
text_to_speech.py Fix/30 add linter action (#95) 2025-04-23 22:58:48 -07:00

README.md

Elevenlabs LLM calls with Dapr Agents

This quickstart demonstrates how to use Dapr Agents to convert text to speech using the ElevenLabs API. You'll learn how to generate natural-sounding audio from text, configure voices and models, and save the resulting audio to a file in your Python application.

Prerequisites

  • Python 3.10 (recommended)
  • pip package manager
  • Elevenlabs API key

Environment Setup

# Create a virtual environment
python3.10 -m venv .venv

# Activate the virtual environment 
# On Windows:
.venv\Scripts\activate
# On macOS/Linux:
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

Configuration

Create a .env file in the project root:

ELEVENLABS_API_KEY=your_api_key_here

Replace your_api_key_here with your actual Elevenlabs API key.

Examples

Audio

You can use the ElevenLabsSpeechClient in dapr-agents for text to speech capabilities of the Elevenlabs Audio API.

1. Run the text to speech example:

python text_to_speech.py

Key Concepts

  • ElevenLabsSpeechClient: The interface for interacting with Elevenlabs' language models
  • create_speech(): The primary method for text to speech capabilities

Dapr Integration

While these examples don't explicitly use Dapr's distributed capabilities, Dapr Agents provides:

  • Unified API: Consistent interfaces for different LLM providers
  • Type Safety: Structured data extraction and validation
  • Integration Path: Foundation for building more complex, distributed LLM applications

In later quickstarts, you'll see how these LLM interactions integrate with Dapr's building blocks.

Troubleshooting

  1. Authentication Errors: If you encounter authentication failures, check your Elevenlabs API key in the .env file
  2. Structured Output Errors: If the model fails to produce valid structured data, try refining your model or prompt
  3. Module Not Found: Ensure you've activated your virtual environment and installed the requirements

Next Steps

After completing these examples, move on to the Agent Tool Call quickstart to learn how to build agents that can use tools to interact with external systems.