👍️[Update] Model : defaultのデバイス動作する機能のendpointを追加

This commit is contained in:
misyaguziya
2024-09-13 13:48:50 +09:00
parent 53edb45825
commit e8c65ed81f
4 changed files with 46 additions and 19 deletions

View File

@@ -5,7 +5,6 @@ from json import load as json_load
from json import dump as json_dump
import tkinter as tk
from tkinter import font
from models.translation.translation_languages import translation_lang
from models.transcription.transcription_utils import getInputDevices, getDefaultInputDevice, getOutputDevices, getDefaultOutputDevice
from models.transcription.transcription_languages import transcription_lang
from utils import generatePercentageStringsList, isUniqueStrings
@@ -458,14 +457,14 @@ class Config:
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, self.MAIN_WINDOW_GEOMETRY)
@property
@json_serializable('INPUT_MIC_AUTOMATIC_SELECTION')
def INPUT_MIC_AUTOMATIC_SELECTION(self):
return self._INPUT_MIC_AUTOMATIC_SELECTION
@json_serializable('ENABLE_MIC_AUTOMATIC_SELECTION')
def ENABLE_MIC_AUTOMATIC_SELECTION(self):
return self._ENABLE_MIC_AUTOMATIC_SELECTION
@INPUT_MIC_AUTOMATIC_SELECTION.setter
def INPUT_MIC_AUTOMATIC_SELECTION(self, value):
@ENABLE_MIC_AUTOMATIC_SELECTION.setter
def ENABLE_MIC_AUTOMATIC_SELECTION(self, value):
if isinstance(value, bool):
self._INPUT_MIC_AUTOMATIC_SELECTION = value
self._ENABLE_MIC_AUTOMATIC_SELECTION = value
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
@property
@@ -579,14 +578,14 @@ class Config:
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
@property
@json_serializable('INPUT_SPEAKER_AUTOMATIC_SELECTION')
def INPUT_SPEAKER_AUTOMATIC_SELECTION(self):
return self._INPUT_SPEAKER_AUTOMATIC_SELECTION
@json_serializable('ENABLE_SPEAKER_AUTOMATIC_SELECTION')
def ENABLE_SPEAKER_AUTOMATIC_SELECTION(self):
return self._ENABLE_SPEAKER_AUTOMATIC_SELECTION
@INPUT_SPEAKER_AUTOMATIC_SELECTION.setter
def INPUT_SPEAKER_AUTOMATIC_SELECTION(self, value):
@ENABLE_SPEAKER_AUTOMATIC_SELECTION.setter
def ENABLE_SPEAKER_AUTOMATIC_SELECTION(self, value):
if isinstance(value, bool):
self._INPUT_SPEAKER_AUTOMATIC_SELECTION = value
self._ENABLE_SPEAKER_AUTOMATIC_SELECTION = value
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
@property
@@ -1139,7 +1138,7 @@ class Config:
"width": "870",
"height": "654",
}
self._INPUT_MIC_AUTOMATIC_SELECTION = True
self._ENABLE_MIC_AUTOMATIC_SELECTION = True
self._CHOICE_MIC_HOST = getDefaultInputDevice()["host"]["name"]
self._CHOICE_MIC_DEVICE = getDefaultInputDevice()["device"]["name"]
self._INPUT_MIC_ENERGY_THRESHOLD = 300
@@ -1150,7 +1149,7 @@ class Config:
self._INPUT_MIC_WORD_FILTER = []
self._INPUT_MIC_AVG_LOGPROB=-0.8
self._INPUT_MIC_NO_SPEECH_PROB=0.6
self._INPUT_SPEAKER_AUTOMATIC_SELECTION = True
self._ENABLE_SPEAKER_AUTOMATIC_SELECTION = True
self._CHOICE_SPEAKER_DEVICE = getDefaultOutputDevice()["device"]["name"]
self._INPUT_SPEAKER_ENERGY_THRESHOLD = 300
self._INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD = False

View File

@@ -423,7 +423,7 @@ class Model:
return [device["name"] for device in getOutputDevices()]
def startMicTranscript(self, fnc):
if config.INPUT_MIC_AUTOMATIC_SELECTION is True:
if config.ENABLE_MIC_AUTOMATIC_SELECTION is True:
default_device = getDefaultInputDevice()
mic_host_name = default_device["host"]["name"]
mic_device_name = default_device["device"]["name"]
@@ -554,7 +554,7 @@ class Model:
# self.mic_get_energy = None
def startCheckMicEnergy(self, fnc):
if config.INPUT_MIC_AUTOMATIC_SELECTION is True:
if config.ENABLE_MIC_AUTOMATIC_SELECTION is True:
default_device = getDefaultInputDevice()
mic_host_name = default_device["host"]["name"]
mic_device_name = default_device["device"]["name"]
@@ -596,7 +596,7 @@ class Model:
self.mic_energy_recorder = None
def startSpeakerTranscript(self, fnc):
if config.INPUT_SPEAKER_AUTOMATIC_SELECTION is True:
if config.ENABLE_SPEAKER_AUTOMATIC_SELECTION is True:
default_device = getDefaultOutputDevice()
speaker_device_name = default_device["device"]["name"]
else:
@@ -685,7 +685,7 @@ class Model:
# self.speaker_get_energy = None
def startCheckSpeakerEnergy(self, fnc):
if config.INPUT_SPEAKER_AUTOMATIC_SELECTION is True:
if config.ENABLE_SPEAKER_AUTOMATIC_SELECTION is True:
default_device = getDefaultOutputDevice()
speaker_device_name = default_device["device"]["name"]
else:

View File

@@ -794,6 +794,17 @@ def callbackClearDeeplAuthKey(*args, **kwargs) -> dict:
# Transcription Tab
# Transcription (Mic)
def callbackEnableMicAutomaticSelection(*args, **kwargs) -> dict:
printLog("Enable Mic Automatic Selection")
config.ENABLE_MIC_AUTOMATIC_SELECTION = True
return {"status":200, "result":config.ENABLE_MIC_AUTOMATIC_SELECTION}
def callbackDisableMicAutomaticSelection(*args, **kwargs) -> dict:
printLog("Disable Mic Automatic Selection")
config.ENABLE_MIC_AUTOMATIC_SELECTION = False
return {"status":200, "result":config.ENABLE_MIC_AUTOMATIC_SELECTION}
def callbackSetMicHost(data, *args, **kwargs) -> dict:
printLog("Set Mic Host", data)
config.CHOICE_MIC_HOST = data
@@ -931,6 +942,17 @@ def callbackDeleteMicWordFilter(data, *args, **kwargs) -> dict:
return {"status":200, "result":config.INPUT_MIC_WORD_FILTER}
# Transcription (Speaker)
def callbackEnableSpeakerAutomaticSelection(*args, **kwargs) -> dict:
printLog("Enable Speaker Automatic Selection")
config.ENABLE_SPEAKER_AUTOMATIC_SELECTION = True
return {"status":200, "result":config.ENABLE_SPEAKER_AUTOMATIC_SELECTION}
def callbackDisableSpeakerAutomaticSelection(*args, **kwargs) -> dict:
printLog("Disable Speaker Automatic Selection")
config.ENABLE_SPEAKER_AUTOMATIC_SELECTION = False
return {"status":200, "result":config.ENABLE_SPEAKER_AUTOMATIC_SELECTION}
def callbackSetSpeakerDevice(data, *args, **kwargs) -> dict:
printLog("Set Speaker Device", data)
config.CHOICE_SPEAKER_DEVICE = data

View File

@@ -42,6 +42,7 @@ config_mapping = {
"/config/ui_language": "UI_LANGUAGE",
"/config/enable_restore_main_window_geometry": "ENABLE_RESTORE_MAIN_WINDOW_GEOMETRY",
"/config/main_window_geometry": "MAIN_WINDOW_GEOMETRY",
"/config/ENABLE_MIC_AUTOMATIC_SELECTION": "ENABLE_MIC_AUTOMATIC_SELECTION",
"/config/choice_mic_host": "CHOICE_MIC_HOST",
"/config/choice_mic_device": "CHOICE_MIC_DEVICE",
"/config/input_mic_energy_threshold": "INPUT_MIC_ENERGY_THRESHOLD",
@@ -52,6 +53,7 @@ config_mapping = {
"/config/input_mic_word_filter": "INPUT_MIC_WORD_FILTER",
"/config/input_mic_avg_logprob": "INPUT_MIC_AVG_LOGPROB",
"/config/input_mic_no_speech_prob": "INPUT_MIC_NO_SPEECH_PROB",
"/config/ENABLE_SPEAKER_AUTOMATIC_SELECTION": "ENABLE_SPEAKER_AUTOMATIC_SELECTION",
"/config/choice_speaker_device": "CHOICE_SPEAKER_DEVICE",
"/config/input_speaker_energy_threshold": "INPUT_SPEAKER_ENERGY_THRESHOLD",
"/config/input_speaker_dynamic_energy_threshold": "INPUT_SPEAKER_DYNAMIC_ENERGY_THRESHOLD",
@@ -140,6 +142,8 @@ controller_mapping = {
"/controller/callback_download_ctranslate2_weight": controller.callbackDownloadCtranslate2Weight,
"/controller/callback_set_deepl_auth_key": controller.callbackSetDeeplAuthKey,
"/controller/callback_clear_deepl_auth_key": controller.callbackClearDeeplAuthKey,
"/controller/callback_enable_mic_automatic_selection": controller.callbackEnableMicAutomaticSelection,
"/controller/callback_disable_mic_automatic_selection": controller.callbackDisableMicAutomaticSelection,
"/controller/callback_set_mic_host": controller.callbackSetMicHost,
"/controller/callback_set_mic_device": controller.callbackSetMicDevice,
"/controller/callback_set_mic_energy_threshold": controller.callbackSetMicEnergyThreshold,
@@ -152,6 +156,8 @@ controller_mapping = {
"/controller/callback_set_mic_max_phrases": controller.callbackSetMicMaxPhrases,
"/controller/callback_set_mic_word_filter": controller.callbackSetMicWordFilter,
"/controller/callback_delete_mic_word_filter": controller.callbackDeleteMicWordFilter,
"/controller/callback_enable_speaker_automatic_selection": controller.callbackEnableSpeakerAutomaticSelection,
"/controller/callback_disable_speaker_automatic_selection": controller.callbackDisableSpeakerAutomaticSelection,
"/controller/callback_set_speaker_device": controller.callbackSetSpeakerDevice,
"/controller/callback_set_speaker_energy_threshold": controller.callbackSetSpeakerEnergyThreshold,
"/controller/callback_enable_speaker_dynamic_energy_threshold": controller.callbackEnableSpeakerDynamicEnergyThreshold,