diff --git a/examples/foundational/43a-heygen-video-service.py b/examples/foundational/43a-heygen-video-service.py index 93c4f5ca6..a02baedaa 100644 --- a/examples/foundational/43a-heygen-video-service.py +++ b/examples/foundational/43a-heygen-video-service.py @@ -21,9 +21,10 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.heygen.api import AvatarQuality, NewSessionRequest from pipecat.services.heygen.video import HeyGenVideoService from pipecat.transports.base_transport import BaseTransport, TransportParams -from pipecat.transports.daily.transport import DailyParams +from pipecat.transports.daily.transport import DailyParams, DailyTransport load_dotenv(override=True) @@ -38,6 +39,7 @@ transport_params = { video_out_is_live=True, video_out_width=1280, video_out_height=720, + video_out_bitrate=2_000_000, # 2MBps vad_analyzer=SileroVADAnalyzer(), ), "webrtc": lambda: TransportParams( @@ -64,7 +66,13 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY")) - heyGen = HeyGenVideoService(api_key=os.getenv("HEYGEN_API_KEY"), session=session) + heyGen = HeyGenVideoService( + api_key=os.getenv("HEYGEN_API_KEY"), + session=session, + session_request=NewSessionRequest( + avatar_id="Shawn_Therapist_public", version="v2", quality=AvatarQuality.high + ), + ) messages = [ { @@ -101,6 +109,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): @transport.event_handler("on_client_connected") async def on_client_connected(transport, client): logger.info(f"Client connected") + # Updating publishing settings to enable adaptive bitrate + if isinstance(transport, DailyTransport): + await transport.update_publishing( + publishing_settings={ + "camera": { + "sendSettings": { + "allowAdaptiveLayers": True, + } + } + } + ) + # Kick off the conversation. messages.append( {