-
Notifications
You must be signed in to change notification settings - Fork 2k
HeyGen improvements. #3653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HeyGen improvements. #3653
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Added support for `video_settings` parameter in `LiveAvatarNewSessionRequest` to configure video encoding (H264/VP8) and quality levels. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Added support for `is_sandbox` parameter in `LiveAvatarNewSessionRequest` to enable sandbox mode for HeyGen LiveAvatar sessions. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Changed default session mode from "CUSTOM" to "LITE" in HeyGen LiveAvatar integration, with VP8 as the default video encoding. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| API to communicate with LiveAvatar Streaming API. | ||
| """ | ||
|
|
||
| from enum import Enum | ||
| from typing import Any, Dict, Optional | ||
|
|
||
| import aiohttp | ||
|
|
@@ -46,17 +47,45 @@ class CustomSDKLiveKitConfig(BaseModel): | |
| livekit_client_token: str | ||
|
|
||
|
|
||
| class VideoEncoding(str, Enum): | ||
| """Enum representing the video encoding.""" | ||
|
|
||
| H264 = "H264" | ||
| VP8 = "VP8" | ||
|
|
||
|
|
||
| class VideoQuality(str, Enum): | ||
| """Enum representing different avatar quality levels.""" | ||
|
|
||
| low = "low" | ||
| medium = "medium" | ||
| high = "high" | ||
| very_high = "very_high" | ||
|
|
||
|
|
||
| class VideoSettings(BaseModel): | ||
| """Video encoding settings for session configuration.""" | ||
|
|
||
| encoding: VideoEncoding | ||
| quality: VideoQuality = VideoQuality.high | ||
|
|
||
|
|
||
| class LiveAvatarNewSessionRequest(BaseModel): | ||
| """Request model for creating a LiveAvatar session token. | ||
|
|
||
| Parameters: | ||
| mode (str): Session mode (default: "CUSTOM"). | ||
| mode (str): Session mode (default: "LITE"). | ||
| avatar_id (str): Unique identifier for the avatar. | ||
| video_settings (VideoSettings): Video encoding settings. | ||
| is_sandbox (bool): Enable sandbox mode (default: False). | ||
| avatar_persona (AvatarPersona): Avatar persona configuration. | ||
| livekit_config (CustomSDKLiveKitConfig): Custom LiveKit configuration. | ||
| """ | ||
|
|
||
| mode: str = "CUSTOM" | ||
| mode: str = "LITE" | ||
| avatar_id: str | ||
| video_settings: Optional[VideoSettings] = VideoSettings(encoding=VideoEncoding.VP8) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect that HeyGen changed their API and started sending video using H.264 instead of VP8 by default. While this works on other platforms, it looks like the LiveKit Python SDK on macOS is unable to decode H.264, so we don’t receive any video frames in Pipecat. We will use VP8 as the default codec, while still allowing users to switch codecs in case H.264 works on other platforns.
filipi87 marked this conversation as resolved.
|
||
| is_sandbox: Optional[bool] = False | ||
| avatar_persona: Optional[AvatarPersona] = None | ||
| livekit_config: Optional[CustomSDKLiveKitConfig] = None | ||
|
|
||
|
|
@@ -219,7 +248,7 @@ async def create_session_token( | |
| Session token information. | ||
| """ | ||
| params: dict[str, Any] = { | ||
| "mode": request_data.mode, | ||
| "mode": request_data.mode if request_data.mode is not None else "LITE", | ||
| "avatar_id": request_data.avatar_id, | ||
| } | ||
|
|
||
|
|
@@ -234,6 +263,20 @@ async def create_session_token( | |
| avatar_persona = {k: v for k, v in avatar_persona.items() if v is not None} | ||
| params["avatar_persona"] = avatar_persona | ||
|
|
||
| if request_data.is_sandbox is not None: | ||
| params["is_sandbox"] = request_data.is_sandbox | ||
|
|
||
| if request_data.video_settings is not None: | ||
| video_settings = { | ||
| "encoding": request_data.video_settings.encoding.value, | ||
| "quality": request_data.video_settings.quality.value, | ||
| } | ||
| params["video_settings"] = video_settings | ||
| else: | ||
| # Fall back to VP8 encoding if video_settings is not provided | ||
| params["video_settings"] = {"encoding": VideoEncoding.VP8.value} | ||
|
|
||
| logger.debug(f"Creating LiveAvatar session token with params: {params}") | ||
| response = await self._request("POST", "/sessions/token", params) | ||
| logger.debug(f"LiveAvatar session token created") | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've changed the docstring to a default of
"LITE"but the actual mode default on line 83 is still"CUSTOM".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, nice catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.