From ae4e77d3902c71ff3e6c04a01b4217122bd61e9d Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Tue, 12 Sep 2023 09:42:23 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20model=20INPUT=5FMIC=5FRE?= =?UTF-8?q?CORD=5FTIMEOUT=E3=81=A8INPUT=5FMIC=5FPHRASE=5FTIMEOUT=E3=81=AE?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E3=81=AB=E3=82=88=E3=82=8B=E6=96=87=E5=AD=97?= =?UTF-8?q?=E8=B5=B7=E3=81=93=E3=81=97=E3=81=AE=E3=83=90=E3=82=B0=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/model.py b/model.py index 99923c2c..6eb1e5a6 100644 --- a/model.py +++ b/model.py @@ -215,17 +215,23 @@ class Model: def startMicTranscript(self, fnc): mic_audio_queue = Queue() + device = [device for device in getInputDevices()[config.CHOICE_MIC_HOST] if device["name"] == config.CHOICE_MIC_DEVICE][0] + record_timeout = config.INPUT_MIC_RECORD_TIMEOUT + phase_timeout = config.INPUT_MIC_PHRASE_TIMEOUT + if record_timeout > phase_timeout: + record_timeout = phase_timeout + self.mic_audio_recorder = SelectedMicRecorder( - [device for device in getInputDevices()[config.CHOICE_MIC_HOST] if device["name"] == config.CHOICE_MIC_DEVICE][0], - config.INPUT_MIC_ENERGY_THRESHOLD, - config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD, - config.INPUT_MIC_RECORD_TIMEOUT, + device=device, + energy_threshold=config.INPUT_MIC_ENERGY_THRESHOLD, + dynamic_energy_threshold=config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD, + record_timeout=record_timeout, ) self.mic_audio_recorder.recordIntoQueue(mic_audio_queue) mic_transcriber = AudioTranscriber( speaker=False, source=self.mic_audio_recorder.source, - phrase_timeout=config.INPUT_MIC_PHRASE_TIMEOUT, + phrase_timeout=phase_timeout, max_phrases=config.INPUT_MIC_MAX_PHRASES, ) def sendMicTranscript(): @@ -274,17 +280,23 @@ class Model: def startSpeakerTranscript(self, fnc): spk_audio_queue = Queue() spk_device = [device for device in getOutputDevices() if device["name"] == config.CHOICE_SPEAKER_DEVICE][0] + + record_timeout = config.INPUT_SPEAKER_RECORD_TIMEOUT + phase_timeout = config.INPUT_SPEAKER_PHRASE_TIMEOUT + if record_timeout > phase_timeout: + record_timeout = phase_timeout + self.spk_audio_recorder = SelectedSpeakerRecorder( - spk_device, - config.INPUT_SPEAKER_ENERGY_THRESHOLD, - config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, - config.INPUT_SPEAKER_RECORD_TIMEOUT, + device=spk_device, + energy_threshold=config.INPUT_SPEAKER_ENERGY_THRESHOLD, + dynamic_energy_threshold=config.INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, + record_timeout=record_timeout, ) self.spk_audio_recorder.recordIntoQueue(spk_audio_queue) spk_transcriber = AudioTranscriber( speaker=True, source=self.spk_audio_recorder.source, - phrase_timeout=config.INPUT_SPEAKER_PHRASE_TIMEOUT, + phrase_timeout=phase_timeout, max_phrases=config.INPUT_SPEAKER_MAX_PHRASES, ) def sendSpkTranscript():