Controllerクラスの設定メソッドを修正し、重複した設定を防止する条件を追加。テストケースを更新し、ON/OFF状態のランダムアクセスと連続テストを強化。

This commit is contained in:
misyaguziya
2025-09-23 16:56:11 +09:00
parent 1689a45e3e
commit a4656a5081
2 changed files with 179 additions and 105 deletions

View File

@@ -795,24 +795,28 @@ class Controller:
@staticmethod @staticmethod
def setEnableTranslation(*args, **kwargs) -> dict: def setEnableTranslation(*args, **kwargs) -> dict:
if model.isLoadedCTranslate2Model() is False: if config.ENABLE_TRANSLATION is False:
model.changeTranslatorCTranslate2Model() if model.isLoadedCTranslate2Model() is False:
config.ENABLE_TRANSLATION = True model.changeTranslatorCTranslate2Model()
config.ENABLE_TRANSLATION = True
return {"status":200, "result":config.ENABLE_TRANSLATION} return {"status":200, "result":config.ENABLE_TRANSLATION}
@staticmethod @staticmethod
def setDisableTranslation(*args, **kwargs) -> dict: def setDisableTranslation(*args, **kwargs) -> dict:
config.ENABLE_TRANSLATION = False if config.ENABLE_TRANSLATION is True:
config.ENABLE_TRANSLATION = False
return {"status":200, "result":config.ENABLE_TRANSLATION} return {"status":200, "result":config.ENABLE_TRANSLATION}
@staticmethod @staticmethod
def setEnableForeground(*args, **kwargs) -> dict: def setEnableForeground(*args, **kwargs) -> dict:
config.ENABLE_FOREGROUND = True if config.ENABLE_FOREGROUND is False:
config.ENABLE_FOREGROUND = True
return {"status":200, "result":config.ENABLE_FOREGROUND} return {"status":200, "result":config.ENABLE_FOREGROUND}
@staticmethod @staticmethod
def setDisableForeground(*args, **kwargs) -> dict: def setDisableForeground(*args, **kwargs) -> dict:
config.ENABLE_FOREGROUND = False if config.ENABLE_FOREGROUND is True:
config.ENABLE_FOREGROUND = False
return {"status":200, "result":config.ENABLE_FOREGROUND} return {"status":200, "result":config.ENABLE_FOREGROUND}
@staticmethod @staticmethod
@@ -906,12 +910,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableConvertMessageToRomaji(*args, **kwargs) -> dict: def setEnableConvertMessageToRomaji(*args, **kwargs) -> dict:
config.CONVERT_MESSAGE_TO_ROMAJI = True if config.CONVERT_MESSAGE_TO_ROMAJI is False:
config.CONVERT_MESSAGE_TO_ROMAJI = True
return {"status":200, "result":config.CONVERT_MESSAGE_TO_ROMAJI} return {"status":200, "result":config.CONVERT_MESSAGE_TO_ROMAJI}
@staticmethod @staticmethod
def setDisableConvertMessageToRomaji(*args, **kwargs) -> dict: def setDisableConvertMessageToRomaji(*args, **kwargs) -> dict:
config.CONVERT_MESSAGE_TO_ROMAJI = False if config.CONVERT_MESSAGE_TO_ROMAJI is True:
config.CONVERT_MESSAGE_TO_ROMAJI = False
return {"status":200, "result":config.CONVERT_MESSAGE_TO_ROMAJI} return {"status":200, "result":config.CONVERT_MESSAGE_TO_ROMAJI}
@staticmethod @staticmethod
@@ -920,12 +926,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableConvertMessageToHiragana(*args, **kwargs) -> dict: def setEnableConvertMessageToHiragana(*args, **kwargs) -> dict:
config.CONVERT_MESSAGE_TO_HIRAGANA = True if config.CONVERT_MESSAGE_TO_HIRAGANA is False:
config.CONVERT_MESSAGE_TO_HIRAGANA = True
return {"status":200, "result":config.CONVERT_MESSAGE_TO_HIRAGANA} return {"status":200, "result":config.CONVERT_MESSAGE_TO_HIRAGANA}
@staticmethod @staticmethod
def setDisableConvertMessageToHiragana(*args, **kwargs) -> dict: def setDisableConvertMessageToHiragana(*args, **kwargs) -> dict:
config.CONVERT_MESSAGE_TO_HIRAGANA = False if config.CONVERT_MESSAGE_TO_HIRAGANA is True:
config.CONVERT_MESSAGE_TO_HIRAGANA = False
return {"status":200, "result":config.CONVERT_MESSAGE_TO_HIRAGANA} return {"status":200, "result":config.CONVERT_MESSAGE_TO_HIRAGANA}
@staticmethod @staticmethod
@@ -934,12 +942,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableMainWindowSidebarCompactMode(*args, **kwargs) -> dict: def setEnableMainWindowSidebarCompactMode(*args, **kwargs) -> dict:
config.MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True if config.MAIN_WINDOW_SIDEBAR_COMPACT_MODE is False:
config.MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True
return {"status":200, "result":config.MAIN_WINDOW_SIDEBAR_COMPACT_MODE} return {"status":200, "result":config.MAIN_WINDOW_SIDEBAR_COMPACT_MODE}
@staticmethod @staticmethod
def setDisableMainWindowSidebarCompactMode(*args, **kwargs) -> dict: def setDisableMainWindowSidebarCompactMode(*args, **kwargs) -> dict:
config.MAIN_WINDOW_SIDEBAR_COMPACT_MODE = False if config.MAIN_WINDOW_SIDEBAR_COMPACT_MODE is True:
config.MAIN_WINDOW_SIDEBAR_COMPACT_MODE = False
return {"status":200, "result":config.MAIN_WINDOW_SIDEBAR_COMPACT_MODE} return {"status":200, "result":config.MAIN_WINDOW_SIDEBAR_COMPACT_MODE}
@staticmethod @staticmethod
@@ -993,12 +1003,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableShowResendButton(*args, **kwargs) -> dict: def setEnableShowResendButton(*args, **kwargs) -> dict:
config.SHOW_RESEND_BUTTON = True if not config.SHOW_RESEND_BUTTON:
config.SHOW_RESEND_BUTTON = True
return {"status":200, "result":config.SHOW_RESEND_BUTTON} return {"status":200, "result":config.SHOW_RESEND_BUTTON}
@staticmethod @staticmethod
def setDisableShowResendButton(*args, **kwargs) -> dict: def setDisableShowResendButton(*args, **kwargs) -> dict:
config.SHOW_RESEND_BUTTON = False if config.SHOW_RESEND_BUTTON is True:
config.SHOW_RESEND_BUTTON = False
return {"status":200, "result":config.SHOW_RESEND_BUTTON} return {"status":200, "result":config.SHOW_RESEND_BUTTON}
@staticmethod @staticmethod
@@ -1033,19 +1045,21 @@ class Controller:
return {"status":200, "result":config.AUTO_MIC_SELECT} return {"status":200, "result":config.AUTO_MIC_SELECT}
def setEnableAutoMicSelect(self, *args, **kwargs) -> dict: def setEnableAutoMicSelect(self, *args, **kwargs) -> dict:
config.AUTO_MIC_SELECT = True if config.AUTO_MIC_SELECT is False:
device_manager.setCallbackProcessBeforeUpdateDevices(self.stopAccessDevices) device_manager.setCallbackProcessBeforeUpdateDevices(self.stopAccessDevices)
device_manager.setCallbackDefaultMicDevice(self.updateSelectedMicDevice) device_manager.setCallbackDefaultMicDevice(self.updateSelectedMicDevice)
device_manager.setCallbackProcessAfterUpdateDevices(self.restartAccessDevices) device_manager.setCallbackProcessAfterUpdateDevices(self.restartAccessDevices)
device_manager.forceUpdateAndSetMicDevices() device_manager.forceUpdateAndSetMicDevices()
config.AUTO_MIC_SELECT = True
return {"status":200, "result":config.AUTO_MIC_SELECT} return {"status":200, "result":config.AUTO_MIC_SELECT}
@staticmethod @staticmethod
def setDisableAutoMicSelect(*args, **kwargs) -> dict: def setDisableAutoMicSelect(*args, **kwargs) -> dict:
device_manager.clearCallbackProcessBeforeUpdateDevices() if config.AUTO_MIC_SELECT is True:
device_manager.clearCallbackDefaultMicDevice() device_manager.clearCallbackProcessBeforeUpdateDevices()
device_manager.clearCallbackProcessAfterUpdateDevices() device_manager.clearCallbackDefaultMicDevice()
config.AUTO_MIC_SELECT = False device_manager.clearCallbackProcessAfterUpdateDevices()
config.AUTO_MIC_SELECT = False
return {"status":200, "result":config.AUTO_MIC_SELECT} return {"status":200, "result":config.AUTO_MIC_SELECT}
@staticmethod @staticmethod
@@ -1108,12 +1122,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableMicAutomaticThreshold(*args, **kwargs) -> dict: def setEnableMicAutomaticThreshold(*args, **kwargs) -> dict:
config.MIC_AUTOMATIC_THRESHOLD = True if config.MIC_AUTOMATIC_THRESHOLD is False:
config.MIC_AUTOMATIC_THRESHOLD = True
return {"status":200, "result":config.MIC_AUTOMATIC_THRESHOLD} return {"status":200, "result":config.MIC_AUTOMATIC_THRESHOLD}
@staticmethod @staticmethod
def setDisableMicAutomaticThreshold(*args, **kwargs) -> dict: def setDisableMicAutomaticThreshold(*args, **kwargs) -> dict:
config.MIC_AUTOMATIC_THRESHOLD = False if config.MIC_AUTOMATIC_THRESHOLD is True:
config.MIC_AUTOMATIC_THRESHOLD = False
return {"status":200, "result":config.MIC_AUTOMATIC_THRESHOLD} return {"status":200, "result":config.MIC_AUTOMATIC_THRESHOLD}
@staticmethod @staticmethod
@@ -1226,20 +1242,21 @@ class Controller:
return {"status":200, "result":config.AUTO_SPEAKER_SELECT} return {"status":200, "result":config.AUTO_SPEAKER_SELECT}
def setEnableAutoSpeakerSelect(self, *args, **kwargs) -> dict: def setEnableAutoSpeakerSelect(self, *args, **kwargs) -> dict:
config.AUTO_SPEAKER_SELECT = True if config.AUTO_SPEAKER_SELECT is False:
device_manager.setCallbackProcessBeforeUpdateDevices(self.stopAccessDevices) device_manager.setCallbackProcessBeforeUpdateDevices(self.stopAccessDevices)
device_manager.setCallbackDefaultSpeakerDevice(self.updateSelectedSpeakerDevice) device_manager.setCallbackDefaultSpeakerDevice(self.updateSelectedSpeakerDevice)
device_manager.setCallbackProcessAfterUpdateDevices(self.restartAccessDevices) device_manager.setCallbackProcessAfterUpdateDevices(self.restartAccessDevices)
device_manager.forceUpdateAndSetSpeakerDevices() device_manager.forceUpdateAndSetSpeakerDevices()
config.AUTO_SPEAKER_SELECT = True
return {"status":200, "result":config.AUTO_SPEAKER_SELECT} return {"status":200, "result":config.AUTO_SPEAKER_SELECT}
@staticmethod @staticmethod
def setDisableAutoSpeakerSelect(*args, **kwargs) -> dict: def setDisableAutoSpeakerSelect(*args, **kwargs) -> dict:
device_manager.clearCallbackProcessBeforeUpdateDevices() if config.AUTO_SPEAKER_SELECT is True:
device_manager.clearCallbackDefaultSpeakerDevice() device_manager.clearCallbackProcessBeforeUpdateDevices()
device_manager.clearCallbackProcessAfterUpdateDevices() device_manager.clearCallbackDefaultSpeakerDevice()
config.AUTO_SPEAKER_SELECT = False device_manager.clearCallbackProcessAfterUpdateDevices()
config.AUTO_SPEAKER_SELECT = False
return {"status":200, "result":config.AUTO_SPEAKER_SELECT} return {"status":200, "result":config.AUTO_SPEAKER_SELECT}
@staticmethod @staticmethod
@@ -1285,12 +1302,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableSpeakerAutomaticThreshold(*args, **kwargs) -> dict: def setEnableSpeakerAutomaticThreshold(*args, **kwargs) -> dict:
config.SPEAKER_AUTOMATIC_THRESHOLD = True if config.SPEAKER_AUTOMATIC_THRESHOLD is False:
config.SPEAKER_AUTOMATIC_THRESHOLD = True
return {"status":200, "result":config.SPEAKER_AUTOMATIC_THRESHOLD} return {"status":200, "result":config.SPEAKER_AUTOMATIC_THRESHOLD}
@staticmethod @staticmethod
def setDisableSpeakerAutomaticThreshold(*args, **kwargs) -> dict: def setDisableSpeakerAutomaticThreshold(*args, **kwargs) -> dict:
config.SPEAKER_AUTOMATIC_THRESHOLD = False if config.SPEAKER_AUTOMATIC_THRESHOLD is True:
config.SPEAKER_AUTOMATIC_THRESHOLD = False
return {"status":200, "result":config.SPEAKER_AUTOMATIC_THRESHOLD} return {"status":200, "result":config.SPEAKER_AUTOMATIC_THRESHOLD}
@staticmethod @staticmethod
@@ -1459,12 +1478,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableNotificationVrcSfx(*args, **kwargs) -> dict: def setEnableNotificationVrcSfx(*args, **kwargs) -> dict:
config.NOTIFICATION_VRC_SFX = True if config.NOTIFICATION_VRC_SFX is False:
config.NOTIFICATION_VRC_SFX = True
return {"status":200, "result":config.NOTIFICATION_VRC_SFX} return {"status":200, "result":config.NOTIFICATION_VRC_SFX}
@staticmethod @staticmethod
def setDisableNotificationVrcSfx(*args, **kwargs) -> dict: def setDisableNotificationVrcSfx(*args, **kwargs) -> dict:
config.NOTIFICATION_VRC_SFX = False if config.NOTIFICATION_VRC_SFX is True:
config.NOTIFICATION_VRC_SFX = False
return {"status":200, "result":config.NOTIFICATION_VRC_SFX} return {"status":200, "result":config.NOTIFICATION_VRC_SFX}
@staticmethod @staticmethod
@@ -1571,12 +1592,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableAutoClearMessageBox(*args, **kwargs) -> dict: def setEnableAutoClearMessageBox(*args, **kwargs) -> dict:
config.AUTO_CLEAR_MESSAGE_BOX = True if config.AUTO_CLEAR_MESSAGE_BOX is False:
config.AUTO_CLEAR_MESSAGE_BOX = True
return {"status":200, "result":config.AUTO_CLEAR_MESSAGE_BOX} return {"status":200, "result":config.AUTO_CLEAR_MESSAGE_BOX}
@staticmethod @staticmethod
def setDisableAutoClearMessageBox(*args, **kwargs) -> dict: def setDisableAutoClearMessageBox(*args, **kwargs) -> dict:
config.AUTO_CLEAR_MESSAGE_BOX = False if config.AUTO_CLEAR_MESSAGE_BOX is True:
config.AUTO_CLEAR_MESSAGE_BOX = False
return {"status":200, "result":config.AUTO_CLEAR_MESSAGE_BOX} return {"status":200, "result":config.AUTO_CLEAR_MESSAGE_BOX}
@staticmethod @staticmethod
@@ -1585,12 +1608,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableSendOnlyTranslatedMessages(*args, **kwargs) -> dict: def setEnableSendOnlyTranslatedMessages(*args, **kwargs) -> dict:
config.SEND_ONLY_TRANSLATED_MESSAGES = True if config.SEND_ONLY_TRANSLATED_MESSAGES is False:
config.SEND_ONLY_TRANSLATED_MESSAGES = True
return {"status":200, "result":config.SEND_ONLY_TRANSLATED_MESSAGES} return {"status":200, "result":config.SEND_ONLY_TRANSLATED_MESSAGES}
@staticmethod @staticmethod
def setDisableSendOnlyTranslatedMessages(*args, **kwargs) -> dict: def setDisableSendOnlyTranslatedMessages(*args, **kwargs) -> dict:
config.SEND_ONLY_TRANSLATED_MESSAGES = False if config.SEND_ONLY_TRANSLATED_MESSAGES is True:
config.SEND_ONLY_TRANSLATED_MESSAGES = False
return {"status":200, "result":config.SEND_ONLY_TRANSLATED_MESSAGES} return {"status":200, "result":config.SEND_ONLY_TRANSLATED_MESSAGES}
@staticmethod @staticmethod
@@ -1599,17 +1624,19 @@ class Controller:
@staticmethod @staticmethod
def setEnableOverlaySmallLog(*args, **kwargs) -> dict: def setEnableOverlaySmallLog(*args, **kwargs) -> dict:
config.OVERLAY_SMALL_LOG = True if config.OVERLAY_SMALL_LOG is False:
if config.OVERLAY_LARGE_LOG is False: if config.OVERLAY_LARGE_LOG is False:
model.startOverlay() model.startOverlay()
config.OVERLAY_SMALL_LOG = True
return {"status":200, "result":config.OVERLAY_SMALL_LOG} return {"status":200, "result":config.OVERLAY_SMALL_LOG}
@staticmethod @staticmethod
def setDisableOverlaySmallLog(*args, **kwargs) -> dict: def setDisableOverlaySmallLog(*args, **kwargs) -> dict:
config.OVERLAY_SMALL_LOG = False if config.OVERLAY_SMALL_LOG is True:
model.clearOverlayImageSmallLog() model.clearOverlayImageSmallLog()
if config.OVERLAY_LARGE_LOG is False: if config.OVERLAY_LARGE_LOG is False:
model.shutdownOverlay() model.shutdownOverlay()
config.OVERLAY_SMALL_LOG = False
return {"status":200, "result":config.OVERLAY_SMALL_LOG} return {"status":200, "result":config.OVERLAY_SMALL_LOG}
@staticmethod @staticmethod
@@ -1628,17 +1655,19 @@ class Controller:
@staticmethod @staticmethod
def setEnableOverlayLargeLog(*args, **kwargs) -> dict: def setEnableOverlayLargeLog(*args, **kwargs) -> dict:
config.OVERLAY_LARGE_LOG = True if config.OVERLAY_LARGE_LOG is False:
if config.OVERLAY_SMALL_LOG is False: if config.OVERLAY_SMALL_LOG is False:
model.startOverlay() model.startOverlay()
config.OVERLAY_LARGE_LOG = True
return {"status":200, "result":config.OVERLAY_LARGE_LOG} return {"status":200, "result":config.OVERLAY_LARGE_LOG}
@staticmethod @staticmethod
def setDisableOverlayLargeLog(*args, **kwargs) -> dict: def setDisableOverlayLargeLog(*args, **kwargs) -> dict:
config.OVERLAY_LARGE_LOG = False if config.OVERLAY_LARGE_LOG is True:
model.clearOverlayImageLargeLog() model.clearOverlayImageLargeLog()
if config.OVERLAY_SMALL_LOG is False: if config.OVERLAY_SMALL_LOG is False:
model.shutdownOverlay() model.shutdownOverlay()
config.OVERLAY_LARGE_LOG = False
return {"status":200, "result":config.OVERLAY_LARGE_LOG} return {"status":200, "result":config.OVERLAY_LARGE_LOG}
@staticmethod @staticmethod
@@ -1657,12 +1686,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableOverlayShowOnlyTranslatedMessages(*args, **kwargs) -> dict: def setEnableOverlayShowOnlyTranslatedMessages(*args, **kwargs) -> dict:
config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = True if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES is False:
config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = True
return {"status":200, "result":config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES} return {"status":200, "result":config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES}
@staticmethod @staticmethod
def setDisableOverlayShowOnlyTranslatedMessages(*args, **kwargs) -> dict: def setDisableOverlayShowOnlyTranslatedMessages(*args, **kwargs) -> dict:
config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = False if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES is True:
config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = False
return {"status":200, "result":config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES} return {"status":200, "result":config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES}
@staticmethod @staticmethod
@@ -1671,12 +1702,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableSendMessageToVrc(*args, **kwargs) -> dict: def setEnableSendMessageToVrc(*args, **kwargs) -> dict:
config.SEND_MESSAGE_TO_VRC = True if config.SEND_MESSAGE_TO_VRC is False:
config.SEND_MESSAGE_TO_VRC = True
return {"status":200, "result":config.SEND_MESSAGE_TO_VRC} return {"status":200, "result":config.SEND_MESSAGE_TO_VRC}
@staticmethod @staticmethod
def setDisableSendMessageToVrc(*args, **kwargs) -> dict: def setDisableSendMessageToVrc(*args, **kwargs) -> dict:
config.SEND_MESSAGE_TO_VRC = False if config.SEND_MESSAGE_TO_VRC is True:
config.SEND_MESSAGE_TO_VRC = False
return {"status":200, "result":config.SEND_MESSAGE_TO_VRC} return {"status":200, "result":config.SEND_MESSAGE_TO_VRC}
@staticmethod @staticmethod
@@ -1685,12 +1718,14 @@ class Controller:
@staticmethod @staticmethod
def setEnableSendReceivedMessageToVrc(*args, **kwargs) -> dict: def setEnableSendReceivedMessageToVrc(*args, **kwargs) -> dict:
config.SEND_RECEIVED_MESSAGE_TO_VRC = True if config.SEND_RECEIVED_MESSAGE_TO_VRC is False:
config.SEND_RECEIVED_MESSAGE_TO_VRC = True
return {"status":200, "result":config.SEND_RECEIVED_MESSAGE_TO_VRC} return {"status":200, "result":config.SEND_RECEIVED_MESSAGE_TO_VRC}
@staticmethod @staticmethod
def setDisableSendReceivedMessageToVrc(*args, **kwargs) -> dict: def setDisableSendReceivedMessageToVrc(*args, **kwargs) -> dict:
config.SEND_RECEIVED_MESSAGE_TO_VRC = False if config.SEND_RECEIVED_MESSAGE_TO_VRC is True:
config.SEND_RECEIVED_MESSAGE_TO_VRC = False
return {"status":200, "result":config.SEND_RECEIVED_MESSAGE_TO_VRC} return {"status":200, "result":config.SEND_RECEIVED_MESSAGE_TO_VRC}
@staticmethod @staticmethod
@@ -1717,45 +1752,53 @@ class Controller:
@staticmethod @staticmethod
def setEnableVrcMicMuteSync(*args, **kwargs) -> dict: def setEnableVrcMicMuteSync(*args, **kwargs) -> dict:
if model.getIsOscQueryEnabled() is True: if config.VRC_MIC_MUTE_SYNC is False:
config.VRC_MIC_MUTE_SYNC = True if model.getIsOscQueryEnabled() is True:
model.setMuteSelfStatus() config.VRC_MIC_MUTE_SYNC = True
model.changeMicTranscriptStatus() model.setMuteSelfStatus()
response = {"status":200, "result":config.VRC_MIC_MUTE_SYNC} model.changeMicTranscriptStatus()
response = {"status":200, "result":config.VRC_MIC_MUTE_SYNC}
else:
response = {
"status":400,
"result":{
"message":"Cannot enable VRC mic mute sync while OSC query is disabled",
"data": config.VRC_MIC_MUTE_SYNC
}
}
else: else:
response = { response = {"status":200, "result":config.VRC_MIC_MUTE_SYNC}
"status":400,
"result":{
"message":"Cannot enable VRC mic mute sync while OSC query is disabled",
"data": config.VRC_MIC_MUTE_SYNC
}
}
return response return response
@staticmethod @staticmethod
def setDisableVrcMicMuteSync(*args, **kwargs) -> dict: def setDisableVrcMicMuteSync(*args, **kwargs) -> dict:
config.VRC_MIC_MUTE_SYNC = False if config.VRC_MIC_MUTE_SYNC is True:
model.changeMicTranscriptStatus() config.VRC_MIC_MUTE_SYNC = False
model.changeMicTranscriptStatus()
return {"status":200, "result":config.VRC_MIC_MUTE_SYNC} return {"status":200, "result":config.VRC_MIC_MUTE_SYNC}
def setEnableCheckSpeakerThreshold(self, *args, **kwargs) -> dict: def setEnableCheckSpeakerThreshold(self, *args, **kwargs) -> dict:
self.startThreadingCheckSpeakerEnergy() if config.ENABLE_CHECK_ENERGY_RECEIVE is False:
config.ENABLE_CHECK_ENERGY_RECEIVE = True self.startThreadingCheckSpeakerEnergy()
config.ENABLE_CHECK_ENERGY_RECEIVE = True
return {"status":200, "result":config.ENABLE_CHECK_ENERGY_RECEIVE} return {"status":200, "result":config.ENABLE_CHECK_ENERGY_RECEIVE}
def setDisableCheckSpeakerThreshold(self, *args, **kwargs) -> dict: def setDisableCheckSpeakerThreshold(self, *args, **kwargs) -> dict:
self.stopThreadingCheckSpeakerEnergy() if config.ENABLE_CHECK_ENERGY_RECEIVE is True:
config.ENABLE_CHECK_ENERGY_RECEIVE = False self.stopThreadingCheckSpeakerEnergy()
config.ENABLE_CHECK_ENERGY_RECEIVE = False
return {"status":200, "result":config.ENABLE_CHECK_ENERGY_RECEIVE} return {"status":200, "result":config.ENABLE_CHECK_ENERGY_RECEIVE}
def setEnableCheckMicThreshold(self, *args, **kwargs) -> dict: def setEnableCheckMicThreshold(self, *args, **kwargs) -> dict:
self.startThreadingCheckMicEnergy() if config.ENABLE_CHECK_ENERGY_SEND is False:
config.ENABLE_CHECK_ENERGY_SEND = True self.startThreadingCheckMicEnergy()
config.ENABLE_CHECK_ENERGY_SEND = True
return {"status":200, "result":config.ENABLE_CHECK_ENERGY_SEND} return {"status":200, "result":config.ENABLE_CHECK_ENERGY_SEND}
def setDisableCheckMicThreshold(self, *args, **kwargs) -> dict: def setDisableCheckMicThreshold(self, *args, **kwargs) -> dict:
self.stopThreadingCheckMicEnergy() if config.ENABLE_CHECK_ENERGY_SEND is True:
config.ENABLE_CHECK_ENERGY_SEND = False self.stopThreadingCheckMicEnergy()
config.ENABLE_CHECK_ENERGY_SEND = False
return {"status":200, "result":config.ENABLE_CHECK_ENERGY_SEND} return {"status":200, "result":config.ENABLE_CHECK_ENERGY_SEND}
@staticmethod @staticmethod
@@ -1769,23 +1812,27 @@ class Controller:
return {"status":200, "result":True} return {"status":200, "result":True}
def setEnableTranscriptionSend(self, *args, **kwargs) -> dict: def setEnableTranscriptionSend(self, *args, **kwargs) -> dict:
self.startThreadingTranscriptionSendMessage() if config.ENABLE_TRANSCRIPTION_SEND is False:
config.ENABLE_TRANSCRIPTION_SEND = True self.startThreadingTranscriptionSendMessage()
config.ENABLE_TRANSCRIPTION_SEND = True
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND} return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND}
def setDisableTranscriptionSend(self, *args, **kwargs) -> dict: def setDisableTranscriptionSend(self, *args, **kwargs) -> dict:
self.stopThreadingTranscriptionSendMessage() if config.ENABLE_TRANSCRIPTION_SEND is True:
config.ENABLE_TRANSCRIPTION_SEND = False self.stopThreadingTranscriptionSendMessage()
config.ENABLE_TRANSCRIPTION_SEND = False
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND} return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND}
def setEnableTranscriptionReceive(self, *args, **kwargs) -> dict: def setEnableTranscriptionReceive(self, *args, **kwargs) -> dict:
self.startThreadingTranscriptionReceiveMessage() if config.ENABLE_TRANSCRIPTION_RECEIVE is False:
config.ENABLE_TRANSCRIPTION_RECEIVE = True self.startThreadingTranscriptionReceiveMessage()
config.ENABLE_TRANSCRIPTION_RECEIVE = True
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE} return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE}
def setDisableTranscriptionReceive(self, *args, **kwargs) -> dict: def setDisableTranscriptionReceive(self, *args, **kwargs) -> dict:
self.stopThreadingTranscriptionReceiveMessage() if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
config.ENABLE_TRANSCRIPTION_RECEIVE = False self.stopThreadingTranscriptionReceiveMessage()
config.ENABLE_TRANSCRIPTION_RECEIVE = False
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE} return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE}
def sendMessageBox(self, data, *args, **kwargs) -> dict: def sendMessageBox(self, data, *args, **kwargs) -> dict:

View File

@@ -73,18 +73,18 @@ class TestMainloop():
"/set/disable/convert_message_to_romaji", "/set/disable/convert_message_to_romaji",
"/set/enable/convert_message_to_hiragana", "/set/enable/convert_message_to_hiragana",
"/set/disable/convert_message_to_hiragana", "/set/disable/convert_message_to_hiragana",
# "/set/enable/auto_mic_select", "/set/enable/auto_mic_select",
# "/set/disable/auto_mic_select", "/set/disable/auto_mic_select",
"/set/enable/mic_automatic_threshold", "/set/enable/mic_automatic_threshold",
"/set/disable/mic_automatic_threshold", "/set/disable/mic_automatic_threshold",
# "/set/enable/check_mic_threshold", "/set/enable/check_mic_threshold",
# "/set/disable/check_mic_threshold", "/set/disable/check_mic_threshold",
# "/set/enable/auto_speaker_select", "/set/enable/auto_speaker_select",
# "/set/disable/auto_speaker_select", "/set/disable/auto_speaker_select",
"/set/enable/speaker_automatic_threshold", "/set/enable/speaker_automatic_threshold",
"/set/disable/speaker_automatic_threshold", "/set/disable/speaker_automatic_threshold",
# "/set/enable/check_speaker_threshold", "/set/enable/check_speaker_threshold",
# "/set/disable/check_speaker_threshold", "/set/disable/check_speaker_threshold",
"/set/enable/overlay_small_log", "/set/enable/overlay_small_log",
"/set/disable/overlay_small_log", "/set/disable/overlay_small_log",
"/set/enable/overlay_large_log", "/set/enable/overlay_large_log",
@@ -251,12 +251,26 @@ class TestMainloop():
print(f"\t -> {Color.RED}[ERROR]{Color.RESET} Status: {status}, Result: {result}, Expected: {expected_result}") print(f"\t -> {Color.RED}[ERROR]{Color.RESET} Status: {status}, Result: {result}, Expected: {expected_result}")
pprint.pprint(self.config_dict) pprint.pprint(self.config_dict)
break break
time.sleep(0.2)
# 最後にすべてOFFにして終了
for endpoint in self.validity_endpoints:
if endpoint.startswith("/set/disable/"):
result, status = self.main.handleRequest(endpoint, None)
time.sleep(0.2)
print("----ON/OFFでのランダムアクセスのテスト終了----") print("----ON/OFFでのランダムアクセスのテスト終了----")
def test_endpoints_continuous(self): def test_endpoints_on_off_continuous(self):
print("----連続テスト----") print("----連続テスト----")
# endpoints = ["/set/enable/websocket_server", "/set/disable/websocket_server"] # endpoints = ["/set/enable/websocket_server", "/set/disable/websocket_server"]
endpoints = ["/set/enable/transcription_receive", "/set/disable/transcription_receive"] endpoints = [
"/set/enable/translation",
"/set/disable/translation",
"/set/enable/transcription_send",
"/set/disable/transcription_send",
"/set/enable/transcription_receive",
"/set/disable/transcription_receive",
]
for i in range(1000): for i in range(1000):
endpoint = random.choice(endpoints) endpoint = random.choice(endpoints)
print(f"No.{i:04} Testing endpoint: {endpoint}", end="", flush=True) print(f"No.{i:04} Testing endpoint: {endpoint}", end="", flush=True)
@@ -280,8 +294,21 @@ class TestMainloop():
print(f"\t -> {Color.RED}[ERROR]{Color.RESET} Status: {status}, Result: {result}, Expected: {expected_result}") print(f"\t -> {Color.RED}[ERROR]{Color.RESET} Status: {status}, Result: {result}, Expected: {expected_result}")
pprint.pprint(self.config_dict) pprint.pprint(self.config_dict)
break break
time.sleep(0.2)
# 最後にすべてOFFにして終了
for endpoint in self.validity_endpoints:
if endpoint.startswith("/set/disable/"):
result, status = self.main.handleRequest(endpoint, None)
time.sleep(0.2)
print("----連続テスト終了----") print("----連続テスト終了----")
if __name__ == "__main__": if __name__ == "__main__":
test = TestMainloop() try:
test.test_endpoints_continuous() test = TestMainloop()
test.test_endpoints_on_off_random()
# test.test_endpoints_continuous()
except KeyboardInterrupt:
print("Interrupted by user, shutting down...")
except Exception as e:
print(f"An error occurred: {e}")