Prep for russian and fix #92 - error when hugvey is silent

This commit is contained in:
Ruben van de Ven 2019-11-30 15:22:59 +01:00
parent ecec82b617
commit 0616fcf72f
7 changed files with 109 additions and 12 deletions

View File

@ -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'):

View File

@ -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:

View File

@ -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: []

View File

@ -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"); }

7
www/images/ru.svg Normal file
View File

@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" id="flag-icon-css-ru" viewBox="0 0 640 480">
<g fill-rule="evenodd" stroke-width="1pt">
<path fill="#fff" d="M0 0h640v480H0z"/>
<path fill="#0039a6" d="M0 160h640v320H0z"/>
<path fill="#d52b1e" d="M0 320h640v160H0z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 286 B

52
www/images/ru2.svg Normal file
View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
viewBox="0 0 640 480"
id="flag-icon-css-ru">
<metadata
id="metadata15">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs13" />
<g
id="g8"
stroke-width="1pt"
fill-rule="evenodd">
<path
id="path2"
d="M0 0h640v480H0z"
fill="#fff" />
<path
id="path4"
d="M0 160h640v320H0z"
fill="#0039a6" />
<path
id="path6"
d="M0 320h640v160H0z"
fill="#d52b1e" />
</g>
<text
id="text827"
y="443.38986"
x="165.22749"
style="font-style:normal;font-weight:normal;font-size:533.27386475px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.99999994"
xml:space="preserve"><tspan
style="stroke-width:0.99999994"
y="443.38986"
x="165.22749"
id="tspan825">2</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -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;
}
}
}