Real-time measurement streaming
WebSocket-based streaming facilitates continuous data flow between your application and Hume’s models, providing immediate feedback and insights.
Key features
- Real-time data processing: Leveraging WebSockets, this API allows for the streaming of data to Hume’s models, enabling instant analysis and response. This feature is particularly beneficial for applications requiring immediate processing, such as live interaction systems or real-time monitoring tools.
- Persistent, two-way communication: Unlike traditional request-response models, the WebSocket-based streaming maintains an open connection for two-way communication between the client and server. This facilitates an ongoing exchange of data, allowing for a more interactive and responsive user experience.
- High throughput and low latency: The API is optimized for high performance, supporting high-volume data streaming with minimal delay. This ensures that applications can handle large streams of data efficiently, without sacrificing speed or responsiveness.
Applications and use cases
WebSockets are ideal for a wide range of applications that benefit from real-time data analysis and interaction. Examples include:
- Live customer service tools: enhance customer support with real-time sentiment analysis and automated, emotionally intelligent responses
- Interactive educational platforms: provide immediate feedback and adaptive learning experiences based on real-time student input
- Health and wellness apps: support live mental health and wellness monitoring, offering instant therapeutic feedback or alerts based on the user’s vocal or textual expressions
- Entertainment and gaming: create more immersive and interactive experiences by responding to user inputs and emotions in real time
Getting started with WebSocket streaming
Integrating WebSocket-based streaming into your application involves establishing a WebSocket connection with Hume AI’s servers and streaming data directly to the models for processing.
Streaming is built for analysis of audio, video, and text streams. By connecting to WebSocket endpoints you can get near real-time feedback on the expressive and emotional content of your data.
Install the Hume Python SDK
First, ensure you have installed the SDK using pip
or another package manager.
Emotional language from text
This example uses our Emotional Language model to perform sentiment analysis on a children’s nursery rhyme.
If you haven’t already, grab your API key.
Your result should look something like this:
Facial expressions from an image
This example uses our Facial Expression model to get expression measurements from an image.
Speech prosody from an audio or video file
This example uses our Speech Prosody model to get expression measurements from an audio or video file.
Streaming with your own WebSockets client
To call the API from your own WebSockets client you’ll need the API endpoint, a JSON message, and an API key header/param. More information can be found in the Expression Measurement API reference.
To get started, you can use a WebSocket client of your choice to connect to the models endpoint:
Make sure you configure the socket connection headers with your personal API key
The default WebSockets implementation in your browser may not have support for headers. If that’s the case you can set the apiKey query parameter.
And finally, send the following JSON message on the socket:
You should receive a JSON response that looks something like this:
Sending images or audio
The WebSocket endpoints of the Expression Measurement API require that you encode your media using base64. Here’s a quick example of base64 encoding data in Python:
API limits
- WebSocket duration limit: connections are subject to a default timeout after one (1) minute of inactivity to ensure unused connections are released.
- WebSocket message payload size limit: the size limit for a given payload depends on the type of content being transmitted and its dimensions.
- Video: 5000 milliseconds (5 seconds)
- Audio: 5000 milliseconds (5 seconds)
- Image: 3,000 x 3,000 pixels
- Text: 10,000 characters
- Request rate limit: HTTP requests (e.g. WebSocket handshake endpoint) are limited to fifty (50) requests per second.