From 437d9eb64497af3e64de4d657e0893fbe5484ee7 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Thu, 12 Sep 2024 13:29:13 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F[remove]=20Model=20:=20XSO?= =?UTF-8?q?verlay=20=E3=81=AE=E6=A9=9F=E8=83=BD=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 12 ------ controller.py | 7 +-- model.py | 4 -- models/xsoverlay/notification.py | 73 -------------------------------- 4 files changed, 1 insertion(+), 95 deletions(-) delete mode 100644 models/xsoverlay/notification.py diff --git a/config.py b/config.py index 30964d58..687307a9 100644 --- a/config.py +++ b/config.py @@ -769,17 +769,6 @@ class Config: self._SEND_MESSAGE_BUTTON_TYPE = value saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) - @property - @json_serializable('ENABLE_NOTICE_XSOVERLAY') - def ENABLE_NOTICE_XSOVERLAY(self): - return self._ENABLE_NOTICE_XSOVERLAY - - @ENABLE_NOTICE_XSOVERLAY.setter - def ENABLE_NOTICE_XSOVERLAY(self, value): - if isinstance(value, bool): - self._ENABLE_NOTICE_XSOVERLAY = value - saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) - @property @json_serializable('OVERLAY_SETTINGS') def OVERLAY_SETTINGS(self): @@ -1113,7 +1102,6 @@ class Config: self._ENABLE_AUTO_CLEAR_MESSAGE_BOX = True self._ENABLE_SEND_ONLY_TRANSLATED_MESSAGES = False self._SEND_MESSAGE_BUTTON_TYPE = "show" - self._ENABLE_NOTICE_XSOVERLAY = False self._OVERLAY_SETTINGS = { "opacity": 1.0, "ui_scaling": 1.0, diff --git a/controller.py b/controller.py index ec46dbbe..c68e24be 100644 --- a/controller.py +++ b/controller.py @@ -158,10 +158,6 @@ def receiveSpeakerMessage(message): changeToCTranslate2Process() if config.ENABLE_TRANSCRIPTION_RECEIVE is True: - if config.ENABLE_NOTICE_XSOVERLAY is True: - xsoverlay_message = messageFormatter("RECEIVED", translation, message) - model.notificationXSOverlay(xsoverlay_message) - if config.ENABLE_OVERLAY_SMALL_LOG is True: if model.overlay.initialized is True: overlay_image = model.createOverlayImageShort(message, translation) @@ -917,8 +913,7 @@ def callbackSetSendMessageButtonType(value): view.changeMainWindowSendMessageButton(config.SEND_MESSAGE_BUTTON_TYPE) def callbackSetEnableNoticeXsoverlay(value): - print("callbackSetEnableNoticeXsoverlay", value) - config.ENABLE_NOTICE_XSOVERLAY = value + pass def callbackSetEnableAutoExportMessageLogs(value): print("callbackSetEnableAutoExportMessageLogs", value) diff --git a/model.py b/model.py index dddb056f..b49db777 100644 --- a/model.py +++ b/model.py @@ -21,7 +21,6 @@ from models.osc.osc_tools import sendTyping, sendMessage, receiveOscParameters, from models.transcription.transcription_recorder import SelectedMicEnergyAndAudioRecorder, SelectedSpeakerEnergyAndAudioRecorder from models.transcription.transcription_recorder import SelectedMicEnergyRecorder, SelectedSpeakerEnergyRecorder from models.transcription.transcription_transcriber import AudioTranscriber -from models.xsoverlay.notification import xsoverlayForVRCT from models.translation.translation_languages import translation_lang from models.transcription.transcription_languages import transcription_lang from models.translation.translation_utils import checkCTranslate2Weight @@ -671,9 +670,6 @@ class Model: self.speaker_energy_recorder.stop() self.speaker_energy_recorder = None - def notificationXSOverlay(self, message): - xsoverlayForVRCT(content=f"{message}") - def createOverlayImageShort(self, message, translation): your_language = config.TARGET_LANGUAGE target_language = config.SOURCE_LANGUAGE diff --git a/models/xsoverlay/notification.py b/models/xsoverlay/notification.py deleted file mode 100644 index cb2c03b5..00000000 --- a/models/xsoverlay/notification.py +++ /dev/null @@ -1,73 +0,0 @@ -# ########################################################################################################################### -# DOCUMENT:https://xiexe.github.io/XSOverlayDocumentation/#/NotificationsAPI -# SOURCE:https://zenn.dev/eeharumt/scraps/95f49a62dd809a -# messageType: int = 0 # 1: ポップアップ通知, 2: メディアプレーヤー情報 -# index: int = 0 # メディアプレーヤーでのみ使用され、手首のアイコンを変更する -# timeout: float = 0.5 # 通知インジケータが表示され続ける時間[秒] -# height: float = 175 # 通知インジケータの高さ -# opacity: float = 1 # 通知インジケータの透明度。0.0-1.0の範囲で低いほど透明に -# volume: float = 0.7 # 通知音の大きさ -# audioPath: str = "" # 通知音ファイルのパス。規定音として"default", "error", "warning"を指定可能。空文字列で通知音なしにできる。 -# title: str = "" # 通知タイトル、リッチテキストフォーマットをサポート。 -# content: str = "" # 通知内容、リッチテキストフォーマットをサポート。省略することで小サイズ通知となる。 -# useBase64Icon: bool = False # TrueにすることでBase64の画像を表示する -# icon: str = "" # Base64画像イメージまたは画像ファイルパス。規定アイコンとして"default", "error", or "warning"を指定可能 -# sourceApp: str = "" # 通知したアプリ名(デバック用) -# ########################################################################################################################## - -import socket -import json -import base64 -from os import path as os_path - -def XSOverlay( - endpoint:tuple=("127.0.0.1", 42069), messageType:int=1, index:int=0, timeout:float=2, - height:float=120.0, opacity:float=1.0, volume:float=0.0, audioPath:str="", - title:str="", content:str="", useBase64Icon:bool=False, icon:str="default", sourceApp:str="" -) -> int: - - if icon in ["default", "error", "warning"]: - icon_data = icon - elif useBase64Icon: - try: - with open(icon, "rb") as f: - icon_data_bytes = f.read() - icon_data = base64.b64encode(icon_data_bytes).decode("utf-8") - except Exception: - icon_data = "default" - else: - icon_data = icon - - sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - - data_msg = { - "messageType": messageType, - "index": index, - "timeout":timeout, - "height": height, - "opacity": opacity, - "volume": volume, - "audioPath": audioPath, - "title": title, - "content": content, - "useBase64Icon": useBase64Icon, - "icon": icon_data, - "sourceApp": sourceApp, - } - msg_str = json.dumps(data_msg) - response = sock.sendto(msg_str.encode("utf-8"), endpoint) - sock.close() - return response - -def xsoverlayForVRCT(content:str="") -> int: - response = XSOverlay( - title="VRCT", - content=content, - useBase64Icon=True, - icon=os_path.join(os_path.dirname(__file__), "img", "xsoverlay2.png"), - sourceApp="VRCT" - ) - return response - -if __name__ == "__main__": - xsoverlayForVRCT(content="notification test") \ No newline at end of file