This project showcases how to call functions in a sample implementation of Hume's Empathic Voice Interface (EVI) using Hume's Python SDK. Here, we have a simple EVI that calls a function to get the current weather for a given location.
See the Tool Use guide for a detailed explanation of the code in this project.
The Hume Python SDK supports Python versions 3.9, 3.10, and 3.11 on macOS and Linux systems.
It does not currently support Windows.
-
Clone this examples repository:
git clone https://github.com/humeai/hume-api-examples cd hume-api-examples/evi/evi-python-function-calling -
Set up a virtual environment (Optional):
It's recommended to isolate dependencies in a virtual environment. Choose one of the following methods:
-
Using
conda(requires Miniconda or Anaconda):conda create --name evi-env python=3.11 conda activate evi-env
-
Using built-in
venv(available with Python 3.3+):python -m venv evi-env source evi-env/bin/activate
After activating the environment, proceed with installing dependencies.
-
-
Set up environment variables:
This project uses
python-dotenvto load your API credentials securely from a.envfile.-
Install the package:
pip install python-dotenv
-
Copy the
.env.examplefile to use as a template:cp .env.example .env
-
Place your API keys inside:
- Visit the API keys page on the Hume Platform to retrieve your API keys. See our documentation on getting your api keys.
- Upon doing so, the
.envfile becomes a persistent local store of your API key, Secret key, and EVI config ID. The.gitignorefile contains local env file paths so that they are not committed to GitHub.
-
-
Install dependencies:
Install the Hume Python SDK with microphone support:
pip install "hume[microphone]"For audio playback and processing, additional system-level dependencies are required. Below are download instructions for each supported operating system:
To ensure audio playback functionality, you will need to install
ffmpeg, a powerful multimedia framework that handles audio and video processing.One of the most common ways to install
ffmpegon macOS is by using Homebrew. Homebrew is a popular package manager for macOS that simplifies the installation of software by automating the process of downloading, compiling, and setting up packages.To install
ffmpegusing Homebrew, follow these steps:-
Install Homebrew onto your system according to the instructions on the Homebrew website.
-
Once Homebrew is installed, you can install
ffmpegwith:brew install ffmpeg
If you prefer not to use Homebrew, you can download a pre-built
ffmpegbinary directly from the FFmpeg website or use other package managers like MacPorts.On Linux systems, you will need to install a few additional packages to support audio input/output and playback:
libasound2-dev: This package contains development files for the ALSA (Advanced Linux Sound Architecture) sound system.libportaudio2: PortAudio is a cross-platform audio I/O library that is essential for handling audio streams.ffmpeg: Required for processing audio and video files.
To install these dependencies, use the following commands:
sudo apt-get --yes update sudo apt-get --yes install libasound2-dev libportaudio2 ffmpeg
Not yet supported.
-
-
Set up EVI configuration
Before running this project, you'll need to set up EVI with the ability to leverage tools or call functions. Follow these steps for authentication, creating a Tool, and adding it to a configuration.
See our documentation on Setup for Tool Use for no-code and full-code guides on creating a tool and adding it to a configuration.
-
Create a tool with the following payload:
curl -X POST https://api.hume.ai/v0/evi/tools \ -H "X-Hume-Api-Key: <YOUR_HUME_API_KEY>" \ -H "Content-Type: application/json" \ -d '{ "name": "get_current_weather", "parameters": "{ \"type\": \"object\", \"properties\": { \"location\": { \"type\": \"string\", \"description\": \"The city and state, e.g. San Francisco, CA\" }, \"format\": { \"type\": \"string\", \"enum\": [\"celsius\", \"fahrenheit\"], \"description\": \"The temperature unit to use. Infer this from the users location.\" } }, \"required\": [\"location\", \"format\"] }", "version_description": "Fetches current weather and uses celsius or fahrenheit based on location of user.", "description": "This tool is for getting the current weather.", "fallback_content": "Unable to fetch current weather." }'This will yield a Tool ID, which you can assign to a new EVI configuration.
-
Create a configuration equipped with that tool:
curl -X POST https://api.hume.ai/v0/evi/configs \ -H "X-Hume-Api-Key: <YOUR_HUME_API_KEY>" \ -H "Content-Type: application/json" \ -d '{ "evi_version": "3", "name": "Weather Assistant Config", "voice": { "provider": "HUME_AI", "name": "ITO" }, "language_model": { "model_provider": "ANTHROPIC", "model_resource": "claude-haiku-4-5-20251001", "temperature": 1 }, "tools": [ { "id": "<YOUR_TOOL_ID>" } ] }' -
Add the Config ID to your environmental variables in your
.envfile:HUME_CONFIG_ID=<YOUR CONFIG ID>
-
-
Add the Geocoding API key to the
.envfile. You can obtain it for free from geocode.maps.co.GEOCODING_API_KEY=<YOUR GEOCODING API KEY>
-
Run the project:
python main.py
- Once the script is running, you can begin speaking with the interface. The transcript of the conversation will be displayed in the terminal in real-time.
- EVI is equipped with a tool to fetch weather information. You can ask about the weather in different locations, and the EVI will use the tool to provide current weather data.
- Terminate the script by pressing
Ctrl+Cwhen you're finished.
Here's an example of how you might interact with the EVI to get weather information:
User: "What's the weather like in New York City?"
EVI: (Uses the get_current_weather tool to fetch data) "Currently in New York City, it's 72°F (22°C) and partly cloudy. The forecast calls for a high of 78°F (26°C) and a low of 65°F (18°C) today."
