Merge branch 'checkbox_transcripton_receive' into UI_2.0
This commit is contained in:
74
main.py
74
main.py
@@ -3,7 +3,7 @@ from vrct_gui import vrct_gui
|
||||
from config import config
|
||||
from model import model
|
||||
|
||||
# func transcription
|
||||
# func transcription send message
|
||||
def sendMicMessage(message):
|
||||
if len(message) > 0:
|
||||
translation = ""
|
||||
@@ -13,29 +13,59 @@ def sendMicMessage(message):
|
||||
elif config.ENABLE_TRANSLATION is False:
|
||||
pass
|
||||
elif model.getTranslatorStatus() is False:
|
||||
pass
|
||||
logAuthenticationError()
|
||||
else:
|
||||
translation = model.getInputTranslate(message)
|
||||
|
||||
if config.ENABLE_OSC is True:
|
||||
osc_message = config.MESSAGE_FORMAT.replace("[message]", message)
|
||||
osc_message = osc_message.replace("[translation]", translation)
|
||||
model.oscSendMessage(osc_message)
|
||||
else:
|
||||
logOSCError()
|
||||
logTranscriptionSendMessage(message, translation)
|
||||
if config.ENABLE_TRANSCRIPTION_SEND is True:
|
||||
if config.ENABLE_OSC is True:
|
||||
osc_message = config.MESSAGE_FORMAT.replace("[message]", message)
|
||||
osc_message = osc_message.replace("[translation]", translation)
|
||||
model.oscSendMessage(osc_message)
|
||||
else:
|
||||
logOSCError()
|
||||
|
||||
logTranscriptionSendMessage(message, translation)
|
||||
|
||||
def startTranscriptionSendMessage():
|
||||
model.startMicTranscript(sendMicMessage)
|
||||
vrct_gui.changeMainWindowWidgetsStatus("normal", "All")
|
||||
|
||||
def stopTranscriptionSendMessage():
|
||||
model.stopMicTranscript()
|
||||
vrct_gui.changeMainWindowWidgetsStatus("normal", "All")
|
||||
|
||||
# func transcription receive message
|
||||
def receiveSpeakerMessage(message):
|
||||
if len(message) > 0:
|
||||
translation = ""
|
||||
if config.ENABLE_TRANSLATION is False:
|
||||
pass
|
||||
elif model.getTranslatorStatus() is False:
|
||||
logAuthenticationError()
|
||||
else:
|
||||
translation = model.getOutputTranslate(message)
|
||||
|
||||
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
|
||||
if config.ENABLE_NOTICE_XSOVERLAY is True:
|
||||
xsoverlay_message = config.MESSAGE_FORMAT.replace("[message]", message)
|
||||
xsoverlay_message = xsoverlay_message.replace("[translation]", translation)
|
||||
model.notificationXSOverlay(xsoverlay_message)
|
||||
logTranscriptionReceiveMessage(message, translation)
|
||||
|
||||
def startTranscriptionReceiveMessage():
|
||||
model.startSpeakerTranscript(receiveSpeakerMessage)
|
||||
vrct_gui.changeMainWindowWidgetsStatus("normal", "All")
|
||||
|
||||
def stopTranscriptionReceiveMessage():
|
||||
model.stopSpeakerTranscript()
|
||||
vrct_gui.changeMainWindowWidgetsStatus("normal", "All")
|
||||
|
||||
# func print textbox
|
||||
def logTranslationStatusChange():
|
||||
textbox_all = getattr(vrct_gui, "textbox_all")
|
||||
textbox_system = getattr(vrct_gui, "textbox_system")
|
||||
if config.ENABLE_TRANSLATION:
|
||||
if config.ENABLE_TRANSLATION is True:
|
||||
vrct_gui.printToTextbox(textbox_all, "翻訳機能をONにしました", "", "INFO")
|
||||
vrct_gui.printToTextbox(textbox_system, "翻訳機能をONにしました", "", "INFO")
|
||||
else:
|
||||
@@ -45,7 +75,7 @@ def logTranslationStatusChange():
|
||||
def logTranscriptionSendStatusChange():
|
||||
textbox_all = getattr(vrct_gui, "textbox_all")
|
||||
textbox_system = getattr(vrct_gui, "textbox_system")
|
||||
if config.ENABLE_TRANSCRIPTION_SEND:
|
||||
if config.ENABLE_TRANSCRIPTION_SEND is True:
|
||||
vrct_gui.printToTextbox(textbox_all, "Voice2chatbox機能をONにしました", "", "INFO")
|
||||
vrct_gui.printToTextbox(textbox_system, "Voice2chatbox機能をONにしました", "", "INFO")
|
||||
else:
|
||||
@@ -58,6 +88,12 @@ def logTranscriptionSendMessage(message, translate):
|
||||
vrct_gui.printToTextbox(textbox_all, message, translate, "SEND")
|
||||
vrct_gui.printToTextbox(textbox_sent, message, translate, "SEND")
|
||||
|
||||
def logTranscriptionReceiveMessage(message, translate):
|
||||
textbox_all = getattr(vrct_gui, "textbox_all")
|
||||
textbox_sent = getattr(vrct_gui, "textbox_received")
|
||||
vrct_gui.printToTextbox(textbox_all, message, translate, "RECEIVE")
|
||||
vrct_gui.printToTextbox(textbox_sent, message, translate, "RECEIVE")
|
||||
|
||||
def logDetectWordFilter(message):
|
||||
textbox_all = getattr(vrct_gui, "textbox_all")
|
||||
textbox_system = getattr(vrct_gui, "textbox_system")
|
||||
@@ -82,6 +118,7 @@ def toggleTranslationFeature():
|
||||
logTranslationStatusChange()
|
||||
|
||||
def toggleTranscriptionSendFeature():
|
||||
vrct_gui.changeMainWindowWidgetsStatus("disabled", "All")
|
||||
config.ENABLE_TRANSCRIPTION_SEND = getattr(vrct_gui, "transcription_send_switch_box").get()
|
||||
if config.ENABLE_TRANSCRIPTION_SEND is True:
|
||||
th_startTranscriptionSendMessage = Thread(target=startTranscriptionSendMessage)
|
||||
@@ -93,6 +130,19 @@ def toggleTranscriptionSendFeature():
|
||||
th_stopTranscriptionSendMessage.start()
|
||||
logTranscriptionSendStatusChange()
|
||||
|
||||
def toggleTranscriptionReceiveFeature():
|
||||
vrct_gui.changeMainWindowWidgetsStatus("disabled", "All")
|
||||
config.ENABLE_TRANSCRIPTION_RECEIVE = getattr(vrct_gui, "transcription_receive_switch_box").get()
|
||||
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
|
||||
th_startTranscriptionReceiveMessage = Thread(target=startTranscriptionReceiveMessage)
|
||||
th_startTranscriptionReceiveMessage.daemon = True
|
||||
th_startTranscriptionReceiveMessage.start()
|
||||
else:
|
||||
th_stopTranscriptionReceiveMessage = Thread(target=stopTranscriptionReceiveMessage)
|
||||
th_stopTranscriptionReceiveMessage.daemon = True
|
||||
th_stopTranscriptionReceiveMessage.start()
|
||||
logTranscriptionSendStatusChange()
|
||||
|
||||
# create GUI
|
||||
vrct_gui.createGUI()
|
||||
|
||||
@@ -115,6 +165,8 @@ translation_switch_box = getattr(vrct_gui, "translation_switch_box")
|
||||
translation_switch_box.configure(command=toggleTranslationFeature)
|
||||
transcription_send_switch_box = getattr(vrct_gui, "transcription_send_switch_box")
|
||||
transcription_send_switch_box.configure(command=toggleTranscriptionSendFeature)
|
||||
transcription_receive_switch_box = getattr(vrct_gui, "transcription_receive_switch_box")
|
||||
transcription_receive_switch_box.configure(command=toggleTranscriptionReceiveFeature)
|
||||
|
||||
if __name__ == "__main__":
|
||||
vrct_gui.startMainLoop()
|
||||
Reference in New Issue
Block a user