Skip to content

Latest commit

 

History

History
88 lines (59 loc) · 2.73 KB

File metadata and controls

88 lines (59 loc) · 2.73 KB

Empathic Voice Interface | Python Chat History

Fetch Chat Events, Generate a Transcript, and Identify Top Emotions

Overview

This project demonstrates how to:

  • Retrieve all chat events for a specified Chat ID from Hume's Empathic Voice Interface (EVI) using the Python SDK.
  • Parse user and assistant messages to produce a formatted chat transcript.
  • Compute the top three average emotion scores from user messages.

Key Features:

  • Transcript generation: Outputs a human-readable .txt file capturing the conversation between user and assistant.
  • Top 3 emotions: Identifies the three emotions with the highest average scores across all user messages.

Instructions

  1. Clone this examples repository:

    git clone https://github.com/humeai/hume-api-examples
    cd hume-api-examples/evi/evi-python-chat-history
  2. Verify Poetry is installed (version 1.7.1 or higher):

    Check your version:

    poetry --version

    If you need to update or install Poetry, follow the instructions on the official Poetry website.

  3. Set up your API key:

    You must authenticate to use the EVI API. Your API key can be retrieved from the Hume AI platform. For detailed instructions, see our documentation on getting your api keys.

    Place your API key in a .env file at the root of your project.

    echo "HUME_API_KEY=your_api_key_here" > .env

    You can copy the .env.example file to use as a template.

  4. Specify the Chat ID:

    In the main function within main.py, set the CHAT_ID variable to the target conversation ID:

    async def main():
        # Replace with your actual Chat ID
        CHAT_ID = "<YOUR_CHAT_ID>"
        # ...

    This determines which Chat's events to fetch and process.

  5. Install dependencies:

    poetry install
  6. Run the project:

    poetry run python main.py

    What happens when run:

    • The script fetches all events for the specified CHAT_ID.
    • It generates a transcript_<CHAT_ID>.txt file containing the user and assistant messages with timestamps.
    • It logs the top 3 average emotions to the console:
    Top 3 Emotions: {'Joy': 0.7419108072916666, 'Interest': 0.63111979166666666, 'Amusement': 0.63061116536458334}

    (These keys and scores are just examples; the actual output depends on the Chat's content.)