diff --git a/hugvey/central_command.py b/hugvey/central_command.py index 12c84ab..7b074cd 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -150,6 +150,7 @@ class CentralCommand(object): for hv_id in self.hugvey_ids: status['hugveys'].append(self.getHugveyStatus(hv_id, hv_id in selected_ids)) + status['hugveys'].sort(key=lambda hv: hv['light_id'] if 'light_id' in hv else hv['id']) # if selected_id and selected_id in self.hugveys: # if self.hugveys[selected_id].recorder: # status['logbook'] = self.hugveys[selected_id].recorder.currentLog diff --git a/hugvey/speech/google.py b/hugvey/speech/google.py index e1d6249..60fa481 100644 --- a/hugvey/speech/google.py +++ b/hugvey/speech/google.py @@ -37,6 +37,7 @@ class GoogleVoiceClient(object): # Create a thread-safe buffer of audio data self.buffer = queue.Queue() self.isRunning = threading.Event() + self.isStarted = threading.Event() self.toBeShutdown = False self.target_rate = 16000 self.cv_laststate = None @@ -57,6 +58,25 @@ class GoogleVoiceClient(object): def resume(self): self.buffer = queue.Queue() # have a clear queue when resuming self.isRunning.set() + + def start(self): + """ + Pause/resume are used within a story to create a break/restart in the recording + eacht time hugvey speaks. however, this caused issues with the mics that stay on after + a story finishes (it cause Google to resume). Hence, we add another layer to its running + state: start/stop. This is not influenced by the resume and triggered by starting and + stopping the story only. + A bit messy but it should work ;-) + """ + self.logger.info("Start STT") + self.resume() + self.isStarted.set() + + + def stop(self): + self.logger.info("Stop STT") + self.pause() + self.isStarted.clear() def generator(self): self.logger.debug('start generator') @@ -207,12 +227,16 @@ class GoogleVoiceClient(object): return self.subsequentMutedFrames = 0 + + if not self.isStarted.is_set(): + # Stopped state, so resume is not triggered + return + # self.logger.debug("We have mic!") if not self.isRunning.is_set(): self.logger.info("Resume voice") self.resume() - if not self.isRunning.is_set(): # logger.log(LOG_BS, "Don't put to queue if google is paused") return @@ -228,7 +252,7 @@ class GoogleVoiceClient(object): self.hugvey = None def triggerStart(self): - pass + self.start() def __del__(self): self.logger.warn("Destroyed google object") diff --git a/hugvey/story.py b/hugvey/story.py index 916213e..e719021 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -1659,6 +1659,8 @@ class Story(object): self.stop() self.finish_time = time.time() self.timer.pause() + if self.hugvey.google: + self.hugvey.google.stop() def calculateFinishesForMsg(self, msgId, depth = 0, checked = []): # if msgId in checked: diff --git a/www/css/styles.css b/www/css/styles.css index 090f746..a8fc216 100644 --- a/www/css/styles.css +++ b/www/css/styles.css @@ -61,7 +61,7 @@ img.icon { height: 100%; overflow-y: scroll; } .panopticon #status { - width: 90%; } + width: 80%; } #status > div { width: 33.3333333%; height: 200px; @@ -344,7 +344,7 @@ body.showTimeline #toggleTimeline { border-radius: 15px; } #logbook { - width: 50%; + width: 20%; padding: 10px; color: #999; height: 100%; diff --git a/www/js/hugvey_timeline.js b/www/js/hugvey_timeline.js index 7f83f6f..786303d 100644 --- a/www/js/hugvey_timeline.js +++ b/www/js/hugvey_timeline.js @@ -125,7 +125,7 @@ checkbox.addEventListener('change', (event) => { this.eventDataSet.update(d); console.log('update', d); } else { - this.eventDataSet.add({id: mId, content: msgContent, title: `${msgContent} (${msgId})`, start: new Date(), group: hv_id, 'className': 'message'}); + this.eventDataSet.add({id: mId, content: msgContent, title: `${msgContent} (${msgId})`, start: new Date(), end: new Date(Date.now()+5000), group: hv_id, 'className': 'message'}); } break; case 'speaking': @@ -137,7 +137,7 @@ checkbox.addEventListener('change', (event) => { let scId = 'sc-'+id+'-'+hv_id; if(info.startsWith('start')){ - this.eventDataSet.add({content: info, start: new Date(), type: 'point', group: hv_id, 'className': 'speech'}); + this.eventDataSet.add({content: info, start: new Date(), end: new Date(Date.now() + 1000), type: 'point', group: hv_id, 'className': 'speech'}); } if(info.startsWith('content')){ d = this.eventDataSet.get(scId); @@ -149,7 +149,7 @@ checkbox.addEventListener('change', (event) => { this.eventDataSet.update(d); } else { console.log('add'); - this.eventDataSet.add({id: scId, content: content, title: content, start: new Date(), group: hv_id, 'className': 'speech'}); + this.eventDataSet.add({id: scId, content: content, title: content, start: new Date(), end: new Date(Date.now() + 1000), group: hv_id, 'className': 'speech'}); } } if(info.startsWith('end')){ diff --git a/www/scss/styles.scss b/www/scss/styles.scss index c0af4c8..10845e0 100644 --- a/www/scss/styles.scss +++ b/www/scss/styles.scss @@ -85,7 +85,7 @@ img.icon{ overflow-y: scroll; .panopticon &{ - width: 90% + width: 80% } & > div{ @@ -553,7 +553,7 @@ img.icon{ } #logbook{ - width: 50%; + width: 20%; padding: 10px; color: #999; height: 100%; diff --git a/www/timeline.html b/www/timeline.html index f615f13..94af64a 100644 --- a/www/timeline.html +++ b/www/timeline.html @@ -4,6 +4,7 @@ +