Hume API Examples

repository·main·Indexed 42 days ago

https://github.com/humeai/hume-api-examples

A collection of official sample projects and quickstart guides for integrating Hume's Empathic Voice Interface (EVI) and Text-to-Speech (TTS) APIs. Includes implementations for .NET 8.0, Flutter (iOS, Android, Web), and Next.js (App Router and Pages Router), demonstrating WebSocket connections, audio streaming, function calling, and session management.

Tokens
59K
Snippets
186
Records
252
Agent score
54%

What's inside Hume

  1. Overview of the Custom Language Model SSE Client

    main
    The evi-python-clm-sse package is a Python client library for handling Server-Sent Events (SSE) with Hume Custom Language Models (CLM). It is specifically built to interface with OpenAI-compatible APIs, allowing you to use your own language model to power custom responses within the Empathic Voice Interface (EVI).
  2. Overview of Hume OCTAVE TTS API

    main

    Hume's OCTAVE TTS is a speech-language model designed for high expressiveness. Unlike conventional Text-to-Speech (TTS) systems that simply read text, OCTAVE understands semantic context.

    Key Capabilities:

    • Contextual Understanding: It understands the meaning of words to influence delivery.
    • Character Acting: It can act out specific characters.
    • Prompt-based Voices: It can generate voices based on descriptive prompts.
    • Instructional Control: It accepts instructions to modify the emotion and style of a specific utterance.
  3. Overview of EVI Chat History features

    main

    This project uses the Hume TypeScript SDK to interact with the Empathic Voice Interface (EVI). It performs the following tasks:

    • Retrieve Chat Events: Fetches all events associated with a specific CHAT_ID.
    • Transcript Generation: Parses user and assistant messages to create a human-readable .txt file (named transcript_<CHAT_ID>.txt) containing messages and timestamps.
    • Emotion Analysis: Computes the top three average emotion scores from user messages. It returns these as a Partial<EmotionScores> object, logging the highest-scoring emotions to the console.
  4. Implement Hume Expressive TTS with Vercel AI SDK and Next.js

    main

    This implementation demonstrates how to integrate Hume's Expressive Text-to-Speech (TTS) into a Next.js application using the Vercel AI SDK.

    Key Architectural Patterns:

    • Secure API Invocation: Uses Next.js Server Actions to call Hume's TTS API. This ensures the HUME_API_KEY is kept on the server and never exposed to the client-side browser.
    • Voice Discovery: Uses the Hume TypeScript SDK to fetch available voices from the Hume Voice Library to dynamically populate the UI.
    • Expressive Synthesis: The UI allows users to provide both text and acting instructions to guide the emotional expressiveness of the generated speech.
    • Audio Management: Generated clips are rendered in a gallery using native HTML audio players for playback and downloading.
  5. Features of the Hume OCTAVE TTS API

    main

    The OCTAVE TTS API is a speech-language model that understands context to generate expressive speech. Key capabilities demonstrated in the C# quickstart include:

    • Voice Generation: Creating new voices based on text descriptions.
    • Voice Library: Saving and reusing custom voices.
    • Context Continuation: Maintaining speech consistency across different utterances.
    • Acting Instructions: Modulating the emotion and style of speech through instructions.
    • Streaming: Generating audio in real-time for low-latency applications.
  6. Explore EVI Prompting Examples

    main
    This repository contains example prompts for Hume's Empathic Voice Interface (EVI). These examples are designed to illustrate the core principles of EVI prompting, such as role definition, communication style, response formatting, expression handling, tool use, and optimizing for voice-only conversations. Use these as templates to tailor your own prompts for specific use cases and audiences.
  7. EVI C# Features Demonstrated

    main

    The EVI C# quickstart implementation demonstrates the following core capabilities of the Empathic Voice Interface:

    • WebSocket Connection: Establishing a real-time connection to EVI.
    • Audio Streaming: Sending audio data in chunks for processing.
    • Event Handling: Subscribing to assistant messages, user transcriptions, and audio output.
    • Session Management: Configuring audio settings and managing chat metadata.
  8. Get started with Hume API Examples

    main

    The hume-api-examples repository provides open-source sample code and quickstart guides to help you integrate Hume APIs into your applications. You can use these examples to implement:

    • Empathic Text-to-Speech (TTS): Add empathic voice synthesis to your apps.
    • Empathic Voice Interface (EVI): Build rich, conversational agents.

    To begin, you will need to retrieve your API keys from the Hume AI platform.

  9. Compatibility and Architecture Notes for EVI React Native

    main
    • Expo Version: This example uses Expo 52, where "The New Architecture" is enabled by default. If using an older version of Expo, you may need to adapt the native module implementation to ensure compatibility.
    • Native Modules: The project relies on custom native code located in modules/audio to provide the necessary audio capabilities for EVI that standard Expo modules lack.
  10. How EVI Webhook events are handled

    main

    The TypeScript webhook example uses an Express server listening on the /hume-webhook endpoint. It processes three primary event types:

    • chat_started: Used to log session details or trigger initial workflows.
    • chat_ended: Used to process chat data for generating transcripts or performing analytics.
    • tool_call: Used to execute server-side logic for tools requested by the EVI (e.g., completing a weather lookup).