From 8ebfb99401ec1cf9989e24f7e6c238d20223ed43 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Tue, 17 Oct 2023 04:01:01 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Config=20:=20NoDevice?= =?UTF-8?q?=E6=99=82=E3=81=ABCHOICE=5FSPEAKER=5FDEVICE=E3=82=92=E3=82=BB?= =?UTF-8?q?=E3=83=83=E3=83=88=E3=81=99=E3=82=8B=E3=81=A8=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=AB=E3=81=AA=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/config.py b/config.py index b0fdacc5..030da6bb 100644 --- a/config.py +++ b/config.py @@ -1,5 +1,4 @@ import sys -from json import load, dump import inspect from os import path as os_path from json import load as json_load @@ -7,9 +6,8 @@ from json import dump as json_dump import tkinter as tk from tkinter import font from languages import selectable_languages -from models.translation.translation_languages import translatorEngine, translation_lang -from models.transcription.transcription_languages import transcription_lang -from models.transcription.transcription_utils import getInputDevices, getOutputDevices, getDefaultInputDevice, getDefaultOutputDevice +from models.translation.translation_languages import translatorEngine +from models.transcription.transcription_utils import getInputDevices, getDefaultInputDevice, getDefaultOutputDevice json_serializable_vars = {} def json_serializable(var_name): @@ -20,7 +18,7 @@ def json_serializable(var_name): def saveJson(path, key, value): with open(path, "r", encoding="utf-8") as fp: - json_data = load(fp) + json_data = json_load(fp) json_data[key] = value with open(path, "w", encoding="utf-8") as fp: json_dump(json_data, fp, indent=4, ensure_ascii=False) @@ -346,11 +344,9 @@ class Config: @CHOICE_SPEAKER_DEVICE.setter def CHOICE_SPEAKER_DEVICE(self, value): - if value in [device["name"] for device in getOutputDevices()]: - speaker_device = [device for device in getOutputDevices() if device["name"] == value][0] - if getDefaultOutputDevice()["index"] == speaker_device["index"]: - self._CHOICE_SPEAKER_DEVICE = value - saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) + if getDefaultOutputDevice()["name"] == value: + self._CHOICE_SPEAKER_DEVICE = value + saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value) @property @json_serializable('INPUT_SPEAKER_ENERGY_THRESHOLD')