From 4bcb28e1827d295fb9a1c01bb0e7f8a1dcd54144 Mon Sep 17 00:00:00 2001 From: xszyou Date: Thu, 7 Nov 2024 11:30:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B4=A7=E6=80=A5=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复麦克风热启动的bug. --- core/recorder.py | 1 + tts/ali_tss.py | 5 ++--- utils/config_util.py | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/recorder.py b/core/recorder.py index d7c0346..c2cdee8 100644 --- a/core/recorder.py +++ b/core/recorder.py @@ -201,6 +201,7 @@ class Recorder: audio_data_list = [] while self.__running: try: + cfg.load_config() record = cfg.config['source']['record'] if not record['enabled'] and not self.is_remote: time.sleep(0.1) diff --git a/tts/ali_tss.py b/tts/ali_tss.py index 15530b9..8ce7b21 100644 --- a/tts/ali_tss.py +++ b/tts/ali_tss.py @@ -93,7 +93,7 @@ class Speech: httpHeaders = { 'Content-Type': 'application/json' } - text = f"{text}" + text = f"{text}" # 设置HTTPS Body。 body = {'appkey': self.ali_nls_app_key, 'token': self.token,'speech_rate':0, 'text': text, 'format': 'wav', 'sample_rate': 16000, 'voice': config_util.config["attribute"]["voice"]} body = json.dumps(body) @@ -117,8 +117,7 @@ class Speech: util.log(1, "[x] 原因: " + str(body)) file_url = None return file_url - conn.close() - print(time.time() - tt) + conn.close() return file_url else: util.log(1, "[x] 语音转换失败!") diff --git a/utils/config_util.py b/utils/config_util.py index 70ea695..1bb34b3 100644 --- a/utils/config_util.py +++ b/utils/config_util.py @@ -124,5 +124,6 @@ def save_config(config_data): file = codecs.open('config.json', mode='w', encoding='utf-8') file.write(json.dumps(config, sort_keys=True, indent=4, separators=(',', ': '))) file.close() + load_config() # for line in json.dumps(config, sort_keys=True, indent=4, separators=(',', ': ')).split("\n"): # print(line)