Merge branch 'master' of gitlab.com:hugvey/hugvey

This commit is contained in:
Hugvey Central Command 2019-05-18 13:15:09 +02:00
commit 5edd78067e
7 changed files with 37 additions and 9 deletions

View file

@ -150,6 +150,7 @@ class CentralCommand(object):
for hv_id in self.hugvey_ids: for hv_id in self.hugvey_ids:
status['hugveys'].append(self.getHugveyStatus(hv_id, hv_id in selected_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 selected_id and selected_id in self.hugveys:
# if self.hugveys[selected_id].recorder: # if self.hugveys[selected_id].recorder:
# status['logbook'] = self.hugveys[selected_id].recorder.currentLog # status['logbook'] = self.hugveys[selected_id].recorder.currentLog

View file

@ -37,6 +37,7 @@ class GoogleVoiceClient(object):
# Create a thread-safe buffer of audio data # Create a thread-safe buffer of audio data
self.buffer = queue.Queue() self.buffer = queue.Queue()
self.isRunning = threading.Event() self.isRunning = threading.Event()
self.isStarted = threading.Event()
self.toBeShutdown = False self.toBeShutdown = False
self.target_rate = 16000 self.target_rate = 16000
self.cv_laststate = None self.cv_laststate = None
@ -57,6 +58,25 @@ class GoogleVoiceClient(object):
def resume(self): def resume(self):
self.buffer = queue.Queue() # have a clear queue when resuming self.buffer = queue.Queue() # have a clear queue when resuming
self.isRunning.set() 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): def generator(self):
self.logger.debug('start generator') self.logger.debug('start generator')
@ -207,12 +227,16 @@ class GoogleVoiceClient(object):
return return
self.subsequentMutedFrames = 0 self.subsequentMutedFrames = 0
if not self.isStarted.is_set():
# Stopped state, so resume is not triggered
return
# self.logger.debug("We have mic!") # self.logger.debug("We have mic!")
if not self.isRunning.is_set(): if not self.isRunning.is_set():
self.logger.info("Resume voice") self.logger.info("Resume voice")
self.resume() self.resume()
if not self.isRunning.is_set(): if not self.isRunning.is_set():
# logger.log(LOG_BS, "Don't put to queue if google is paused") # logger.log(LOG_BS, "Don't put to queue if google is paused")
return return
@ -228,7 +252,7 @@ class GoogleVoiceClient(object):
self.hugvey = None self.hugvey = None
def triggerStart(self): def triggerStart(self):
pass self.start()
def __del__(self): def __del__(self):
self.logger.warn("Destroyed google object") self.logger.warn("Destroyed google object")

View file

@ -1659,6 +1659,8 @@ class Story(object):
self.stop() self.stop()
self.finish_time = time.time() self.finish_time = time.time()
self.timer.pause() self.timer.pause()
if self.hugvey.google:
self.hugvey.google.stop()
def calculateFinishesForMsg(self, msgId, depth = 0, checked = []): def calculateFinishesForMsg(self, msgId, depth = 0, checked = []):
# if msgId in checked: # if msgId in checked:

View file

@ -61,7 +61,7 @@ img.icon {
height: 100%; height: 100%;
overflow-y: scroll; } overflow-y: scroll; }
.panopticon #status { .panopticon #status {
width: 90%; } width: 80%; }
#status > div { #status > div {
width: 33.3333333%; width: 33.3333333%;
height: 200px; height: 200px;
@ -344,7 +344,7 @@ body.showTimeline #toggleTimeline {
border-radius: 15px; } border-radius: 15px; }
#logbook { #logbook {
width: 50%; width: 20%;
padding: 10px; padding: 10px;
color: #999; color: #999;
height: 100%; height: 100%;

View file

@ -125,7 +125,7 @@ checkbox.addEventListener('change', (event) => {
this.eventDataSet.update(d); this.eventDataSet.update(d);
console.log('update', d); console.log('update', d);
} else { } 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; break;
case 'speaking': case 'speaking':
@ -137,7 +137,7 @@ checkbox.addEventListener('change', (event) => {
let scId = 'sc-'+id+'-'+hv_id; let scId = 'sc-'+id+'-'+hv_id;
if(info.startsWith('start')){ 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')){ if(info.startsWith('content')){
d = this.eventDataSet.get(scId); d = this.eventDataSet.get(scId);
@ -149,7 +149,7 @@ checkbox.addEventListener('change', (event) => {
this.eventDataSet.update(d); this.eventDataSet.update(d);
} else { } else {
console.log('add'); 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')){ if(info.startsWith('end')){

View file

@ -85,7 +85,7 @@ img.icon{
overflow-y: scroll; overflow-y: scroll;
.panopticon &{ .panopticon &{
width: 90% width: 80%
} }
& > div{ & > div{
@ -553,7 +553,7 @@ img.icon{
} }
#logbook{ #logbook{
width: 50%; width: 20%;
padding: 10px; padding: 10px;
color: #999; color: #999;
height: 100%; height: 100%;

View file

@ -4,6 +4,7 @@
<link rel="stylesheet" href="/css/vis.min.css"></link> <link rel="stylesheet" href="/css/vis.min.css"></link>
<script src="/js/reconnecting-websocket.js"></script> <script src="/js/reconnecting-websocket.js"></script>
<script src="/js/moment.min.js"></script>
<script src="/js/vis.min.js"></script> <script src="/js/vis.min.js"></script>
<style type="text/css"> <style type="text/css">
body{ body{