This project showcases how to call functions in a sample implementation of Hume's Empathic Voice Interface using Hume's Python SDK. Here, we have a simple EVI that calls a function to get the current weather for a given location.
The Hume Python SDK supports Python versions 3.9, 3.10, and 3.11 on macOS and Linux systems.
You can create a virtual environment using either conda
from Miniconda or Anaconda, or the built-in venv
module in Python. Instructions for both methods are provided below.
- Install
conda
using Miniconda, the free minimal installer for it. - Create a new virtual environment:
conda create --name evi-env python=3.11
- Activate the virtual environment:
conda activate evi-env
To create a virtual environment with venv
, run the following commands in your terminal:
- Create a new virtual environment:
python -m venv evi-env
- Activate the virtual environment:
source evi-env/bin/activate
Follow these steps to install the required packages and system dependencies for using environment variables, EVI, and handling audio input/output.
Install the python-dotenv
package to load variables from a .env
file:
pip install python-dotenv
Install the Hume Python SDK with microphone support:
pip install "hume[microphone]"
For audio playback and processing, additional system-level dependencies are required:
Install ffmpeg
using Homebrew:
brew install ffmpeg
Install the required packages:
sudo apt-get --yes update
sudo apt-get --yes install libasound2-dev libportaudio2 ffmpeg
Not yet supported.
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.
- Create a
.env
file in the root folder of the repo and add your API Key and Secret Key:
HUME_API_KEY=<YOUR API KEY>
HUME_SECRET_KEY=<YOUR SECRET KEY>
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": "2",
"name": "Weather Assistant Config",
"voice": {
"provider": "HUME_AI",
"name": "ITO"
},
"language_model": {
"model_provider": "ANTHROPIC",
"model_resource": "claude-3-5-sonnet-20240620",
"temperature": 1
},
"tools": [
{
"id": "<YOUR_TOOL_ID>"
}
]
}'
- Add the Config ID to your environmental variables in your
.env
file:
HUME_CONFIG_ID=<YOUR CONFIG ID>
- Add your Geocoding API key to your environmental variables (free to use from geocode.maps.co):
GEOCODING_API_KEY=<YOUR GEOCODING API KEY>
This implementation of Hume's Empathic User Interface (EVI) is minimal, using default configurations for the interface and a basic terminal application to authenticate, connect to, and disconnect from the interface.
To run the project:
- Ensure you have set up your virtual environment and installed all required dependencies.
- Execute the script by running
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.
- The 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+C
when 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."