EVI Python Quickstart Guide
A quickstart guide for implementing the Empathic Voice Interface (EVI) with 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
The complete specification for the Python SDK can be found on the Python SDK reference page.
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:
For audio playback, install dependencies with the following commands:
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.
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.
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.
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.