Hume AI
The HumeTTSService provides emotion-aware voice generation creating deeply empathetic and expressive agent responses. Leveraging Hume's Octave models, it allows for natural-sounding speech guided by descriptive acting directions.
Installation
To use Hume AI, install the required dependencies:
pip install "piopiy-ai[hume]"
Prerequisites
- A Hume AI account and API key (Get yours here).
- Set your API key in your environment:
export HUME_API_KEY="your_api_key_here"
Configuration
HumeTTSService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your Hume API key. |
voice_id | str | Required | The ID of the voice to use. |
sample_rate | int | 48000 | Audio sample rate (Hume streams at 48kHz). |
params | InputParams | InputParams() | Acting directions and speed settings. |
InputParams
| Parameter | Type | Default | Description |
|---|---|---|---|
description | str | None | Natural-language acting directions. |
speed | float | None | Speaking-rate multiplier (0.5 to 2.0). |
trailing_silence | float | None | Seconds of silence to append at the end. |
Usage
Basic Setup
import os
from piopiy.services.hume.tts import HumeTTSService
tts = HumeTTSService(
api_key=os.getenv("HUME_API_KEY"),
voice_id="default"
)
With Acting Directions
from piopiy.services.hume.tts import HumeTTSService
tts = HumeTTSService(
voice_id="default",
params=HumeTTSService.InputParams(
description="Speak in a warm, comforting, and empathetic tone.",
speed=0.9
)
)
Notes
- Empathic Voice: Hume's TTS is uniquely designed to convey emotional nuance; use the
descriptionparameter to fine-tune the agent's persona. - Word Timestamps: Supports millisecond-precision word-level timestamps for perfect audio-text synchronization.
- Buffering: Piopiy automatically buffers audio chunks from Hume to ensure glitch-free streaming over telephony networks.