From 494324fd8f82ecc1e53fce69ef7fbf4af8aeea5e Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sat, 30 Sep 2023 22:41:52 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Model:=20Mic?= =?UTF-8?q?=E3=82=82=E3=81=97=E3=81=8F=E3=81=AFSpeaker=E3=81=8C=E4=B8=80?= =?UTF-8?q?=E3=81=A4=E3=82=82=E6=8E=A5=E7=B6=9A=E3=81=95=E3=82=8C=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=AA=E3=81=84=E7=8A=B6=E6=85=8B=E3=81=A7=E3=83=87?= =?UTF-8?q?=E3=83=90=E3=82=A4=E3=82=B9=E6=83=85=E5=A0=B1=E3=82=92=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=81=97=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=ABNone?= =?UTF-8?q?=E3=81=AB=E3=81=AA=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/transcription/transcription_utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/models/transcription/transcription_utils.py b/models/transcription/transcription_utils.py index 4c72a8fa..522cb7a2 100644 --- a/models/transcription/transcription_utils.py +++ b/models/transcription/transcription_utils.py @@ -12,6 +12,8 @@ def getInputDevices(): devices[host["name"]].append(device) else: devices[host["name"]] = [device] + if len(devices) == 0: + devices = {"None": [{"name": "None"}]} return devices def getOutputDevices(): @@ -21,6 +23,8 @@ def getOutputDevices(): for device in p.get_loopback_device_info_generator(): if device["hostApi"] == wasapi_info["index"] and device["isLoopbackDevice"] is True: devices.append(device) + if len(devices) == 0: + devices = [{'name':"None"}] return devices def getDefaultInputDevice(): @@ -33,7 +37,8 @@ def getDefaultInputDevice(): for device_index in range(0, p. get_host_api_info_by_index(host_index)['deviceCount']): device = p.get_device_info_by_host_api_device_index(host_index, device_index) if device["index"] == defaultInputDevice: - return {"host":host, "device": device} + return {"host": host, "device": device} + return {"host": {"name": "None"}, "device": {"name": "None"}} def getDefaultOutputDevice(): with PyAudio() as p: @@ -49,4 +54,5 @@ def getDefaultOutputDevice(): for loopback in p.get_loopback_device_info_generator(): if default_speakers["name"] in loopback["name"]: default_device = loopback - return default_device \ No newline at end of file + return default_device + return {"name":"None"} \ No newline at end of file From 6c04d496c9a7bc5ed6cdaaced786510a23f45baf Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sat, 30 Sep 2023 22:51:23 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Model:=20Mic/Speaker?= =?UTF-8?q?=E3=81=AE=E3=83=87=E3=83=90=E3=82=A4=E3=82=B9=E3=81=8CNone?= =?UTF-8?q?=E3=81=AE=E5=A0=B4=E5=90=88=E3=81=ABTranscript=E3=82=82?= =?UTF-8?q?=E3=81=97=E3=81=8F=E3=81=AFCheckEnergy=E3=81=AE=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=83=95=E3=82=A7=E3=83=BC=E3=83=AB=E3=82=BB=E3=83=BC?= =?UTF-8?q?=E3=83=95=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/model.py b/model.py index 1bb20dbd..e398c3ba 100644 --- a/model.py +++ b/model.py @@ -253,6 +253,9 @@ class Model: return False def startMicTranscript(self, fnc): + if config.CHOICE_MIC_HOST == "None" or config.CHOICE_MIC_DEVICE == "None": + return + 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 @@ -294,6 +297,9 @@ class Model: self.mic_audio_recorder = None def startCheckMicEnergy(self, fnc): + if config.CHOICE_MIC_HOST == "None" or config.CHOICE_MIC_DEVICE == "None": + return + def sendMicEnergy(): if mic_energy_queue.empty() is False: energy = mic_energy_queue.get() @@ -320,6 +326,8 @@ class Model: self.mic_energy_recorder = None def startSpeakerTranscript(self, fnc): + if config.CHOICE_SPEAKER_DEVICE == "None": + return spk_audio_queue = Queue() spk_device = [device for device in getOutputDevices() if device["name"] == config.CHOICE_SPEAKER_DEVICE][0] @@ -362,6 +370,9 @@ class Model: self.spk_audio_recorder = None def startCheckSpeakerEnergy(self, fnc): + if config.CHOICE_SPEAKER_DEVICE == "None": + return + def sendSpeakerEnergy(): if speaker_energy_queue.empty() is False: energy = speaker_energy_queue.get()