Merge branch 'master' of gitlab.com:hugvey/hugvey
This commit is contained in:
commit
0bd9e80429
5 changed files with 74 additions and 54 deletions
|
@ -774,7 +774,9 @@ class HugveyState(object):
|
||||||
if self.command.config['voice']['record_dir']:
|
if self.command.config['voice']['record_dir']:
|
||||||
self.logger.warn("Record Audio of conversation")
|
self.logger.warn("Record Audio of conversation")
|
||||||
self.recorder = Recorder( self.id,
|
self.recorder = Recorder( self.id,
|
||||||
self.command.config['voice']['src_rate'], self.command.config['voice']['record_dir'])
|
self.command.config['voice']['src_rate'], self.command.config['voice']['record_dir'],
|
||||||
|
self.command.config['voice']['record_voice'] if 'record_voice' in self.command.config['voice'] else False)
|
||||||
|
|
||||||
self.streamer.addConsumer(self.recorder)
|
self.streamer.addConsumer(self.recorder)
|
||||||
|
|
||||||
self.logger.debug("Start Speech")
|
self.logger.debug("Start Speech")
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Recorder:
|
||||||
Record the streamed audio
|
Record the streamed audio
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, hv_id, src_rate, out_folder):
|
def __init__(self, hv_id, src_rate, out_folder, record_voice = True):
|
||||||
self.logger = mainLogger.getChild(f"{hv_id}").getChild('recorder')
|
self.logger = mainLogger.getChild(f"{hv_id}").getChild('recorder')
|
||||||
|
|
||||||
if not os.path.exists(out_folder):
|
if not os.path.exists(out_folder):
|
||||||
|
@ -26,6 +26,7 @@ class Recorder:
|
||||||
self.src_rate = src_rate
|
self.src_rate = src_rate
|
||||||
self.main_folder = out_folder # unfortunately not every device plays 16kHz audio streams
|
self.main_folder = out_folder # unfortunately not every device plays 16kHz audio streams
|
||||||
self.running = False
|
self.running = False
|
||||||
|
self.record_voice = record_voice
|
||||||
self.data = array('h')
|
self.data = array('h')
|
||||||
self.currentLog = []
|
self.currentLog = []
|
||||||
|
|
||||||
|
@ -53,6 +54,8 @@ class Recorder:
|
||||||
self.logger.info("Skip empty wave creation")
|
self.logger.info("Skip empty wave creation")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
if self.record_voice:
|
||||||
self.fragmentNr += 1
|
self.fragmentNr += 1
|
||||||
|
|
||||||
fn = os.path.join(self.out_folder, f"{self.fragmentNr}.wav")
|
fn = os.path.join(self.out_folder, f"{self.fragmentNr}.wav")
|
||||||
|
@ -69,12 +72,16 @@ class Recorder:
|
||||||
|
|
||||||
with open(os.path.join(self.out_folder, "transcriptions.txt"), "a") as fp:
|
with open(os.path.join(self.out_folder, "transcriptions.txt"), "a") as fp:
|
||||||
fp.write(f"{self.fragmentNr}\t{self.currentTranscription}\n")
|
fp.write(f"{self.fragmentNr}\t{self.currentTranscription}\n")
|
||||||
|
|
||||||
self.log('-',self.currentTranscription)
|
self.log('-',self.currentTranscription)
|
||||||
|
|
||||||
self.data = array('h')
|
self.data = array('h')
|
||||||
self.currentTranscription = ""
|
self.currentTranscription = ""
|
||||||
|
|
||||||
def receive(self, chunk):
|
def receive(self, chunk):
|
||||||
|
if not self.record_voice:
|
||||||
|
return
|
||||||
|
|
||||||
if not self.running:
|
if not self.running:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ voice:
|
||||||
port: 4444
|
port: 4444
|
||||||
chunk: 2972
|
chunk: 2972
|
||||||
google_credentials: "../test_googlespeech/My First Project-0c7833e0d5fa.json"
|
google_credentials: "../test_googlespeech/My First Project-0c7833e0d5fa.json"
|
||||||
|
record_dir: "./recordings"
|
||||||
|
record_voice: false
|
||||||
hugveys: 26
|
hugveys: 26
|
||||||
languages:
|
languages:
|
||||||
- code: en-GB
|
- code: en-GB
|
||||||
|
|
12
www/js/crel.min.js
vendored
12
www/js/crel.min.js
vendored
|
@ -5,19 +5,27 @@ crel.attrMap['on'] = function(element, value) {
|
||||||
element.addEventListener(eventName, value[eventName]);
|
element.addEventListener(eventName, value[eventName]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
crel.attrMap['options'] = function(element, values) {
|
crel.attrMap['options'] = function(element, values, a, b) {
|
||||||
if(element.tagName != "SELECT") {
|
if(element.tagName != "SELECT") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(values, element.value);
|
|
||||||
if(Array.isArray(values)) {
|
if(Array.isArray(values)) {
|
||||||
for (let option of values) {
|
for (let option of values) {
|
||||||
|
if(element.value == option) {
|
||||||
|
element.appendChild(crel('option', {'selected': 'selected'}, option));
|
||||||
|
} else {
|
||||||
element.appendChild(crel('option', option));
|
element.appendChild(crel('option', option));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let option in values) {
|
for (let option in values) {
|
||||||
|
if(element.value == option) {
|
||||||
|
element.appendChild(crel('option', {'selected': 'selected','value': option}, values[option]));
|
||||||
|
}else{
|
||||||
element.appendChild(crel('option', {'value': option}, values[option]));
|
element.appendChild(crel('option', {'value': option}, values[option]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
|
@ -28,6 +28,7 @@ class Timeline{
|
||||||
this.dataGroups = new vis.DataSet(groups);
|
this.dataGroups = new vis.DataSet(groups);
|
||||||
let options = {
|
let options = {
|
||||||
maxHeight: '100%',
|
maxHeight: '100%',
|
||||||
|
height: '100%',
|
||||||
margin : {
|
margin : {
|
||||||
item: {
|
item: {
|
||||||
horizontal: 0,
|
horizontal: 0,
|
||||||
|
|
Loading…
Reference in a new issue