From 033cece3a7e62776b3b5c106d21884bb54e1abd3 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sun, 15 Oct 2023 03:18:58 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Model=20:=20Auth=20k?= =?UTF-8?q?ey=E3=81=AE=E5=A0=B4=E5=90=88=E3=81=AB=E7=BF=BB=E8=A8=B3?= =?UTF-8?q?=E8=A8=80=E8=AA=9E=E8=A8=AD=E5=AE=9A=E3=81=8C=E5=9B=BD=E3=82=92?= =?UTF-8?q?=E5=90=AB=E3=82=81=E3=81=9F=E8=A8=80=E8=AA=9E=E8=A8=AD=E5=AE=9A?= =?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 --- model.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/model.py b/model.py index 7b148552..57343efe 100644 --- a/model.py +++ b/model.py @@ -150,6 +150,18 @@ class Model: def getInputTranslate(self, message): try: + if config.CHOICE_TRANSLATOR == "DeepL(auth)": + if config.TARGET_LANGUAGE == "English": + if config.TARGET_COUNTRY in ["United States", "Canada", "Philippines"]: + config.TARGET_LANGUAGE = "English American" + else: + config.TARGET_LANGUAGE = "English British" + elif config.TARGET_LANGUAGE in ["Portuguese"]: + if config.TARGET_COUNTRY == "Portugal": + config.TARGET_LANGUAGE = "Portuguese European" + else: + config.TARGET_LANGUAGE = "Portuguese Brazilian" + translation = self.translator.translate( translator_name=config.CHOICE_TRANSLATOR, source_language=config.SOURCE_LANGUAGE, @@ -162,6 +174,18 @@ class Model: def getOutputTranslate(self, message): try: + if config.CHOICE_TRANSLATOR == "DeepL(auth)": + if config.SOURCE_LANGUAGE == "English": + if config.SOURCE_COUNTRY in ["United States", "Canada", "Philippines"]: + config.SOURCE_LANGUAGE = "English American" + else: + config.SOURCE_LANGUAGE = "English British" + elif config.SOURCE_LANGUAGE in ["Portuguese"]: + if config.SOURCE_COUNTRY == "Portugal": + config.SOURCE_LANGUAGE = "Portuguese European" + else: + config.SOURCE_LANGUAGE = "Portuguese Brazilian" + translation = self.translator.translate( translator_name=config.CHOICE_TRANSLATOR, source_language=config.TARGET_LANGUAGE, From 39a63cb0e2d76cf629ba9f9da8670b412319db8e Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sun, 15 Oct 2023 03:38:06 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Controller=20:=20ENA?= =?UTF-8?q?BLE=5FSEND=5FMESSAGE=5FTO=5FVRC=E3=81=8CFalse=E3=81=AE=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=81=AB=E3=82=BF=E3=82=A4=E3=83=94=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E3=81=8C=E9=80=81=E4=BF=A1=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controller.py b/controller.py index bf8ee183..dab14af3 100644 --- a/controller.py +++ b/controller.py @@ -185,7 +185,10 @@ def messageBoxPressKeyEnter(e): sendChatMessage(message) def messageBoxPressKeyAny(e): - model.oscStartSendTyping() + if config.ENABLE_SEND_MESSAGE_TO_VRC is True: + model.oscStartSendTyping() + else: + model.oscStopSendTyping() # func select languages def initSetLanguageAndCountry(): From 5152b3679c988234a3901f1481697f5d5f817775 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sun, 15 Oct 2023 04:21:52 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[Refactor]=20Model=20=EF=BC=9A=20spk=20->?= =?UTF-8?q?=20speaker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/model.py b/model.py index 57343efe..9ba41389 100644 --- a/model.py +++ b/model.py @@ -66,8 +66,8 @@ class Model: self.mic_audio_recorder = None self.mic_energy_recorder = None self.mic_energy_plot_progressbar = None - self.spk_print_transcript = None - self.spk_audio_recorder = None + self.speaker_print_transcript = None + self.speaker_audio_recorder = None self.speaker_energy_recorder = None self.speaker_energy_plot_progressbar = None self.translator = Translator() @@ -394,46 +394,46 @@ class Model: def startSpeakerTranscript(self, fnc): if config.CHOICE_SPEAKER_DEVICE == "NoDevice": return - spk_audio_queue = Queue() - spk_device = [device for device in getOutputDevices() if device["name"] == config.CHOICE_SPEAKER_DEVICE][0] + speaker_audio_queue = Queue() + speaker_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( - device=spk_device, + self.speaker_audio_recorder = SelectedSpeakerRecorder( + device=speaker_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( + self.speaker_audio_recorder.recordIntoQueue(speaker_audio_queue) + speaker_transcriber = AudioTranscriber( speaker=True, - source=self.spk_audio_recorder.source, + source=self.speaker_audio_recorder.source, phrase_timeout=phase_timeout, max_phrases=config.INPUT_SPEAKER_MAX_PHRASES, ) - def sendSpkTranscript(): - spk_transcriber.transcribeAudioQueue(spk_audio_queue, config.TARGET_LANGUAGE, config.TARGET_COUNTRY) - message = spk_transcriber.getTranscript() + def sendSpeakerTranscript(): + speaker_transcriber.transcribeAudioQueue(speaker_audio_queue, config.TARGET_LANGUAGE, config.TARGET_COUNTRY) + message = speaker_transcriber.getTranscript() try: fnc(message) except: pass - self.spk_print_transcript = threadFnc(sendSpkTranscript) - self.spk_print_transcript.daemon = True - self.spk_print_transcript.start() + self.speaker_print_transcript = threadFnc(sendSpeakerTranscript) + self.speaker_print_transcript.daemon = True + self.speaker_print_transcript.start() def stopSpeakerTranscript(self): - if isinstance(self.spk_print_transcript, threadFnc): - self.spk_print_transcript.stop() - self.spk_print_transcript = None - if isinstance(self.spk_audio_recorder, SelectedSpeakerRecorder): - self.spk_audio_recorder.stop() - self.spk_audio_recorder = None + if isinstance(self.speaker_print_transcript, threadFnc): + self.speaker_print_transcript.stop() + self.speaker_print_transcript = None + if isinstance(self.speaker_audio_recorder, SelectedSpeakerRecorder): + self.speaker_audio_recorder.stop() + self.speaker_audio_recorder = None def startCheckSpeakerEnergy(self, fnc, end_fnc): if config.CHOICE_SPEAKER_DEVICE == "NoDevice": From 8e93080a8e9f3f95826c855c09ff4bd840dcdc3f Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sun, 15 Oct 2023 16:25:36 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Model=20:=20?= =?UTF-8?q?=E3=82=B9=E3=83=94=E3=83=BC=E3=82=AB=E3=83=BC=E3=83=87=E3=83=90?= =?UTF-8?q?=E3=82=A4=E3=82=B9=E3=81=AE=E5=8F=96=E5=BE=97=E3=82=BF=E3=82=A4?= =?UTF-8?q?=E3=83=9F=E3=83=B3=E3=82=B0=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config windowでのデバイス選択が不要になりました --- controller.py | 12 ++++++------ model.py | 14 +++++--------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/controller.py b/controller.py index dab14af3..df38e1ec 100644 --- a/controller.py +++ b/controller.py @@ -491,12 +491,12 @@ def callbackSetMicWordFilter(value): model.addKeywords() # Transcription Tab (Speaker) -def callbackSetSpeakerDevice(value): - print("callbackSetSpeakerDevice", value) - config.CHOICE_SPEAKER_DEVICE = value +# def callbackSetSpeakerDevice(value): +# print("callbackSetSpeakerDevice", value) +# config.CHOICE_SPEAKER_DEVICE = value - model.stopCheckSpeakerEnergy() - view.replaceSpeakerThresholdCheckButton_Passive() +# model.stopCheckSpeakerEnergy() +# view.replaceSpeakerThresholdCheckButton_Passive() def callbackSetSpeakerEnergyThreshold(value): print("callbackSetSpeakerEnergyThreshold", value) @@ -708,7 +708,7 @@ def createMainWindow(): "callback_set_mic_word_filter": callbackSetMicWordFilter, # Transcription Tab (Speaker) - "callback_set_speaker_device": callbackSetSpeakerDevice, + # "callback_set_speaker_device": callbackSetSpeakerDevice, "list_speaker_device": model.getListOutputDevice(), "callback_set_speaker_energy_threshold": callbackSetSpeakerEnergyThreshold, "callback_set_speaker_dynamic_energy_threshold": callbackSetSpeakerDynamicEnergyThreshold, diff --git a/model.py b/model.py index 9ba41389..93ad8882 100644 --- a/model.py +++ b/model.py @@ -13,6 +13,7 @@ from requests import get as requests_get import webbrowser from flashtext import KeywordProcessor +import pyaudiowpatch from models.translation.translation_translator import Translator from models.transcription.transcription_utils import getInputDevices, getOutputDevices, getDefaultInputDevice, getDefaultOutputDevice from models.osc.osc_tools import sendTyping, sendMessage, sendTestAction, receiveOscParameters @@ -311,13 +312,6 @@ class Model: def getListOutputDevice(): return [device["name"] for device in getOutputDevices()] - @staticmethod - def checkSpeakerStatus(choice=config.CHOICE_SPEAKER_DEVICE): - speaker_device = [device for device in getOutputDevices() if device["name"] == choice][0] - if getDefaultOutputDevice()["index"] == speaker_device["index"]: - return True - return False - def startMicTranscript(self, fnc): if config.CHOICE_MIC_HOST == "NoHost" or config.CHOICE_MIC_DEVICE == "NoDevice": return @@ -392,10 +386,11 @@ class Model: self.mic_energy_recorder = None def startSpeakerTranscript(self, fnc): + speaker_device = getDefaultOutputDevice() + config.CHOICE_SPEAKER_DEVICE = speaker_device["name"] if config.CHOICE_SPEAKER_DEVICE == "NoDevice": return speaker_audio_queue = Queue() - speaker_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 @@ -436,6 +431,8 @@ class Model: self.speaker_audio_recorder = None def startCheckSpeakerEnergy(self, fnc, end_fnc): + speaker_device = getDefaultOutputDevice() + config.CHOICE_SPEAKER_DEVICE = speaker_device["name"] if config.CHOICE_SPEAKER_DEVICE == "NoDevice": return @@ -448,7 +445,6 @@ class Model: pass # sleep(0.01) - speaker_device = [device for device in getOutputDevices() if device["name"] == config.CHOICE_SPEAKER_DEVICE][0] speaker_energy_queue = Queue() self.speaker_energy_recorder = SelectedSpeakeEnergyRecorder(speaker_device) self.speaker_energy_recorder.recordIntoQueue(speaker_energy_queue)