Empathic Voice Interface (EVI)Quickstart

EVI Python Quickstart Guide

A quickstart guide for implementing the Empathic Voice Interface (EVI) using Python.

This is a simplified example of streaming a session with EVI using your device’s microphone. To see this code fully implemented with complete instructions, visit the GitHub repository: evi-python-example

Python versions 3.9, 3.10, and 3.11 are supported. To use the basic functionality of HumeVoiceClient, HumeBatchClient or HumeStreamClient, there are no additional system dependencies. However, using the audio playback functionality of the EVI MicrophoneInterface may require a few extra dependencies depending on your operating system.

The Python SDK is currently supported on Mac and Linux, and not yet on Windows.

We recommend using a virtual environment like venv in Python to manage project-specific dependencies without affecting the global Python installation. This helps avoid version conflicts between packages and makes it easier to replicate and troubleshoot projects across different systems. See the section “Setting up a virtual environment” in the repository.

To use microphone functionality in the MicrophoneInterface as shown below, run:

$pip install "hume[microphone]"

For audio playback, install dependencies with the following commands:

1brew update
2brew upgrade
3brew install ffmpeg

Let’s walk through the steps, or you can jump down to the complete code snippet under “Putting it all together.”

In the sample code below, the Hume API key is hard-coded; this is to make this guide as simple as possible. In practice, do not hard code these values in your project to prevent them from being leaked. See the section “Authenticate and Connect” in the repository for instructions on using environment variables to prevent accidental exposure of your credentials.

Import libraries

First we import the required Hume libraries and asyncio for asynchronous functions calls.

1import asyncio
2from hume import HumeVoiceClient, MicrophoneInterface

Authenticate and Connect

The Python SDK uses a Hume API key to authenticate. These keys can be obtained by logging into the portal and visiting the API keys page. Replace the placeholder “HUME_API_KEY” with your Hume API key.

1async def main() -> None:
2 # Paste your Hume API key here.
4 # Connect and authenticate with Hume
5 client = HumeVoiceClient(HUME_API_KEY)
7 # Start streaming EVI over your device's microphone and speakers
8 async with client.connect() as socket:
9 await MicrophoneInterface.start(socket)

Optional: Specify device

You can specify your microphone device using the device parameter. See Optional: Specify device in the repository for details on how to list your audio devices and manually set one for EVI.


Initialize, execute, and manage the lifecycle of the event loop in the asyncio-based application, making sure that the main() coroutine runs effectively and that the application shuts down cleanly after the coroutine finishes executing.


Putting it all together

Here is the complete code from the steps above to run this example. Keep in mind that in practice you should use an environment variable to store the Hume API key, as is done in the evi-python-example repository.

1import asyncio
2from hume import HumeVoiceClient, MicrophoneInterface
4async def main() -> None:
5 # Paste your Hume API key here
7 # Connect and authenticate with Hume
8 client = HumeVoiceClient(HUME_API_KEY)
10 # Start streaming EVI over your device's microphone and speakers
11 async with client.connect() as socket:
12 await MicrophoneInterface.start(socket)