Merge branch 'config_window' into UI_2.0
This commit is contained in:
@@ -11,12 +11,6 @@ class ConfigWindow(CTkToplevel):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.withdraw()
|
self.withdraw()
|
||||||
|
|
||||||
self.INPUT_MIC_RECORD_TIMEOUT = 3
|
|
||||||
self.INPUT_SOURCE_LANG = "aaaaaaaaa"
|
|
||||||
self.INPUT_SPEAKER_ENERGY_THRESHOLD = 300
|
|
||||||
self.MAX_SPEAKER_ENERGY_THRESHOLD = 4000
|
|
||||||
self.INPUT_MIC_PHRASE_TIMEOUT = 3
|
|
||||||
|
|
||||||
|
|
||||||
# configure window
|
# configure window
|
||||||
self.title("test config_window.py")
|
self.title("test config_window.py")
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from .addConfigSideMenuItem import addConfigSideMenuItem
|
|||||||
from .createSettingBoxContainer import createSettingBoxContainer
|
from .createSettingBoxContainer import createSettingBoxContainer
|
||||||
|
|
||||||
|
|
||||||
from .setting_box_containers import createSettingBox_Appearance
|
from .setting_box_containers import createSettingBox_Appearance, createSettingBox_Mic
|
||||||
|
|
||||||
|
|
||||||
def createSideMenuAndSettingsBoxContainers(config_window, settings):
|
def createSideMenuAndSettingsBoxContainers(config_window, settings):
|
||||||
@@ -55,12 +55,11 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings):
|
|||||||
{ "section_title": None, "setting_box": createSettingBox_Appearance },
|
{ "section_title": None, "setting_box": createSettingBox_Appearance },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"activate_by_default": True,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"side_menu_tab_attr_name": "side_menu_tab_translation",
|
"side_menu_tab_attr_name": "side_menu_tab_translation",
|
||||||
"label_attr_name": "label_translation",
|
"label_attr_name": "label_translation",
|
||||||
"selected_mark_attr_name": "transcription_send_selected_mark",
|
"selected_mark_attr_name": "selected_mark_translation",
|
||||||
"text": "Translation",
|
"text": "Translation",
|
||||||
"setting_box_container_settings": {
|
"setting_box_container_settings": {
|
||||||
"setting_box_container_attr_name": "setting_box_container_translation",
|
"setting_box_container_attr_name": "setting_box_container_translation",
|
||||||
@@ -72,19 +71,20 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings):
|
|||||||
{
|
{
|
||||||
"side_menu_tab_attr_name": "side_menu_tab_transcription",
|
"side_menu_tab_attr_name": "side_menu_tab_transcription",
|
||||||
"label_attr_name": "label_transcription",
|
"label_attr_name": "label_transcription",
|
||||||
"selected_mark_attr_name": "transcription_receive_selected_mark",
|
"selected_mark_attr_name": "selected_mark_transcription",
|
||||||
"text": "Transcription",
|
"text": "Transcription",
|
||||||
"setting_box_container_settings": {
|
"setting_box_container_settings": {
|
||||||
"setting_box_container_attr_name": "setting_box_container_transcription",
|
"setting_box_container_attr_name": "setting_box_container_transcription",
|
||||||
"setting_boxes": [
|
"setting_boxes": [
|
||||||
{ "section_title": None, "setting_box": None },
|
{ "section_title": "Mic", "setting_box": createSettingBox_Mic },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"activate_by_default": True,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"side_menu_tab_attr_name": "side_menu_tab_parameters",
|
"side_menu_tab_attr_name": "side_menu_tab_parameters",
|
||||||
"label_attr_name": "label_parameters",
|
"label_attr_name": "label_parameters",
|
||||||
"selected_mark_attr_name": "foreground_selected_mark",
|
"selected_mark_attr_name": "selected_mark_foreground",
|
||||||
"text": "Parameters",
|
"text": "Parameters",
|
||||||
"setting_box_container_settings": {
|
"setting_box_container_settings": {
|
||||||
"setting_box_container_attr_name": "setting_box_container_parameters",
|
"setting_box_container_attr_name": "setting_box_container_parameters",
|
||||||
@@ -96,7 +96,7 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings):
|
|||||||
{
|
{
|
||||||
"side_menu_tab_attr_name": "side_menu_tab_others",
|
"side_menu_tab_attr_name": "side_menu_tab_others",
|
||||||
"label_attr_name": "label_others",
|
"label_attr_name": "label_others",
|
||||||
"selected_mark_attr_name": "foreground_selected_mark",
|
"selected_mark_attr_name": "selected_mark_foreground",
|
||||||
"text": "Others",
|
"text": "Others",
|
||||||
"setting_box_container_settings": {
|
"setting_box_container_settings": {
|
||||||
"setting_box_container_attr_name": "setting_box_container_others",
|
"setting_box_container_attr_name": "setting_box_container_others",
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
from .setting_box_appearance import createSettingBox_Appearance
|
from .setting_box_appearance import createSettingBox_Appearance
|
||||||
|
from .setting_box_transcription import createSettingBox_Mic
|
||||||
@@ -3,7 +3,7 @@ from time import sleep
|
|||||||
from customtkinter import StringVar, IntVar
|
from customtkinter import StringVar, IntVar
|
||||||
|
|
||||||
|
|
||||||
from ..SettingBoxGenerator import SettingBoxGenerator
|
from .SettingBoxGenerator import SettingBoxGenerator
|
||||||
|
|
||||||
from config import config
|
from config import config
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
from .createSettingBox_Mic import createSettingBox_Mic
|
||||||
@@ -0,0 +1,268 @@
|
|||||||
|
from time import sleep
|
||||||
|
|
||||||
|
from customtkinter import StringVar, IntVar
|
||||||
|
|
||||||
|
|
||||||
|
from ..SettingBoxGenerator import SettingBoxGenerator
|
||||||
|
|
||||||
|
from config import config
|
||||||
|
|
||||||
|
def createSettingBox_Mic(setting_box_wrapper, config_window, settings):
|
||||||
|
|
||||||
|
|
||||||
|
sbg = SettingBoxGenerator(config_window, settings)
|
||||||
|
|
||||||
|
createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu
|
||||||
|
createSettingBoxSwitch = sbg.createSettingBoxSwitch
|
||||||
|
createSettingBoxCheckbox = sbg.createSettingBoxCheckbox
|
||||||
|
createSettingBoxSlider = sbg.createSettingBoxSlider
|
||||||
|
createSettingBoxProgressbarXSlider = sbg.createSettingBoxProgressbarXSlider
|
||||||
|
createSettingBoxEntry = sbg.createSettingBoxEntry
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# def dropdownMenuFun(selected_value):
|
||||||
|
# print(selected_value)
|
||||||
|
# config.INPUT_SOURCE_LANG = selected_value
|
||||||
|
|
||||||
|
# def switchFun(_, switch_box_widget):
|
||||||
|
# print(switch_box_widget.get())
|
||||||
|
|
||||||
|
# def checkboxFun(_, checkbox_box_widget):
|
||||||
|
# print(checkbox_box_widget.get())
|
||||||
|
|
||||||
|
# def sliderFun(value):
|
||||||
|
# print(value)
|
||||||
|
|
||||||
|
# def entryFun(value):
|
||||||
|
# config_window.INPUT_MIC_PHRASE_TIMEOUT = int(value)
|
||||||
|
# print(config_window.INPUT_MIC_PHRASE_TIMEOUT)
|
||||||
|
|
||||||
|
def checkbox_input_speaker_threshold_check_callback(e, passive_button_wrapper_widget, active_button_wrapper_widget, is_turned_on):
|
||||||
|
print("is_turned_on", is_turned_on)
|
||||||
|
|
||||||
|
if is_turned_on is True:
|
||||||
|
passive_button_widget = passive_button_wrapper_widget.children["!ctklabel"]
|
||||||
|
passive_button_wrapper_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
|
||||||
|
passive_button_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
|
||||||
|
passive_button_wrapper_widget.update_idletasks()
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
|
passive_button_wrapper_widget.grid_remove()
|
||||||
|
active_button_wrapper_widget.grid()
|
||||||
|
|
||||||
|
elif is_turned_on is False:
|
||||||
|
# active_button_widget = active_button_wrapper_widget.children["!ctklabel"]
|
||||||
|
# active_button_wrapper_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
|
||||||
|
# active_button_widget.configure(fg_color=settings.ctm.SB__PROGRESSBAR_X_SLIDER__PASSIVE_BUTTON_DISABLED_COLOR)
|
||||||
|
# active_button_wrapper_widget.update_idletasks()
|
||||||
|
# sleep(3)
|
||||||
|
|
||||||
|
active_button_wrapper_widget.grid_remove()
|
||||||
|
passive_button_wrapper_widget.grid()
|
||||||
|
|
||||||
|
def optionmenu_mic_host_callback(value):
|
||||||
|
config.CHOICE_MIC_HOST = value
|
||||||
|
|
||||||
|
def optionmenu_input_mic_device_callback(value):
|
||||||
|
config.CHOICE_MIC_DEVICE = value
|
||||||
|
|
||||||
|
def slider_input_mic_energy_threshold_callback(value):
|
||||||
|
config.INPUT_MIC_ENERGY_THRESHOLD = int(value)
|
||||||
|
|
||||||
|
def checkbox_input_mic_dynamic_energy_threshold_callback(checkbox_box_widget):
|
||||||
|
print(checkbox_box_widget.get())
|
||||||
|
config.INPUT_MIC_DYNAMIC_ENERGY_THRESHOLD = checkbox_box_widget.get()
|
||||||
|
|
||||||
|
row=0
|
||||||
|
# Mic Host と Mic Device は一つの項目として引っ付ける予定
|
||||||
|
config_window.sb__mic_host = createSettingBoxDropdownMenu(
|
||||||
|
parent_widget=setting_box_wrapper,
|
||||||
|
label_text="Mic Host",
|
||||||
|
desc_text="Select the mic host. (Default: ?)",
|
||||||
|
optionmenu_attr_name="sb__mic_host_optionmenu",
|
||||||
|
dropdown_menu_attr_name="sb__mic_host_dropdown",
|
||||||
|
# dropdown_menu_values=model.getListInputHost(),
|
||||||
|
dropdown_menu_values=["host1", "host2", "host3"],
|
||||||
|
command=lambda value: optionmenu_mic_host_callback(value),
|
||||||
|
variable=StringVar(value=config.CHOICE_MIC_HOST)
|
||||||
|
)
|
||||||
|
config_window.sb__mic_host.grid(row=row)
|
||||||
|
row+=1
|
||||||
|
|
||||||
|
config_window.sb__mic_device = createSettingBoxDropdownMenu(
|
||||||
|
parent_widget=setting_box_wrapper,
|
||||||
|
label_text="Mic Device",
|
||||||
|
desc_text="Select the mic host. (Default: ?)",
|
||||||
|
optionmenu_attr_name="sb__mic_device_optionmenu",
|
||||||
|
dropdown_menu_attr_name="sb__mic_device_dropdown",
|
||||||
|
# dropdown_menu_values=model.getListInputDevice(),
|
||||||
|
dropdown_menu_values=["device1", "device2", "device3"],
|
||||||
|
command=lambda value: optionmenu_input_mic_device_callback(value),
|
||||||
|
variable=StringVar(value=config.CHOICE_MIC_DEVICE)
|
||||||
|
)
|
||||||
|
config_window.sb__mic_device.grid(row=row)
|
||||||
|
row+=1
|
||||||
|
|
||||||
|
|
||||||
|
config_window.sb__mic_energy_threshold = createSettingBoxProgressbarXSlider(
|
||||||
|
parent_widget=setting_box_wrapper,
|
||||||
|
label_text="Mic Energy Threshold",
|
||||||
|
desc_text="Slider to modify the threshold for activating voice input.\nPress the microphone button to start input and speak something, so you can adjust it while monitoring the actual volume. 0 to 2000 (Default: 300)",
|
||||||
|
command=slider_input_mic_energy_threshold_callback,
|
||||||
|
variable=IntVar(value=config.INPUT_MIC_ENERGY_THRESHOLD),
|
||||||
|
entry_attr_name="sb__progressbar_x_slider__entry_mic_energy_threshold",
|
||||||
|
|
||||||
|
|
||||||
|
slider_attr_name="progressbar_x_slider__slider_mic_energy_threshold",
|
||||||
|
slider_range=(0, config.MAX_MIC_ENERGY_THRESHOLD),
|
||||||
|
slider_number_of_steps=config.MAX_MIC_ENERGY_THRESHOLD,
|
||||||
|
|
||||||
|
progressbar_attr_name="sb__progressbar_x_slider__progressbar_mic_energy_threshold",
|
||||||
|
|
||||||
|
passive_button_attr_name="sb__progressbar_x_slider__passive_button_mic_energy_threshold",
|
||||||
|
passive_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
|
||||||
|
e,
|
||||||
|
config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold,
|
||||||
|
config_window.sb__progressbar_x_slider__active_button_mic_energy_threshold,
|
||||||
|
is_turned_on=True,
|
||||||
|
),
|
||||||
|
active_button_attr_name="sb__progressbar_x_slider__active_button_mic_energy_threshold",
|
||||||
|
active_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
|
||||||
|
e,
|
||||||
|
config_window.sb__progressbar_x_slider__passive_button_mic_energy_threshold,
|
||||||
|
config_window.sb__progressbar_x_slider__active_button_mic_energy_threshold,
|
||||||
|
is_turned_on=False,
|
||||||
|
),
|
||||||
|
button_image_filename="mic_icon_white.png"
|
||||||
|
)
|
||||||
|
config_window.sb__mic_energy_threshold.grid(row=row)
|
||||||
|
row+=1
|
||||||
|
|
||||||
|
# Mic Dynamic Energy Thresholdも上に引っ付ける予定
|
||||||
|
config_window.sb__mic_dynamic_energy_threshold = createSettingBoxCheckbox(
|
||||||
|
parent_widget=setting_box_wrapper,
|
||||||
|
label_text="Mic Dynamic Energy Threshold",
|
||||||
|
desc_text="When this feature is selected, it will automatically adjust in a way that works well, based on the set Mic Energy Threshold.",
|
||||||
|
checkbox_attr_name="sb__checkbox_mic_dynamic_energy_threshold",
|
||||||
|
command=lambda: checkbox_input_mic_dynamic_energy_threshold_callback(config_window.sb__checkbox_mic_dynamic_energy_threshold),
|
||||||
|
is_checked=False,
|
||||||
|
)
|
||||||
|
config_window.sb__mic_dynamic_energy_threshold.grid(row=row)
|
||||||
|
row+=1
|
||||||
|
|
||||||
|
# config_window.sb__switch_1 = createSettingBoxSwitch(
|
||||||
|
# parent_widget=setting_box_wrapper,
|
||||||
|
# label_text="Switch",
|
||||||
|
# desc_text="Turning this switch on will bring happiness.\nAs for turning it off... I leave that to your imagination",
|
||||||
|
# switch_attr_name="switch_attr_name_1",
|
||||||
|
# command=lambda: switchFun(config_window.switch_attr_name_1),
|
||||||
|
# is_checked=True,
|
||||||
|
# )
|
||||||
|
# config_window.sb__switch_1.grid(row=row)
|
||||||
|
# row+=1
|
||||||
|
|
||||||
|
# config_window.sb__checkbox_1 = createSettingBoxCheckbox(
|
||||||
|
# parent_widget=setting_box_wrapper,
|
||||||
|
# label_text="Checkbox",
|
||||||
|
# desc_text="Checkbox ticked, a checkmark.",
|
||||||
|
# checkbox_attr_name="checkbox_attr_name_1",
|
||||||
|
# command=lambda: checkboxFun(config_window.checkbox_attr_name_1),
|
||||||
|
# is_checked=False,
|
||||||
|
# )
|
||||||
|
# config_window.sb__checkbox_1.grid(row=row)
|
||||||
|
# row+=1
|
||||||
|
|
||||||
|
# config_window.sb__slider_1 = createSettingBoxSlider(
|
||||||
|
# parent_widget=setting_box_wrapper,
|
||||||
|
# label_text="Slider",
|
||||||
|
# desc_text="Adjust using the slider; the balance is up to you.",
|
||||||
|
# slider_attr_name="slider_attr_name_1",
|
||||||
|
# slider_range=(0, config_window.MAX_SPEAKER_ENERGY_THRESHOLD),
|
||||||
|
# slider_number_of_steps=config_window.MAX_SPEAKER_ENERGY_THRESHOLD,
|
||||||
|
# command=lambda value: sliderFun(value, config_window.slider_attr_name_1),
|
||||||
|
# variable=IntVar(value=config_window.INPUT_SPEAKER_ENERGY_THRESHOLD),
|
||||||
|
# )
|
||||||
|
# config_window.sb__slider_1.grid(row=row)
|
||||||
|
# row+=1
|
||||||
|
|
||||||
|
|
||||||
|
# config_window.sb__progressbar_x_slider_1 = createSettingBoxProgressbarXSlider(
|
||||||
|
# parent_widget=setting_box_wrapper,
|
||||||
|
# label_text="Progressbar and Slider for check the threshold",
|
||||||
|
# desc_text="just the slider to modify the threshold for activating voice input.\nPress the microphone button to start input, and you can adjust it while monitoring the actual volume.",
|
||||||
|
# command=set_input_threshold, # ?
|
||||||
|
# variable=IntVar(value=config.INPUT_MIC_ENERGY_THRESHOLD),
|
||||||
|
# entry_attr_name="progressbar_x_slider__entry_attr_name_1",
|
||||||
|
|
||||||
|
|
||||||
|
# slider_attr_name="progressbar_x_slider__slider_attr_name_1",
|
||||||
|
# slider_range=(0, config_window.MAX_SPEAKER_ENERGY_THRESHOLD),
|
||||||
|
# slider_number_of_steps=config_window.MAX_SPEAKER_ENERGY_THRESHOLD,
|
||||||
|
|
||||||
|
# progressbar_attr_name="progressbar_x_slider__progressbar_attr_name_1",
|
||||||
|
|
||||||
|
# passive_button_attr_name="progressbar_x_slider__passive_button_attr_name_1",
|
||||||
|
# passive_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
|
||||||
|
# e,
|
||||||
|
# config_window.progressbar_x_slider__passive_button_attr_name_1,
|
||||||
|
# config_window.progressbar_x_slider__active_button_attr_name_1,
|
||||||
|
# is_turned_on=True,
|
||||||
|
# ),
|
||||||
|
# active_button_attr_name="progressbar_x_slider__active_button_attr_name_1",
|
||||||
|
# active_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
|
||||||
|
# e,
|
||||||
|
# config_window.progressbar_x_slider__passive_button_attr_name_1,
|
||||||
|
# config_window.progressbar_x_slider__active_button_attr_name_1,
|
||||||
|
# is_turned_on=False,
|
||||||
|
# ),
|
||||||
|
# button_image_filename="mic_icon_white.png"
|
||||||
|
# )
|
||||||
|
# config_window.sb__progressbar_x_slider_1.grid(row=row)
|
||||||
|
# row+=1
|
||||||
|
|
||||||
|
# config_window.sb__progressbar_x_slider_2 = createSettingBoxProgressbarXSlider(
|
||||||
|
# parent_widget=setting_box_wrapper,
|
||||||
|
# label_text="Progressbar and Slider for check the threshold2",
|
||||||
|
# desc_text="just the slider to modify the threshold for activating voice input.\nPress the microphone button to start input, and you can adjust it while monitoring the actual volume.",
|
||||||
|
# command=set_input_threshold, # ?
|
||||||
|
# variable=IntVar(value=config.INPUT_SPEAKER_ENERGY_THRESHOLD),
|
||||||
|
|
||||||
|
# entry_attr_name="progressbar_x_slider__entry_attr_name_2",
|
||||||
|
|
||||||
|
|
||||||
|
# slider_attr_name="progressbar_x_slider__slider_attr_name_2",
|
||||||
|
# slider_range=(0, config_window.MAX_SPEAKER_ENERGY_THRESHOLD),
|
||||||
|
# slider_number_of_steps=config_window.MAX_SPEAKER_ENERGY_THRESHOLD,
|
||||||
|
# progressbar_attr_name="progressbar_x_slider__progressbar_attr_name_2",
|
||||||
|
|
||||||
|
# passive_button_attr_name="progressbar_x_slider__passive_button_attr_name_2",
|
||||||
|
# passive_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
|
||||||
|
# e,
|
||||||
|
# config_window.progressbar_x_slider__passive_button_attr_name_2,
|
||||||
|
# config_window.progressbar_x_slider__active_button_attr_name_2,
|
||||||
|
# is_turned_on=True,
|
||||||
|
# ),
|
||||||
|
# active_button_attr_name="progressbar_x_slider__active_button_attr_name_2",
|
||||||
|
# active_button_command=lambda e: checkbox_input_speaker_threshold_check_callback(
|
||||||
|
# e,
|
||||||
|
# config_window.progressbar_x_slider__passive_button_attr_name_2,
|
||||||
|
# config_window.progressbar_x_slider__active_button_attr_name_2,
|
||||||
|
# is_turned_on=False,
|
||||||
|
# ),
|
||||||
|
# button_image_filename="headphones_icon_white.png"
|
||||||
|
# )
|
||||||
|
# config_window.sb__progressbar_x_slider_2.grid(row=row)
|
||||||
|
# row+=1
|
||||||
|
|
||||||
|
# config_window.sb__entry_1 = createSettingBoxEntry(
|
||||||
|
# parent_widget=setting_box_wrapper,
|
||||||
|
# label_text="Entry",
|
||||||
|
# desc_text="Please input a numerical value.",
|
||||||
|
# entry_attr_name="entry_attr_name_1",
|
||||||
|
# entry_width=settings.uism.SB__ENTRY_WIDTH_100,
|
||||||
|
# entry_bind__Any_KeyRelease=lambda value: entryFun(value, config_window.entry_attr_name_1),
|
||||||
|
# entry_textvariable=IntVar(value=config_window.INPUT_MIC_PHRASE_TIMEOUT),
|
||||||
|
# )
|
||||||
|
# config_window.sb__entry_1.grid(row=row, pady=0)
|
||||||
|
# row+=1
|
||||||
Reference in New Issue
Block a user