diff --git a/hugvey/central_command.py b/hugvey/central_command.py index c42aae8..80a6e70 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -190,6 +190,8 @@ class CentralCommand(object): status['time_since_hugvey_spoke_state'] = "" status['time_since_visitor_spoke_state'] = "" + hugveyCriticalDiff = self.config['story']['hugvey_critical_silence'] if 'hugvey_critical_silence' in self.config['story'] else 90 + if not hv.story: status['time_since_hugvey_spoke'] = '-' status['time_since_visitor_spoke'] = '-' @@ -202,9 +204,9 @@ class CentralCommand(object): diff = datetime.timedelta(seconds=int(hv.story.timer.getElapsed() - hv.story.lastMsgFinishTime)) status['time_since_hugvey_spoke'] = str(diff) diffs = diff.total_seconds() - if diffs > 120: + if diffs > hugveyCriticalDiff: status['time_since_hugvey_spoke_state'] = 'critical' - elif diffs > 80: + elif diffs > hugveyCriticalDiff/1.5: status['time_since_hugvey_spoke_state'] = 'warning' if not hv.story.timer.hasMark('last_speech'): diff --git a/hugvey/story.py b/hugvey/story.py index f1c0290..8870c78 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -1471,6 +1471,7 @@ class Story(object): self.finish_time = False self.runId = uuid.uuid4().hex self.diversionDirections = [] + self.gaveErrorForNotContinuing = False self.events = [] # queue of received events self.commands = [] # queue of commands to send @@ -1777,6 +1778,23 @@ class Story(object): self.hugvey.eventLogger.warning("Audience is quiet for too long...stopping") self.logger.warning("Audience is quiet, force END!") self._finish() + + def checkIfHanging(self): + ''' + Make a guestimation if the story is hanging at a message. Raise exception once. + ''' + if not self.lastMsgFinishTime or self.gaveErrorForNotContinuing: + # don't do it when hugvey is speaking + # or when it already gave the error for this message + return + diff = self.timer.getElapsed() - self.lastMsgFinishTime + + safeDiff = self.hugvey.command.config['story']['hugvey_critical_silence'] if 'hugvey_critical_silence' in self.hugvey.command.config['story'] else 90 + + if diff > safeDiff: + self.hugvey.eventLogger.warning("Hugvey is quiet for very long!") + self.logger.critical("Hugvey is quiet for very long!") # critical messages are forwarded to telegram + self.gaveErrorForNotContinuing = True async def _renderer(self): """ @@ -1798,6 +1816,7 @@ class Story(object): directions = self.getCurrentDirections() await self._processDirections(directions) self.checkIfGone() + self.checkIfHanging() # TODO create timer event # self.commands.append({'msg':'TEST!'}) @@ -1836,6 +1855,7 @@ class Story(object): self.lastMsgTime = time.time() self.lastMsgFinishTime = None # to be filled in by the event self.lastMsgStartTime = None # to be filled in by the event + self.gaveErrorForNotContinuing = False self.allowReplyInterrupt = allowReplyInterrupt # if not reset: diff --git a/server_config.yml b/server_config.yml index 2a63c59..6dcf3e0 100644 --- a/server_config.yml +++ b/server_config.yml @@ -18,19 +18,24 @@ languages: token: "LB_TOKEN" connect_timeout: 3 request_timeout: 5 - - code: de-DE - file: story_de.json - type: "ms" - token: "xxx" - - code: fr-FR - file: story_fr.json + - code: ru-RU + file: story_ru.json type: "ms" token: "SECRET_KEY" token_url: "https://LOCATION.api.cognitive.microsoft.com/sts/v1.0/issueToken" voice_url: "https://LOCATION.voice.speech.microsoft.com/cognitiveservices/v1?deploymentId=DEPID" - ms_gender: "Male" - ms_name: "NAME" - ms_lang: "fr-FR" + ms_gender: "Female" + ms_name: "Microsoft Server Speech Text to Speech Voice (ru-RU, Irina, Apollo)" + ms_lang: "ru-RU" + - code: ru-RU2 + file: story_ru.json + type: "ms" + token: "SECRET_KEY" + token_url: "https://LOCATION.api.cognitive.microsoft.com/sts/v1.0/issueToken" + voice_url: "https://LOCATION.voice.speech.microsoft.com/cognitiveservices/v1?deploymentId=DEPID" + ms_gender: "Female" + ms_name: "Microsoft Server Speech Text to Speech Voice (ru-RU, EkaterinaRUS)" + ms_lang: "ru-RU" - code: fr-FR2 file: story_fr2.json type: "ms" @@ -51,6 +56,7 @@ light: fade_duration_id: 37 story: loop: true + hugvey_critical_silence: 90 telegram: token: null chat_ids: [] \ No newline at end of file diff --git a/www/css/styles.css b/www/css/styles.css index 8060449..261158c 100644 --- a/www/css/styles.css +++ b/www/css/styles.css @@ -324,6 +324,10 @@ img.icon { background-image: url("/images/fr.svg"); } .flag-icon.fr-FR2 { background-image: url("/images/fr2.svg"); } + .flag-icon.ru-RU { + background-image: url("/images/ru.svg"); } + .flag-icon.ru-RU2 { + background-image: url("/images/ru2.svg"); } .flag-icon.nl-NL { background-image: url("/images/nl.svg"); } diff --git a/www/images/ru.svg b/www/images/ru.svg new file mode 100644 index 0000000..f56fddb --- /dev/null +++ b/www/images/ru.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/www/images/ru2.svg b/www/images/ru2.svg new file mode 100644 index 0000000..12e551d --- /dev/null +++ b/www/images/ru2.svg @@ -0,0 +1,52 @@ + + + + + + image/svg+xml + + + + + + + + + + + + 2 + diff --git a/www/scss/styles.scss b/www/scss/styles.scss index 80386e6..c4de001 100644 --- a/www/scss/styles.scss +++ b/www/scss/styles.scss @@ -522,6 +522,12 @@ img.icon{ &.fr-FR2 { background-image: url('/images/fr2.svg'); } + &.ru-RU { + background-image: url('/images/ru.svg'); + } + &.ru-RU2 { + background-image: url('/images/ru2.svg'); + } &.nl-NL { background-image: url('/images/nl.svg'); } @@ -654,4 +660,4 @@ img.icon{ &.visible{ display:block; } -} \ No newline at end of file +}