Untested changes for time info and language change
This commit is contained in:
parent
0c1936126c
commit
70a146491f
3 changed files with 26 additions and 15 deletions
|
@ -158,11 +158,13 @@ class CentralCommand(object):
|
|||
# status['history'] = hv.story.getLogSummary() # disabled as it is a bit slow. We now have eventLog
|
||||
# status['counts'] = {t: len(a) for t, a in status['history'].items() if t != 'directions' }
|
||||
status['counts'] = {} if not hv.story else hv.story.getLogCounts()
|
||||
status['duration'] = 0 if not hv.story else hv.story.timer.getElapsed()
|
||||
status['duration'] = 0 if not hv.story else (hv.story.timer.getElapsed('first_speech') if hv.story.timer.hasMark('first_speech') else hv.story.timer.getElapsed())
|
||||
status['has_state'] = Story.hugveyHasSavedState(hv.lightId)
|
||||
status['variables'] = {} if not isSelected or not hv.story else hv.story.variableValues
|
||||
|
||||
# evLogger = eventLogger.getChild(f"{hv_id}")
|
||||
status['time_since_hugvey_spoke_state'] = ""
|
||||
status['time_since_visitor_spoke_state'] = ""
|
||||
|
||||
if not hv.story:
|
||||
status['time_since_hugvey_spoke'] = '-'
|
||||
|
@ -175,23 +177,21 @@ class CentralCommand(object):
|
|||
else:
|
||||
diff = datetime.timedelta(seconds=int(hv.story.timer.getElapsed() - hv.story.lastMsgFinishTime))
|
||||
status['time_since_hugvey_spoke'] = str(diff)
|
||||
# if diff > 300:
|
||||
# evLogger.warning("Very long time since hugvey spoke")
|
||||
# elif diff > 100:
|
||||
# evLogger.warning("Long time since hugvey spoke")
|
||||
# else:
|
||||
# #clear warning
|
||||
# pass
|
||||
if diff > 300:
|
||||
status['time_since_hugvey_spoke_state'] = 'critical'
|
||||
elif diff > 100:
|
||||
status['time_since_hugvey_spoke_state'] = 'warning'
|
||||
|
||||
if not hv.story.timer.hasMark('last_speech'):
|
||||
status['time_since_visitor_spoke'] = 'never'
|
||||
else:
|
||||
diff = datetime.timedelta(seconds=int(hv.story.timer.getElapsed('last_speech')))
|
||||
status['time_since_visitor_spoke'] = str(diff)
|
||||
# if diff > 300:
|
||||
if diff > 300:
|
||||
# evLogger.warning("Very long time since audience spoke")
|
||||
# elif diff > 100:
|
||||
# evLogger.warning("Long time since audience spoke")
|
||||
status['time_since_visitor_spoke'] = 'critical'
|
||||
elif diff > 100:
|
||||
status['time_since_visitor_spoke'] = 'warning'
|
||||
# else:
|
||||
# #clear warning
|
||||
# pass
|
||||
|
@ -535,6 +535,7 @@ class HugveyState(object):
|
|||
|
||||
self.eventQueue = None
|
||||
self.language_code = 'en-GB'
|
||||
self.future_language_code = None
|
||||
self.story = None
|
||||
self.streamer = None
|
||||
self.google = None
|
||||
|
@ -695,8 +696,9 @@ class HugveyState(object):
|
|||
if event['event'] == 'change_language':
|
||||
self.setLanguage(event['lang_code'])
|
||||
if event['event'] == 'change_language_if_available':
|
||||
if self.isAvailable() or self.status == self.STATE_BLOCKED:
|
||||
self.setLanguage(event['lang_code'])
|
||||
self.future_language_code = event['lang_code']
|
||||
# if self.isAvailable() or self.status == self.STATE_BLOCKED:
|
||||
# self.setLanguage(event['lang_code'])
|
||||
if event['event'] == 'change_light':
|
||||
self.setLightId(event['light_id'])
|
||||
if event['event'] == 'change_light_status':
|
||||
|
@ -860,6 +862,10 @@ class HugveyState(object):
|
|||
self.logger.info("Changing language")
|
||||
self.configureLanguage(self.story.language_code)
|
||||
else:
|
||||
if self.future_language_code and self.future_language_code != self.language_code:
|
||||
self.logger.info(f"Restart with other language: {self.language_code} -> {self.future_language_code}")
|
||||
self.configureLanguage(self.future_language_code)
|
||||
|
||||
self.story = Story(self, port)
|
||||
self.story.setStoryData(copy.deepcopy(self.command.languages[self.language_code]), self.language_code)
|
||||
|
||||
|
|
|
@ -140,6 +140,9 @@ def getWebSocketHandler(central_command):
|
|||
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language', 'lang_code': lang_code})
|
||||
|
||||
def msgChangeLanguageForAllAvailableHugveys(self, lang_code):
|
||||
"""
|
||||
Set language for all future hugvey runs (so after a 'finish')
|
||||
"""
|
||||
for hv_id in central_command.hugveys:
|
||||
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language_if_available', 'lang_code': lang_code})
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ class Reply(object):
|
|||
self.utterances.append(utterance)
|
||||
|
||||
def getText(self) -> str:
|
||||
return ". ".join([u.text for u in self.utterances])
|
||||
return ". ".join([u.text for u in self.utterances]).strip()
|
||||
|
||||
def getActiveUtterance(self, currentTime) -> Utterance:
|
||||
"""
|
||||
|
@ -1592,6 +1592,8 @@ class Story(object):
|
|||
utterance.setText(e['transcript'], now)
|
||||
|
||||
self.hugvey.eventLogger.info("speaking: content {} \"{}\"".format(id(utterance), e['transcript']))
|
||||
if not self.timer.hasMark('first_speech'):
|
||||
self.timer.setMark('first_speech')
|
||||
self.timer.setMark('last_speech')
|
||||
|
||||
if e['is_final']:
|
||||
|
|
Loading…
Reference in a new issue