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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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