Skip to content

Commit

Permalink
feat/session_location (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl authored Feb 21, 2024
1 parent c14f127 commit 4b67d0c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions ovos_bus_client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,17 @@ def get_context(self, max_frames: int = None,


class Session:
def __init__(self, session_id: str = None, expiration_seconds: int = None,
def __init__(self, session_id: str = None,
expiration_seconds: int = None,
active_skills: List[List[Union[str, float]]] = None,
utterance_states: Dict = None, lang: str = None,
utterance_states: Dict = None,
lang: str = None,
context: IntentContextManager = None,
site_id: str = "unknown",
pipeline: List[str] = None,
stt_prefs: Dict = None,
tts_prefs: Dict = None):
tts_prefs: Dict = None,
location_prefs: Dict = None):
"""
Construct a session identifier
@param session_id: string UUID for the session
Expand All @@ -282,7 +285,7 @@ def __init__(self, session_id: str = None, expiration_seconds: int = None,

self.lang = lang or get_default_lang()

self.site_id = site_id or "unknown" # indoors placement info
self.site_id = site_id or Configuration().get("site_id") or "unknown" # indoors placement info

self.active_skills = active_skills or [] # [skill_id , timestamp]# (Message , timestamp)
self.utterance_states = utterance_states or {} # {skill_id: UtteranceState}
Expand Down Expand Up @@ -319,6 +322,7 @@ def __init__(self, session_id: str = None, expiration_seconds: int = None,
tts_prefs = {"plugin_id": ttsm,
"config": tts.get(ttsm) or {}}
self.tts_preferences = tts_prefs
self.location_preferences = location_prefs or Configuration().get("location", {})

@property
def active(self) -> bool:
Expand Down Expand Up @@ -415,7 +419,8 @@ def serialize(self) -> dict:
"site_id": self.site_id,
"pipeline": self.pipeline,
"stt": self.stt_preferences,
"tts": self.tts_preferences
"tts": self.tts_preferences,
"location": self.location_preferences
}

def update_history(self, message: Message = None):
Expand All @@ -440,8 +445,9 @@ def deserialize(data: Dict):
context = IntentContextManager.deserialize(data.get("context", {}))
site_id = data.get("site_id", "unknown")
pipeline = data.get("pipeline", [])
tts = data.get("tts_preferences", {})
stt = data.get("stt_preferences", {})
tts = data.get("tts", {})
stt = data.get("stt", {})
location = data.get("location", {})
return Session(uid,
active_skills=active,
utterance_states=states,
Expand All @@ -450,7 +456,8 @@ def deserialize(data: Dict):
pipeline=pipeline,
site_id=site_id,
tts_prefs=tts,
stt_prefs=stt)
stt_prefs=stt,
location_prefs=location)

@staticmethod
def from_message(message: Message = None):
Expand Down

0 comments on commit 4b67d0c

Please sign in to comment.