From 45744fb5e466349956f6cc097a7a708ac2d57892 Mon Sep 17 00:00:00 2001 From: Hugvey Central Command Date: Sun, 12 May 2019 14:42:50 +0200 Subject: [PATCH 1/3] updated README --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ed16384..d1c5994 100644 --- a/README.md +++ b/README.md @@ -92,18 +92,27 @@ chown=pi:pi ## Deploy / usefull commands +rsync them all ```bash for i in {1..26}; do echo $i; rsync -av ~/hugvey/ pi@hugvey$i.local:/home/pi/hugvey/ --exclude=www --exclude=venv --exclude=local --exclude=*.pyc --exclude=.git --exclude=recordings --exclude=/voice* --exclude=/pd; done ``` +shut all of them down ```bash -for i in {1..6}; do ssh pi@hugvey$i.local "sudo shutdown -h now"; done +for i in {1..26}; do ssh pi@hugvey$i.local "sudo shutdown -h now"; done ``` +restart supervisor on all of them ```bash -for i in {1..6}; do ssh pi@hugvey$i.local "supervisorctl restart hugvey_client"; done +for i in {1..26}; do ssh pi@hugvey$i.local "supervisorctl restart hugvey_client"; done ``` +install bash on all of them +```bash +for i in {1..26}; do echo $i;ssh pi@hugvey$i.local "cd hugvey && sudo bash install_server.sh"; done +``` + + ### Monitoring the server processes @@ -205,3 +214,12 @@ times occured/only on n-th instance: determines the order of diversions of the s Visit 192.168.5.1 The password is at the bottom of the device. + + +# Restoring a hugvey + +- Write image `/mnt/stash/hugvey.img` to the microSD card. + + You can use `gnome-disks` 'restore image' for that +- Open partition called rootfs, and `sudo nano etc/hostname` + + Change hugvey20 into hugveyX (the number you need) +- Start it, rsync, install_server.sh as mentioned above. From cd7a948787545d5f96a08c90a7c62bd23c18eb1d Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Sun, 12 May 2019 14:54:37 +0200 Subject: [PATCH 2/3] Set volume per language --- hugvey/story.py | 23 +++++++++++++++++-- www/css/styles.css | 15 ++++++------ www/index.html | 1 + www/js/hugvey_console.js | 49 +++++++++++++++++++++++++++++++++++++++- www/scss/styles.scss | 12 ++++++---- 5 files changed, 85 insertions(+), 15 deletions(-) diff --git a/hugvey/story.py b/hugvey/story.py index 0eaca85..97181a6 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -103,6 +103,9 @@ class Message(object): if not 'vol' in msg.params: # prevent clipping on some Lyrebird tracks msg.params['vol'] = .8 + + msg.params['vol'] = float(msg.params['vol']) + return msg def parseForVariables(self): @@ -937,12 +940,23 @@ class Diversion(object): return True +class Configuration(object): + id = 'configuration' + volume = 1 + + @classmethod + def initFromJson(configClass, data, story): + config = Configuration() + config.__dict__.update(data) + return config + storyClasses = { 'Msg': Message, 'Direction': Direction, 'Condition': Condition, 'Diversion': Diversion, + 'Configuration': Configuration, } @@ -1158,6 +1172,8 @@ class Story(object): self.diversions = [el for el in self.elements.values() if type(el) == Diversion] self.interruptionDiversions = [el for el in self.elements.values() if type(el) == Diversion and el.type == 'interrupt'] + configurations = [el for el in self.elements.values() if type(el) == Configuration] + self.configuration = configurations[0] if len(configurations) else Configuration() if currentId: self.currentMessage = self.get(currentId) @@ -1536,13 +1552,16 @@ class Story(object): self.logger.critical(f"error: crash when reading wave file: {fn}") self.logger.exception(e) duration = 10 # some default duration to have something to fall back to - + + params = message.getParams().copy() + params['vol'] = params['vol'] * self.configuration.volume if 'vol' in params else self.configuration.volume + # self.hugvey.google.pause() # pause STT to avoid text events while decision is made self.hugvey.sendCommand({ 'action': 'play', 'file': fn, 'id': message.id, - 'params': message.getParams(), + 'params': params, 'duration': duration }) diff --git a/www/css/styles.css b/www/css/styles.css index 56919f7..e4b258c 100644 --- a/www/css/styles.css +++ b/www/css/styles.css @@ -44,13 +44,14 @@ img.icon { flex-direction: row; height: 100vh; width: 100vw; } - #interface #audioFiles { + #interface #audioFiles, #interface #configuration { position: absolute; - top: 10%; - left: 10%; - right: 10%; - bottom: 10%; - background: #ccc; } + top: 30%; + left: 30%; + right: 30%; + bottom: 30%; + background: #ccc; + overflow: auto; } #status { display: flex; @@ -105,7 +106,7 @@ img.icon { bottom: 3px; right: 3px; } #status .hugvey .light input { - width: 2em; } + width: 3.2em; } #status .hugvey .stats .count { display: inline-block; margin-right: 10px; } diff --git a/www/index.html b/www/index.html index 23c9cf6..bc9d860 100644 --- a/www/index.html +++ b/www/index.html @@ -81,6 +81,7 @@
Create message
View Diversions
View Audio Files
+
Configuration
node['@type'] == 'Condition' ); this.diversions = this.data.filter(( node ) => node['@type'] == 'Diversion' ); + let configurations = this.data.filter(( node ) => node['@type'] == 'Configuration' ); + this.configuration = configurations.length > 0 ? configurations[0] : { + "@id": "config", + "@type": "Configuration" + }; + document.getElementById('current_lang').innerHTML = ""; document.getElementById('current_lang').appendChild(crel('span', { 'class': 'flag-icon ' + this.language_code diff --git a/www/scss/styles.scss b/www/scss/styles.scss index f617858..b9ee96c 100644 --- a/www/scss/styles.scss +++ b/www/scss/styles.scss @@ -64,14 +64,16 @@ img.icon{ &.showStatus{ } - #audioFiles { + #audioFiles, #configuration { position: absolute; - top: 10%; - left: 10%; - right: 10%; - bottom: 10%; + top: 30%; + left: 30%; + right: 30%; + bottom: 30%; background: #ccc; + overflow:auto; } + } #status{ From fefda5a2a59eaf8b5fba7e2c272a862958e26736 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Sun, 12 May 2019 15:06:00 +0200 Subject: [PATCH 3/3] Speed up for calculateFinishesForMsg --- hugvey/story.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hugvey/story.py b/hugvey/story.py index 97181a6..766319b 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -1647,19 +1647,24 @@ class Story(object): self.finish_time = time.time() self.timer.pause() - def calculateFinishesForMsg(self, msgId, depth = 0): + def calculateFinishesForMsg(self, msgId, depth = 0, checked = []): + if msgId in checked: + return [] + + checked.append(msgId) + if not msgId in self.directionsPerMsg or len(self.directionsPerMsg[msgId]) < 1: # is finish return [msgId] - if depth > 40: + if depth > 200: return [] finishes = [] for d in self.directionsPerMsg[msgId]: if d.msgTo.id == msgId: continue - finishes.extend(self.calculateFinishesForMsg(d.msgTo.id, depth+1)) + finishes.extend(self.calculateFinishesForMsg(d.msgTo.id, depth+1, checked)) # de-duplicate before returning return list(set(finishes))