Added support for using the HeyGen LiveAvatar API with the HeyGenTransport.

This commit is contained in:
filipi87
2026-01-06 10:16:12 -03:00
parent 5a40054ac2
commit 5412840a93
2 changed files with 7 additions and 7 deletions

View File

@@ -27,7 +27,7 @@ from pipecat.processors.aggregators.llm_response_universal import (
from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.cartesia.tts import CartesiaTTSService
from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.stt import DeepgramSTTService
from pipecat.services.google.llm import GoogleLLMService from pipecat.services.google.llm import GoogleLLMService
from pipecat.transports.heygen.transport import HeyGenParams, HeyGenTransport from pipecat.transports.heygen.transport import HeyGenParams, HeyGenTransport, ServiceType
from pipecat.turns.user_stop import TurnAnalyzerUserTurnStopStrategy from pipecat.turns.user_stop import TurnAnalyzerUserTurnStopStrategy
from pipecat.turns.user_turn_strategies import UserTurnStrategies from pipecat.turns.user_turn_strategies import UserTurnStrategies
@@ -40,7 +40,8 @@ logger.add(sys.stderr, level="DEBUG")
async def main(): async def main():
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
transport = HeyGenTransport( transport = HeyGenTransport(
api_key=os.getenv("HEYGEN_API_KEY"), api_key=os.getenv("HEYGEN_LIVE_AVATAR_API_KEY"),
service_type=ServiceType.LIVE_AVATAR,
session=session, session=session,
params=HeyGenParams( params=HeyGenParams(
audio_in_enabled=True, audio_in_enabled=True,

View File

@@ -93,7 +93,8 @@ class LiveAvatarSessionData(BaseModel):
Parameters: Parameters:
session_id (str): Unique identifier for the streaming session. session_id (str): Unique identifier for the streaming session.
livekit_url (str): LiveKit server URL for the session. livekit_url (str): LiveKit server URL for the session.
livekit_client_token (str): Access token for LiveKit. livekit_client_token (str): Access token for LiveKit user.
livekit_agent_token (str): Access token for LiveKit Agent (Pipecat).
max_session_duration (int): Maximum session duration in seconds. max_session_duration (int): Maximum session duration in seconds.
ws_url (str): WebSocket URL for the session. ws_url (str): WebSocket URL for the session.
""" """
@@ -101,6 +102,7 @@ class LiveAvatarSessionData(BaseModel):
session_id: str session_id: str
livekit_url: str livekit_url: str
livekit_client_token: str livekit_client_token: str
livekit_agent_token: str
max_session_duration: int max_session_duration: int
ws_url: str ws_url: str
@@ -303,10 +305,7 @@ class LiveAvatarApi(BaseAvatarApi):
session_id=session_response.data.session_id, session_id=session_response.data.session_id,
access_token=session_response.data.livekit_client_token, access_token=session_response.data.livekit_client_token,
livekit_url=session_response.data.livekit_url, livekit_url=session_response.data.livekit_url,
# TODO: HeyGen will create a new token for Pipecat livekit_agent_token=session_response.data.livekit_agent_token,
# Right now they are creating a single token, which is supposed to be used by the user
# Due to this, HeyGenTransport it is not going to work yet.
livekit_agent_token=session_response.data.livekit_client_token,
ws_url=session_response.data.ws_url, ws_url=session_response.data.ws_url,
raw_response=session_response, raw_response=session_response,
) )