Allow logging without voice
This commit is contained in:
parent
be10bfe44c
commit
28d8d26ce7
3 changed files with 58 additions and 47 deletions
|
@ -756,7 +756,9 @@ class HugveyState(object):
|
|||
if self.command.config['voice']['record_dir']:
|
||||
self.logger.warn("Record Audio of conversation")
|
||||
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.logger.debug("Start Speech")
|
||||
|
|
|
@ -16,7 +16,7 @@ class Recorder:
|
|||
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')
|
||||
|
||||
if not os.path.exists(out_folder):
|
||||
|
@ -26,6 +26,7 @@ class Recorder:
|
|||
self.src_rate = src_rate
|
||||
self.main_folder = out_folder # unfortunately not every device plays 16kHz audio streams
|
||||
self.running = False
|
||||
self.record_voice = record_voice
|
||||
self.data = array('h')
|
||||
self.currentLog = []
|
||||
|
||||
|
@ -53,6 +54,8 @@ class Recorder:
|
|||
self.logger.info("Skip empty wave creation")
|
||||
return
|
||||
|
||||
|
||||
if self.record_voice:
|
||||
self.fragmentNr += 1
|
||||
|
||||
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:
|
||||
fp.write(f"{self.fragmentNr}\t{self.currentTranscription}\n")
|
||||
|
||||
self.log('-',self.currentTranscription)
|
||||
|
||||
self.data = array('h')
|
||||
self.currentTranscription = ""
|
||||
|
||||
def receive(self, chunk):
|
||||
if not self.record_voice:
|
||||
return
|
||||
|
||||
if not self.running:
|
||||
return
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ voice:
|
|||
port: 4444
|
||||
chunk: 2972
|
||||
google_credentials: "../test_googlespeech/My First Project-0c7833e0d5fa.json"
|
||||
record_dir: "./recordings"
|
||||
record_voice: false
|
||||
hugveys: 26
|
||||
languages:
|
||||
- code: en-GB
|
||||
|
|
Loading…
Reference in a new issue