Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from __future__ import annotations

import asyncio
import logging
import os
from typing import Any
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from .avatar import VideoQuality

import aiohttp

Expand Down Expand Up @@ -54,6 +59,7 @@ async def create_streaming_session(
room: rtc.Room,
avatar_id: str,
is_sandbox: bool = False,
video_quality: VideoQuality | None = None,
) -> dict[str, Any]:
"""Create a new streaming session, return a session id"""

Expand All @@ -63,13 +69,16 @@ async def create_streaming_session(
"livekit_client_token": livekit_token,
}

payload = {
payload: dict[str, Any] = {
"mode": "LITE",
"avatar_id": avatar_id,
"is_sandbox": is_sandbox,
"livekit_config": livekit_config,
}

if video_quality is not None:
payload["video_quality"] = video_quality

self._headers = {
"accept": "application/json",
"content-type": "application/json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import uuid
from collections.abc import Iterator
from typing import Any
from typing import Any, Literal

import aiohttp

Expand Down Expand Up @@ -38,6 +38,8 @@
_AVATAR_AGENT_IDENTITY = "liveavatar-avatar-agent"
_AVATAR_AGENT_NAME = "liveavatar-avatar-agent"

VideoQuality = Literal["very_high", "high", "medium", "low"]


class AvatarSession(BaseAvatarSession):
"""A LiveAvatar avatar session"""
Expand All @@ -49,6 +51,7 @@ def __init__(
api_url: NotGivenOr[str] = NOT_GIVEN,
api_key: NotGivenOr[str] = NOT_GIVEN,
is_sandbox: NotGivenOr[bool] = NOT_GIVEN,
video_quality: NotGivenOr[VideoQuality] = NOT_GIVEN,
avatar_participant_identity: NotGivenOr[str] = NOT_GIVEN,
avatar_participant_name: NotGivenOr[str] = NOT_GIVEN,
conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS,
Expand All @@ -69,6 +72,7 @@ def __init__(
conn_options=conn_options,
)
self._is_sandbox = is_sandbox if is_given(is_sandbox) else False
self._video_quality = video_quality if is_given(video_quality) else None

self._avatar_participant_identity = avatar_participant_identity or _AVATAR_AGENT_IDENTITY
self._avatar_participant_name = avatar_participant_name or _AVATAR_AGENT_NAME
Expand Down Expand Up @@ -136,6 +140,7 @@ async def start(
room=self._room,
avatar_id=self._avatar_id,
is_sandbox=self._is_sandbox,
video_quality=self._video_quality,
)
self._session_id = session_config_data["data"]["session_id"]
self._session_token = session_config_data["data"]["session_token"]
Expand Down
Loading