From 0ffaa09c9507f9fd6b75c462b20f33931665fdb0 Mon Sep 17 00:00:00 2001 From: ivaaan Date: Fri, 5 Dec 2025 19:00:47 +0100 Subject: [PATCH] add tracking headers to Hume service --- src/pipecat/services/hume/tts.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pipecat/services/hume/tts.py b/src/pipecat/services/hume/tts.py index a2472c6d3..6b256961e 100644 --- a/src/pipecat/services/hume/tts.py +++ b/src/pipecat/services/hume/tts.py @@ -8,9 +8,11 @@ import base64 import os from typing import Any, AsyncGenerator, Optional +import httpx from loguru import logger from pydantic import BaseModel +from pipecat import __version__ from pipecat.frames.frames import ( ErrorFrame, Frame, @@ -26,11 +28,7 @@ from pipecat.utils.tracing.service_decorators import traced_tts try: from hume import AsyncHumeClient - from hume.tts import ( - FormatPcm, - PostedUtterance, - PostedUtteranceVoiceWithId, - ) + from hume.tts import FormatPcm, PostedUtterance, PostedUtteranceVoiceWithId from hume.tts.types import TimestampMessage except ModuleNotFoundError as e: # pragma: no cover - import-time guidance logger.error(f"Exception: {e}") @@ -40,6 +38,12 @@ except ModuleNotFoundError as e: # pragma: no cover - import-time guidance HUME_SAMPLE_RATE = 48_000 # Hume TTS streams at 48 kHz +# Tracking headers for Hume API requests +DEFAULT_HEADERS = { + "X-Hume-Client-Name": "pipecat", + "X-Hume-Client-Version": __version__, +} + class HumeTTSService(WordTTSService): """Hume Octave Text-to-Speech service. @@ -104,7 +108,11 @@ class HumeTTSService(WordTTSService): **kwargs, ) - self._client = AsyncHumeClient(api_key=api_key) + # Create a custom httpx.AsyncClient with tracking headers + # Headers are included in all requests made by the Hume SDK + custom_http_client = httpx.AsyncClient(headers=DEFAULT_HEADERS) + + self._client = AsyncHumeClient(api_key=api_key, httpx_client=custom_http_client) self._params = params or HumeTTSService.InputParams() # Store voice in the base class (mirrors other services)