Repository: livekit/agents
File: livekit-plugins/livekit-plugins-avatartalk/livekit/plugins/avatartalk/avatar.py (Python)

Code before:
from livekit import api, rtc
from livekit.agents import NOT_GIVEN, AgentSession, NotGivenOr, get_job_context
from livekit.agents.types import ATTRIBUTE_PUBLISH_ON_BEHALF
from livekit.agents.voice.avatar import DataStreamAudioOutput

from .api import AvatarTalkAPI, AvatarTalkException
from .log import logger

_AVATAR_AGENT_IDENTITY = "avatartalk-agent"
_AVATAR_AGENT_NAME = "avatartalk-agent"
SAMPLE_RATE = 16000


class AvatarSession:
    """AvatarTalkAPI avatar session"""

    def __init__(
        self,
        *,
        api_url: NotGivenOr[str | None] = NOT_GIVEN,
        api_secret: NotGivenOr[str | None] = NOT_GIVEN,
        avatar_name: NotGivenOr[str | None] = NOT_GIVEN,
        avatar_expression: NotGivenOr[str | None] = NOT_GIVEN,
        avatar_participant_identity: NotGivenOr[str | None] = NOT_GIVEN,
        avatar_participant_name: NotGivenOr[str | None] = NOT_GIVEN,
        **kwargs,
    ):
        self._api_url = api_url or (os.getenv("AVATARTALK_API_URL") or NOT_GIVEN)
        self._api_secret = api_secret or (os.getenv("AVATARTALK_API_SECRET") or NOT_GIVEN)
        self._avatar_name = avatar_name or (os.getenv("AVATARTALK_AVATAR_NAME") or NOT_GIVEN)
        self._avatar_expression = avatar_expression or (
            os.getenv("AVATARTALK_AVATAR_EXPRESSION") or NOT_GIVEN
        )
        self._avatar_participant_identity = avatar_participant_identity or _AVATAR_AGENT_IDENTITY
        self._avatar_participant_name = avatar_participant_name or _AVATAR_AGENT_NAME
        self._agent_track = None

        if self._api_url is NOT_GIVEN or self._api_secret is NOT_GIVEN:
            raise AvatarTalkException("api_url and api_secret must be provided")

        if self._avatar_name is NOT_GIVEN:
            raise AvatarTalkException("avatar_name must be provided")

        if self._avatar_expression is NOT_GIVEN:
            self._avatar_expression = "expressive"

        self._avatartalk_api = AvatarTalkAPI(self._api_url, self._api_secret)

    def __generate_lk_token(
        self,
        livekit_api_key: str,

Review comment (suggestion):
```suggestion
```
remove kwargs if it's not used

Code after:
from livekit import api, rtc
from livekit.agents import NOT_GIVEN, AgentSession, NotGivenOr, get_job_context
from livekit.agents.types import ATTRIBUTE_PUBLISH_ON_BEHALF
from livekit.agents.voice.avatar import DataStreamAudioOutput

from .api import AvatarTalkAPI, AvatarTalkException
from .log import logger

_AVATAR_AGENT_IDENTITY = "avatartalk-agent"
_AVATAR_AGENT_NAME = "avatartalk-agent"
DEFAULT_AVATAR_NAME = "japanese_man"
DEFAULT_AVATAR_EMOTION = "expressive"
SAMPLE_RATE = 16000


class AvatarSession:
    """AvatarTalkAPI avatar session"""

    def __init__(
        self,
        *,
        api_url: NotGivenOr[str] = NOT_GIVEN,
        api_secret: NotGivenOr[str] = NOT_GIVEN,
        avatar: NotGivenOr[str | None] = NOT_GIVEN,
        emotion: NotGivenOr[str | None] = NOT_GIVEN,
        avatar_participant_identity: NotGivenOr[str | None] = NOT_GIVEN,
        avatar_participant_name: NotGivenOr[str | None] = NOT_GIVEN,
    ):
        self._avatartalk_api = AvatarTalkAPI(api_url, api_secret)
        self._avatar = avatar or (os.getenv("AVATARTALK_AVATAR") or DEFAULT_AVATAR_NAME)
        self._emotion = emotion or (os.getenv("AVATARTALK_EMOTION") or DEFAULT_AVATAR_EMOTION)
        self._avatar_participant_identity = avatar_participant_identity or _AVATAR_AGENT_IDENTITY
        self._avatar_participant_name = avatar_participant_name or _AVATAR_AGENT_NAME
        self._agent_track = None

    def __generate_lk_token(
        self,
        livekit_api_key: str,
        livekit_api_secret: str,
        room: rtc.Room,
        participant_identity: str,
        participant_name: str,
        as_agent: bool = True,
        local_participant_identity: Optional[str] = None,
    ):
        token = (
            api.AccessToken(api_key=livekit_api_key, api_secret=livekit_api_secret)
            .with_identity(participant_identity)
            .with_name(participant_name)
            .with_grants(api.VideoGrants(room_join=True, room=room.name))
            .with_attributes({ATTRIBUTE_PUBLISH_ON_BEHALF: local_participant_identity})