Merge branch 'model' into for_webui

This commit is contained in:
misyaguziya
2024-09-02 22:01:28 +09:00
2 changed files with 13 additions and 42 deletions

View File

@@ -157,24 +157,19 @@ def startTranscriptionSendMessage(action:Callable[[dict], None]) -> None:
mic_message = MicMessage(action)
model.startMicTranscript(mic_message.send)
def stopTranscriptionSendMessage(action:Callable[[dict], None]) -> None:
def stopTranscriptionSendMessage() -> None:
model.stopMicTranscript()
action("mic", {
"status":200,
"result":{
"message":"Stopped sending messages"
}
})
def startThreadingTranscriptionSendMessage(action:Callable[[dict], None]) -> None:
th_startTranscriptionSendMessage = Thread(target=startTranscriptionSendMessage, args=(action,))
th_startTranscriptionSendMessage.daemon = True
th_startTranscriptionSendMessage.start()
def stopThreadingTranscriptionSendMessage(action:Callable[[dict], None]) -> None:
th_stopTranscriptionSendMessage = Thread(target=stopTranscriptionSendMessage, args=(action,))
def stopThreadingTranscriptionSendMessage() -> None:
th_stopTranscriptionSendMessage = Thread(target=stopTranscriptionSendMessage)
th_stopTranscriptionSendMessage.daemon = True
th_stopTranscriptionSendMessage.start()
th_stopTranscriptionSendMessage.join()
def startTranscriptionSendMessageOnCloseConfigWindow(action:Callable[[dict], None]) -> None:
mic_message = MicMessage(action)
@@ -256,24 +251,19 @@ def startTranscriptionReceiveMessage(action:Callable[[dict], None]) -> None:
speaker_message = SpeakerMessage(action)
model.startSpeakerTranscript(speaker_message.receive)
def stopTranscriptionReceiveMessage(action:Callable[[dict], None]) -> None:
def stopTranscriptionReceiveMessage() -> None:
model.stopSpeakerTranscript()
action("speaker", {
"status":200,
"result": {
"message":"Stopped receiving messages"
}
})
def startThreadingTranscriptionReceiveMessage(action:Callable[[dict], None]) -> None:
th_startTranscriptionReceiveMessage = Thread(target=startTranscriptionReceiveMessage, args=(action,))
th_startTranscriptionReceiveMessage.daemon = True
th_startTranscriptionReceiveMessage.start()
def stopThreadingTranscriptionReceiveMessage(action:Callable[[dict], None]) -> None:
th_stopTranscriptionReceiveMessage = Thread(target=stopTranscriptionReceiveMessage, args=(action,))
def stopThreadingTranscriptionReceiveMessage() -> None:
th_stopTranscriptionReceiveMessage = Thread(target=stopTranscriptionReceiveMessage)
th_stopTranscriptionReceiveMessage.daemon = True
th_stopTranscriptionReceiveMessage.start()
th_stopTranscriptionReceiveMessage.join()
def startTranscriptionReceiveMessageOnCloseConfigWindow(action:Callable[[dict], None]) -> None:
speaker_message = SpeakerMessage(action)
@@ -364,15 +354,6 @@ def callbackMessageBoxTypingStop(*args, **kwargs) -> dict:
model.oscStopSendTyping()
return {"status":200}
def messageBoxFocusIn(e):
# view.foregroundOffIfForegroundEnabled()
pass
def messageBoxFocusOut(e):
# view.foregroundOnIfForegroundEnabled()
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
model.oscStopSendTyping()
# def addSentMessageLog(sent_message):
# config.SENT_MESSAGES_LOG.append(sent_message)
# config.CURRENT_SENT_MESSAGES_LOG_INDEX = len(config.SENT_MESSAGES_LOG)
@@ -531,10 +512,10 @@ def callbackEnableTranscriptionSend(data, action, *args, **kwargs) -> dict:
startThreadingTranscriptionSendMessage(action)
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND}
def callbackDisableTranscriptionSend(data, action, *args, **kwargs) -> dict:
def callbackDisableTranscriptionSend(*args, **kwargs) -> dict:
printLog("Disable Transcription Send")
config.ENABLE_TRANSCRIPTION_SEND = False
stopThreadingTranscriptionSendMessage(action)
stopThreadingTranscriptionSendMessage()
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_SEND}
def callbackEnableTranscriptionReceive(data, action, *args, **kwargs) -> dict:
@@ -547,10 +528,10 @@ def callbackEnableTranscriptionReceive(data, action, *args, **kwargs) -> dict:
model.startOverlay()
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE}
def callbackDisableTranscriptionReceive(data, action, *args, **kwargs) -> dict:
def callbackDisableTranscriptionReceive(*args, **kwargs) -> dict:
printLog("Disable Transcription Receive")
config.ENABLE_TRANSCRIPTION_RECEIVE = False
stopThreadingTranscriptionReceiveMessage(action)
stopThreadingTranscriptionReceiveMessage()
return {"status":200, "result":config.ENABLE_TRANSCRIPTION_RECEIVE}
def callbackEnableForeground(*args, **kwargs) -> dict:
@@ -770,11 +751,7 @@ def callbackSetMicDevice(data, *args, **kwargs) -> dict:
printLog("Set Mic Device", data)
config.CHOICE_MIC_DEVICE = data
model.stopCheckMicEnergy()
return {"status":200,
"result":{
"host":config.CHOICE_MIC_HOST,
},
}
return {"status":200, "result":config.CHOICE_MIC_DEVICE}
def callbackSetMicEnergyThreshold(data, *args, **kwargs) -> dict:
printLog("Set Mic Energy Threshold", data)

View File

@@ -212,17 +212,11 @@ action_mapping = {
"error_translation_engine":"/action/error_translation_engine",
"word_filter":"/action/word_filter",
},
"/controller/callback_disable_transcription_send": {
"mic":"/action/transcription_send_mic_message_stopped"
},
"/controller/callback_enable_transcription_receive": {
"speaker":"/action/transcription_receive_speaker_message",
"error_device":"/action/error_device",
"error_translation_engine":"/action/error_translation_engine",
},
"/controller/callback_disable_transcription_receive": {
"speaker":"/action/transcription_receive_speaker_message_stopped"
},
"/controller/callback_enable_check_mic_threshold": {
"mic":"/action/check_mic_threshold_energy",
"stopped":"/action/check_mic_threshold_energy_stopped",