SDKs overview

Hume AI offers Software Development Kits (SDKs) to facilitate the integration of its Empathic Voice Interface (EVI) and Expression Measurement API into various software applications. These SDKs are designed to abstract the underlying API calls, allowing developers to interact with Hume AI's emotion AI capabilities using native language constructs. The primary official SDKs are available for Python and JavaScript, catering to common development environments for AI and web-based applications.

The SDKs streamline tasks such as authenticating with the Hume AI platform, sending audio or video data for analysis, and receiving structured responses containing emotion predictions and expression measurements. By providing pre-built functionalities, the SDKs aim to reduce development time and complexity when working with Hume AI's models for understanding emotional nuance in voice and analyzing facial and vocal expressions, which is useful for building emotionally intelligent AI assistants or improving customer service interactions.

Official SDKs by language

Hume AI provides official SDKs for Python and JavaScript, which are maintained directly by the Hume AI development team. These SDKs are the recommended method for integrating Hume AI's services into applications built with these languages. The table below outlines the key details for each official SDK.

Language Package Name Install Command Maturity
Python hume-ai pip install hume-ai Stable
JavaScript @humeai/hume npm install @humeai/hume or yarn add @humeai/hume Stable

Each SDK is designed to interact with specific Hume AI core products, including the Empathic Voice Interface (EVI) and the Expression Measurement API. Developers can find detailed usage guides and API references within the Hume AI documentation portal to understand the full capabilities and integration patterns for each language.

Installation

Python SDK

To install the Hume AI Python SDK, use pip, the standard package installer for Python. It is recommended to install the SDK within a virtual environment to manage dependencies.

pip install hume-ai

After installation, you will need to set up authentication by providing your Hume AI API key. This is typically done by setting an environment variable named HUME_API_KEY or by passing the key directly during client initialization, as detailed in the Hume AI Python quickstart guide.

JavaScript SDK

For JavaScript projects, the Hume AI SDK can be installed using npm or Yarn, the package managers for Node.js environments.

Using npm:

npm install @humeai/hume

Using Yarn:

yarn add @humeai/hume

Similar to the Python SDK, authentication for the JavaScript SDK involves providing your API key. This can be done through environment variables or by passing the key directly when creating an API client instance. Consult the Hume AI browser quickstart documentation for specific implementation examples.

Quickstart example

This example demonstrates how to use the Hume AI Python SDK to connect to the Expression Measurement API and process a simple text input. This requires a valid API key configured as an environment variable (HUME_API_KEY).

First, ensure you have installed the Python SDK:

pip install hume-ai

Then, create a Python file (e.g., hume_example.py) with the following content:

import os
from hume import HumeBatchClient
from hume.models.config import FaceConfig

# Ensure your Hume API key is set as an environment variable
# export HUME_API_KEY="YOUR_API_KEY"

def analyze_face_emotions(file_path: str):
    try:
        client = HumeBatchClient(os.getenv("HUME_API_KEY"))
        configs = [FaceConfig()]
        
        job = client.submit_job(files=[file_path], configs=configs)
        print(f"Submitted job with ID: {job.id}")
        print("Waiting for job to complete...")
        
        job.await_complete()
        
        if job.get_error() is None:
            results = job.get_predictions()
            if results and results[0].results.face: # Accessing face-specific results
                # Process and print some high-level emotion predictions
                for prediction in results[0].results.face.predictions:
                    print(f"Segment: {prediction.file_name}")
                    for emotion in prediction.emotions[:3]: # Top 3 emotions
                        print(f"  {emotion.name}: {emotion.score:.4f}")
            else:
                print("No face predictions found.")
        else:
            print(f"Job failed with error: {job.get_error()}")

    except Exception as e:
        print(f"An error occurred: {e}")

if __name__ == "__main__":
    # Replace 'path/to/your/image.jpg' with a valid image file path
    # or 'path/to/your/video.mp4' for video analysis
    sample_file_path = "path/to/your/image.jpg" 
    # For this example, you would need an actual image file.
    # For testing without a file, you might adapt for simple text analysis if available,
    # but FaceConfig specifically requires visual input.
    
    # Example placeholder if using a text model (not FaceConfig):
    # from hume.models.config import LanguageConfig
    # configs = [LanguageConfig()]
    # job = client.submit_job(text=["I am feeling great today."], configs=configs)
    # ... (rest of the logic for language analysis)
    
    print("This quickstart requires an image or video file for face analysis.")
    print(f"Please replace '{sample_file_path}' with a real file path and ensure HUME_API_KEY is set.")
    # To run, ensure you have an image file, e.g., 'sample.jpg' and replace the path above.
    # Example: analyze_face_emotions("sample.jpg")

This snippet initializes a HumeBatchClient, configures it for face analysis, submits a job with a file, waits for completion, and then prints the top emotion predictions. For further details on specific configurations and output structures, refer to the Hume AI API Reference.

Developers working with Empathic Voice Interface (EVI) would use different client methods, such as HumeClient.v0.evi, and handle real-time audio streams, often using WebSocket connections, as described in the dedicated Hume AI EVI documentation.

Community libraries

As of late 2024, Hume AI primarily focuses on its official Python and JavaScript SDKs. The ecosystem for community-contributed libraries and wrappers is still developing. While there isn't a broad collection of officially recognized third-party SDKs in other languages or specialized integrations, developers can still interact with Hume AI's underlying REST and WebSocket APIs directly using standard HTTP client libraries available in most programming languages.

For languages without an official SDK, developers can consult the MDN Web Docs on HTTP for general guidance on making API requests. This approach involves constructing HTTP requests, handling JSON responses, and managing authentication manually. As the Hume AI platform matures, the community may develop and share libraries, but users should verify the maintenance status and reliability of any unofficial implementations.

Hume AI's emphasis remains on providing robust official support, encouraging developers to utilize the Python and JavaScript SDKs for the most stable and feature-rich integration experience, while also offering comprehensive API documentation for direct integration pathways.