Merge branch 'bugfix#20_poposuke' into develop

This commit is contained in:
misygauziya
2023-07-21 17:10:02 +09:00
2 changed files with 77 additions and 52 deletions

27
VRCT.py
View File

@@ -508,22 +508,16 @@ class App(CTk):
self.checkbox_transcription_receive.configure(state="normal") self.checkbox_transcription_receive.configure(state="normal")
def checkbox_transcription_send_callback(self): def checkbox_transcription_send_callback(self):
self.checkbox_transcription_send.configure(state="disabled")
self.checkbox_transcription_receive.configure(state="disabled")
self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"])
self.update()
self.ENABLE_TRANSCRIPTION_SEND = self.checkbox_transcription_send.get() self.ENABLE_TRANSCRIPTION_SEND = self.checkbox_transcription_send.get()
if self.ENABLE_TRANSCRIPTION_SEND is True: if self.ENABLE_TRANSCRIPTION_SEND is True:
self.checkbox_transcription_send.configure(state="disabled")
self.checkbox_transcription_receive.configure(state="disabled")
self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"])
self.update()
th_transcription_send_start = Thread(target=self.transcription_send_start) th_transcription_send_start = Thread(target=self.transcription_send_start)
th_transcription_send_start.daemon = True th_transcription_send_start.daemon = True
th_transcription_send_start.start() th_transcription_send_start.start()
else: else:
self.checkbox_transcription_send.configure(state="disabled")
self.checkbox_transcription_receive.configure(state="disabled")
self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"])
self.update()
th_transcription_send_stop = Thread(target=self.transcription_send_stop) th_transcription_send_stop = Thread(target=self.transcription_send_stop)
th_transcription_send_stop.daemon = True th_transcription_send_stop.daemon = True
th_transcription_send_stop.start() th_transcription_send_stop.start()
@@ -599,21 +593,16 @@ class App(CTk):
self.checkbox_transcription_receive.configure(state="normal") self.checkbox_transcription_receive.configure(state="normal")
def checkbox_transcription_receive_callback(self): def checkbox_transcription_receive_callback(self):
self.checkbox_transcription_send.configure(state="disabled")
self.checkbox_transcription_receive.configure(state="disabled")
self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"])
self.update()
self.ENABLE_TRANSCRIPTION_RECEIVE = self.checkbox_transcription_receive.get() self.ENABLE_TRANSCRIPTION_RECEIVE = self.checkbox_transcription_receive.get()
if self.ENABLE_TRANSCRIPTION_RECEIVE is True: if self.ENABLE_TRANSCRIPTION_RECEIVE is True:
self.checkbox_transcription_send.configure(state="disabled")
self.checkbox_transcription_receive.configure(state="disabled")
self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"])
self.update()
th_transcription_receive_start = Thread(target=self.transcription_receive_start) th_transcription_receive_start = Thread(target=self.transcription_receive_start)
th_transcription_receive_start.daemon = True th_transcription_receive_start.daemon = True
th_transcription_receive_start.start() th_transcription_receive_start.start()
else: else:
self.checkbox_transcription_send.configure(state="disabled")
self.checkbox_transcription_receive.configure(state="disabled")
self.button_config.configure(state="disabled", fg_color=["gray92", "gray14"])
self.update()
th_transcription_receive_stop = Thread(target=self.transcription_receive_stop) th_transcription_receive_stop = Thread(target=self.transcription_receive_stop)
th_transcription_receive_stop.daemon = True th_transcription_receive_stop.daemon = True
th_transcription_receive_stop.start() th_transcription_receive_stop.start()

View File

@@ -7,6 +7,7 @@ import customtkinter
from customtkinter import CTkToplevel, CTkTabview, CTkFont, CTkLabel, CTkSlider, CTkOptionMenu, StringVar, CTkEntry, CTkCheckBox, CTkProgressBar from customtkinter import CTkToplevel, CTkTabview, CTkFont, CTkLabel, CTkSlider, CTkOptionMenu, StringVar, CTkEntry, CTkCheckBox, CTkProgressBar
from flashtext import KeywordProcessor from flashtext import KeywordProcessor
from threading import Thread
from utils import save_json, print_textbox, thread_fnc, get_localized_text, get_key_by_value, widget_config_window_label_setter from utils import save_json, print_textbox, thread_fnc, get_localized_text, get_key_by_value, widget_config_window_label_setter
from audio_utils import get_input_device_list, get_output_device_list, get_default_output_device from audio_utils import get_input_device_list, get_output_device_list, get_default_output_device
from audio_recorder import SelectedMicEnergyRecorder, SelectedSpeakeEnergyRecorder from audio_recorder import SelectedMicEnergyRecorder, SelectedSpeakeEnergyRecorder
@@ -306,21 +307,38 @@ class ToplevelWindowConfig(CTkToplevel):
pass pass
sleep(0.01) sleep(0.01)
def mic_threshold_check_start(self):
self.mic_energy_queue = Queue()
mic_device = [device for device in get_input_device_list()[self.parent.CHOICE_MIC_HOST] if device["name"] == self.parent.CHOICE_MIC_DEVICE][0]
self.mic_energy_recorder = SelectedMicEnergyRecorder(mic_device)
self.mic_energy_recorder.record_into_queue(self.mic_energy_queue)
self.mic_energy_plot_progressbar = thread_fnc(self.progressBar_input_mic_energy_plot)
self.mic_energy_plot_progressbar.daemon = True
self.mic_energy_plot_progressbar.start()
self.checkbox_input_mic_threshold_check.configure(state="normal")
self.checkbox_input_speaker_threshold_check.configure(state="normal")
def mic_threshold_check_stop(self):
if self.mic_energy_recorder != None:
self.mic_energy_recorder.stop()
if self.mic_energy_plot_progressbar != None:
self.mic_energy_plot_progressbar.stop()
self.progressBar_input_mic_energy_threshold.set(0)
self.checkbox_input_mic_threshold_check.configure(state="normal")
self.checkbox_input_speaker_threshold_check.configure(state="normal")
def checkbox_input_mic_threshold_check_callback(self): def checkbox_input_mic_threshold_check_callback(self):
self.checkbox_input_mic_threshold_check.configure(state="disabled")
self.checkbox_input_speaker_threshold_check.configure(state="disabled")
self.update()
if self.checkbox_input_mic_threshold_check.get(): if self.checkbox_input_mic_threshold_check.get():
self.mic_energy_queue = Queue() th_mic_threshold_check_start = Thread(target=self.mic_threshold_check_start)
mic_device = [device for device in get_input_device_list()[self.parent.CHOICE_MIC_HOST] if device["name"] == self.parent.CHOICE_MIC_DEVICE][0] th_mic_threshold_check_start.daemon = True
self.mic_energy_recorder = SelectedMicEnergyRecorder(mic_device) th_mic_threshold_check_start.start()
self.mic_energy_recorder.record_into_queue(self.mic_energy_queue)
self.mic_energy_plot_progressbar = thread_fnc(self.progressBar_input_mic_energy_plot)
self.mic_energy_plot_progressbar.daemon = True
self.mic_energy_plot_progressbar.start()
else: else:
if self.mic_energy_recorder != None: th_mic_threshold_check_stop = Thread(target=self.mic_threshold_check_stop)
self.mic_energy_recorder.stop() th_mic_threshold_check_stop.daemon = True
if self.mic_energy_plot_progressbar != None: th_mic_threshold_check_stop.start()
self.mic_energy_plot_progressbar.stop()
self.progressBar_input_mic_energy_threshold.set(0)
def slider_input_mic_energy_threshold_callback(self, value): def slider_input_mic_energy_threshold_callback(self, value):
self.parent.INPUT_MIC_ENERGY_THRESHOLD = int(value) self.parent.INPUT_MIC_ENERGY_THRESHOLD = int(value)
@@ -387,29 +405,47 @@ class ToplevelWindowConfig(CTkToplevel):
energy = self.speaker_energy_recorder.recorder.listen_energy(source) energy = self.speaker_energy_recorder.recorder.listen_energy(source)
self.speaker_energy_queue.put(energy) self.speaker_energy_queue.put(energy)
def checkbox_input_speaker_threshold_check_callback(self): def speaker_threshold_check_start(self):
if self.checkbox_input_speaker_threshold_check.get(): speaker_device = [device for device in get_output_device_list() if device["name"] == self.parent.CHOICE_SPEAKER_DEVICE][0]
self.speaker_energy_queue = Queue()
speaker_device = [device for device in get_output_device_list() if device["name"] == self.parent.CHOICE_SPEAKER_DEVICE][0]
if get_default_output_device()["index"] == speaker_device["index"]: if get_default_output_device()["index"] == speaker_device["index"]:
self.speaker_energy_recorder = SelectedSpeakeEnergyRecorder(speaker_device) self.speaker_energy_queue = Queue()
self.speaker_energy_get_progressbar = thread_fnc(self.progressBar_input_speaker_energy_get) self.speaker_energy_recorder = SelectedSpeakeEnergyRecorder(speaker_device)
self.speaker_energy_get_progressbar.daemon = True self.speaker_energy_get_progressbar = thread_fnc(self.progressBar_input_speaker_energy_get)
self.speaker_energy_get_progressbar.start() self.speaker_energy_get_progressbar.daemon = True
self.speaker_energy_plot_progressbar = thread_fnc(self.progressBar_input_speaker_energy_plot) self.speaker_energy_get_progressbar.start()
self.speaker_energy_plot_progressbar.daemon = True self.speaker_energy_plot_progressbar = thread_fnc(self.progressBar_input_speaker_energy_plot)
self.speaker_energy_plot_progressbar.start() self.speaker_energy_plot_progressbar.daemon = True
else: self.speaker_energy_plot_progressbar.start()
print_textbox(self.parent.textbox_message_log, "Windows playback device and selected device do not match. Change the Windows playback device.", "ERROR")
print_textbox(self.parent.textbox_message_system_log, "Windows playback device and selected device do not match. Change the Windows playback device.", "ERROR")
self.checkbox_input_speaker_threshold_check.deselect()
else: else:
if self.speaker_energy_get_progressbar != None: print_textbox(self.parent.textbox_message_log, "Windows playback device and selected device do not match. Change the Windows playback device.", "ERROR")
self.speaker_energy_get_progressbar.stop() print_textbox(self.parent.textbox_message_system_log, "Windows playback device and selected device do not match. Change the Windows playback device.", "ERROR")
if self.speaker_energy_plot_progressbar != None: self.checkbox_input_speaker_threshold_check.deselect()
self.speaker_energy_plot_progressbar.stop() self.checkbox_input_mic_threshold_check.configure(state="normal")
self.progressBar_input_speaker_energy_threshold.set(0) self.checkbox_input_speaker_threshold_check.configure(state="normal")
def speaker_threshold_check_stop(self):
if self.speaker_energy_get_progressbar != None:
self.speaker_energy_get_progressbar.stop()
if self.speaker_energy_plot_progressbar != None:
self.speaker_energy_plot_progressbar.stop()
self.progressBar_input_speaker_energy_threshold.set(0)
self.checkbox_input_mic_threshold_check.configure(state="normal")
self.checkbox_input_speaker_threshold_check.configure(state="normal")
def checkbox_input_speaker_threshold_check_callback(self):
self.checkbox_input_mic_threshold_check.configure(state="disabled")
self.checkbox_input_speaker_threshold_check.configure(state="disabled")
self.update()
if self.checkbox_input_speaker_threshold_check.get():
th_speaker_threshold_check_start = Thread(target=self.speaker_threshold_check_start)
th_speaker_threshold_check_start.daemon = True
th_speaker_threshold_check_start.start()
else:
th_speaker_threshold_check_stop = Thread(target=self.speaker_threshold_check_stop)
th_speaker_threshold_check_stop.daemon = True
th_speaker_threshold_check_stop.start()
def slider_input_speaker_energy_threshold_callback(self, value): def slider_input_speaker_energy_threshold_callback(self, value):
self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD = int(value) self.parent.INPUT_SPEAKER_ENERGY_THRESHOLD = int(value)