[Update] Config Window: Transcription (Speaker) Tab. Add Select Speaker Devices.

This commit is contained in:
Sakamoto Shiina
2024-04-07 11:56:39 +09:00
parent a9d0ca531e
commit 406d846b6b
6 changed files with 67 additions and 1 deletions

View File

@@ -704,6 +704,13 @@ def callbackDeleteMicWordFilter(value):
print("There was no the target word in config.INPUT_MIC_WORD_FILTER") print("There was no the target word in config.INPUT_MIC_WORD_FILTER")
# Transcription (Speaker) # Transcription (Speaker)
def callbackSetSpeakerDevice(value):
print("callbackSetSpeakerDevice", value)
config.CHOICE_SPEAKER_DEVICE = value
model.stopCheckSpeakerEnergy()
view.replaceSpeakerThresholdCheckButton_Passive()
def callbackSetSpeakerEnergyThreshold(value): def callbackSetSpeakerEnergyThreshold(value):
print("callbackSetSpeakerEnergyThreshold", value) print("callbackSetSpeakerEnergyThreshold", value)
if value == "": if value == "":
@@ -1046,6 +1053,8 @@ def createMainWindow(splash):
"callback_delete_mic_word_filter": callbackDeleteMicWordFilter, "callback_delete_mic_word_filter": callbackDeleteMicWordFilter,
# Transcription Tab (Speaker) # Transcription Tab (Speaker)
"callback_set_speaker_device": callbackSetSpeakerDevice,
"list_speaker_device": model.getListOutputDevice(),
"callback_set_speaker_energy_threshold": callbackSetSpeakerEnergyThreshold, "callback_set_speaker_energy_threshold": callbackSetSpeakerEnergyThreshold,
"callback_set_speaker_dynamic_energy_threshold": callbackSetSpeakerDynamicEnergyThreshold, "callback_set_speaker_dynamic_energy_threshold": callbackSetSpeakerDynamicEnergyThreshold,
"callback_check_speaker_threshold": callbackCheckSpeakerThreshold, "callback_check_speaker_threshold": callbackCheckSpeakerThreshold,

View File

@@ -168,6 +168,9 @@ config_window:
count_desc: "Current registered word count: %{count}" count_desc: "Current registered word count: %{count}"
speaker_device:
label: Speaker Device
speaker_dynamic_energy_threshold: speaker_dynamic_energy_threshold:
label_for_automatic: "Speaker Energy Threshold (Current Setting: Automatic)" label_for_automatic: "Speaker Energy Threshold (Current Setting: Automatic)"
desc_for_automatic: "Automatically determine speaker input sensitivity." desc_for_automatic: "Automatically determine speaker input sensitivity."

View File

@@ -167,6 +167,9 @@ config_window:
count_desc: "現在登録されている単語数: %{count}" count_desc: "現在登録されている単語数: %{count}"
speaker_device:
label: スピーカー (デバイス)
speaker_dynamic_energy_threshold: speaker_dynamic_energy_threshold:
label_for_automatic: "スピーカー入力感度の調整 (現在の設定: 自動)" label_for_automatic: "スピーカー入力感度の調整 (現在の設定: 自動)"
desc_for_automatic: スピーカーの入力感度を自動的に調節する。 desc_for_automatic: スピーカーの入力感度を自動的に調節する。

32
view.py
View File

@@ -358,6 +358,13 @@ class View():
# Transcription Tab (Speaker) # Transcription Tab (Speaker)
VAR_LABEL_SPEAKER_DEVICE=StringVar(value=i18n.t("config_window.speaker_device.label")),
VAR_DESC_SPEAKER_DEVICE=None,
LIST_SPEAKER_DEVICE=[],
CALLBACK_SET_SPEAKER_DEVICE=None,
VAR_SPEAKER_DEVICE=StringVar(value=config.CHOICE_SPEAKER_DEVICE),
VAR_LABEL_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=StringVar(value=""), VAR_LABEL_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=StringVar(value=""),
VAR_DESC_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=StringVar(value=""), VAR_DESC_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=StringVar(value=""),
CALLBACK_SET_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=None, CALLBACK_SET_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=None,
@@ -642,6 +649,9 @@ class View():
self.view_variable.CALLBACK_DELETE_MIC_WORD_FILTER=config_window_registers.get("callback_delete_mic_word_filter", None) self.view_variable.CALLBACK_DELETE_MIC_WORD_FILTER=config_window_registers.get("callback_delete_mic_word_filter", None)
# Transcription Tab (Speaker) # Transcription Tab (Speaker)
self.view_variable.CALLBACK_SET_SPEAKER_DEVICE = config_window_registers.get("callback_set_speaker_device", None)
config_window_registers.get("list_speaker_device", None) and self.updateList_SpeakerDevice(config_window_registers["list_speaker_device"])
self.view_variable.CALLBACK_SET_SPEAKER_ENERGY_THRESHOLD=config_window_registers.get("callback_set_speaker_energy_threshold", None) self.view_variable.CALLBACK_SET_SPEAKER_ENERGY_THRESHOLD=config_window_registers.get("callback_set_speaker_energy_threshold", None)
self.view_variable.CALLBACK_SET_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=config_window_registers.get("callback_set_speaker_dynamic_energy_threshold", None) self.view_variable.CALLBACK_SET_SPEAKER_DYNAMIC_ENERGY_THRESHOLD=config_window_registers.get("callback_set_speaker_dynamic_energy_threshold", None)
self.view_variable.CALLBACK_CHECK_SPEAKER_THRESHOLD=config_window_registers.get("callback_check_speaker_threshold", None) self.view_variable.CALLBACK_CHECK_SPEAKER_THRESHOLD=config_window_registers.get("callback_check_speaker_threshold", None)
@@ -708,6 +718,16 @@ class View():
) )
self.replaceMicThresholdCheckButton_Disabled() self.replaceMicThresholdCheckButton_Disabled()
if config.CHOICE_SPEAKER_DEVICE == "NoDevice":
self.view_variable.VAR_SPEAKER_DEVICE.set("No Speaker Device Detected")
vrct_gui._changeConfigWindowWidgetsStatus(
status="disabled",
target_names=[
"sb__optionmenu_speaker_device",
]
)
self.replaceSpeakerThresholdCheckButton_Disabled()
if config.USE_WHISPER_FEATURE is True: if config.USE_WHISPER_FEATURE is True:
self.openWhisperWeightTypeWidget() self.openWhisperWeightTypeWidget()
else: else:
@@ -1210,7 +1230,10 @@ class View():
def initSpeakerThresholdCheckButton(self): def initSpeakerThresholdCheckButton(self):
self.replaceSpeakerThresholdCheckButton_Passive() if config.CHOICE_SPEAKER_DEVICE == "NoDevice":
self.replaceSpeakerThresholdCheckButton_Disabled()
else:
self.replaceSpeakerThresholdCheckButton_Passive()
@staticmethod @staticmethod
def replaceSpeakerThresholdCheckButton_Active(): def replaceSpeakerThresholdCheckButton_Active():
@@ -1268,6 +1291,13 @@ class View():
vrct_gui.config_window.sb__progressbar_x_slider__progressbar_mic_energy_threshold.set(0) vrct_gui.config_window.sb__progressbar_x_slider__progressbar_mic_energy_threshold.set(0)
def updateList_SpeakerDevice(self, new_speaker_device_list:list):
self.view_variable.LIST_SPEAKER_DEVICE = new_speaker_device_list
vrct_gui.dropdown_menu_window.updateDropdownMenuValues(
dropdown_menu_widget_id="sb__optionmenu_speaker_device",
dropdown_menu_values=new_speaker_device_list,
)
def updateSetProgressBar_SpeakerEnergy(self, new_speaker_energy): def updateSetProgressBar_SpeakerEnergy(self, new_speaker_energy):
self.updateProgressBar( self.updateProgressBar(
target_progressbar_widget=vrct_gui.config_window.sb__progressbar_x_slider__progressbar_speaker_energy_threshold, target_progressbar_widget=vrct_gui.config_window.sb__progressbar_x_slider__progressbar_speaker_energy_threshold,

View File

@@ -43,6 +43,12 @@ def _changeConfigWindowWidgetsStatus(config_window, settings, view_variable, sta
disableLabelsWidgets(target_widget) disableLabelsWidgets(target_widget)
disableOptionmenuWidget(target_widget) disableOptionmenuWidget(target_widget)
case "sb__optionmenu_speaker_device":
if status == "disabled":
target_widget = config_window.sb__widgets["sb__optionmenu_speaker_device"]
disableLabelsWidgets(target_widget)
disableOptionmenuWidget(target_widget)
case "sb__optionmenu_appearance_theme": case "sb__optionmenu_appearance_theme":
if status == "disabled": if status == "disabled":
target_widget = config_window.sb__widgets["sb__optionmenu_appearance_theme"] target_widget = config_window.sb__widgets["sb__optionmenu_appearance_theme"]

View File

@@ -4,6 +4,7 @@ from .._SettingBoxGenerator import _SettingBoxGenerator
def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_variable): def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_variable):
sbg = _SettingBoxGenerator(setting_box_wrapper, config_window, settings, view_variable) sbg = _SettingBoxGenerator(setting_box_wrapper, config_window, settings, view_variable)
createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu
createSettingBoxSwitch = sbg.createSettingBoxSwitch createSettingBoxSwitch = sbg.createSettingBoxSwitch
createSettingBoxProgressbarXSlider = sbg.createSettingBoxProgressbarXSlider createSettingBoxProgressbarXSlider = sbg.createSettingBoxProgressbarXSlider
createSettingBoxEntry = sbg.createSettingBoxEntry createSettingBoxEntry = sbg.createSettingBoxEntry
@@ -13,6 +14,9 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_
callFunctionIfCallable(view_variable.CALLBACK_CHECK_SPEAKER_THRESHOLD, is_turned_on) callFunctionIfCallable(view_variable.CALLBACK_CHECK_SPEAKER_THRESHOLD, is_turned_on)
def optionmenuInputSpeakerDeviceCallback(value):
callFunctionIfCallable(view_variable.CALLBACK_SET_SPEAKER_DEVICE, value)
def sliderInputSpeakerEnergyThresholdCallback(value): def sliderInputSpeakerEnergyThresholdCallback(value):
callFunctionIfCallable(view_variable.CALLBACK_SET_SPEAKER_ENERGY_THRESHOLD, value) callFunctionIfCallable(view_variable.CALLBACK_SET_SPEAKER_ENERGY_THRESHOLD, value)
@@ -32,6 +36,17 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_
row=0 row=0
config_window.sb__speaker_device = createSettingBoxDropdownMenu(
for_var_label_text=view_variable.VAR_LABEL_SPEAKER_DEVICE,
for_var_desc_text=view_variable.VAR_DESC_SPEAKER_DEVICE,
optionmenu_attr_name="sb__optionmenu_speaker_device",
dropdown_menu_values=view_variable.LIST_SPEAKER_DEVICE,
command=lambda value: optionmenuInputSpeakerDeviceCallback(value),
variable=view_variable.VAR_SPEAKER_DEVICE,
)
config_window.sb__speaker_device.grid(row=row)
row+=1
config_window.sb__speaker_dynamic_energy_threshold = createSettingBoxSwitch( config_window.sb__speaker_dynamic_energy_threshold = createSettingBoxSwitch(
for_var_label_text=view_variable.VAR_LABEL_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, for_var_label_text=view_variable.VAR_LABEL_SPEAKER_DYNAMIC_ENERGY_THRESHOLD,
for_var_desc_text=view_variable.VAR_DESC_SPEAKER_DYNAMIC_ENERGY_THRESHOLD, for_var_desc_text=view_variable.VAR_DESC_SPEAKER_DYNAMIC_ENERGY_THRESHOLD,