From 5c5e9d08bd323a2f433964849ef250d40b4447a5 Mon Sep 17 00:00:00 2001 From: xszyou Date: Wed, 5 Jul 2023 22:21:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A3=B0=E9=9F=B3=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、修复唇形算法运行出错而导致的声音不播放问题。 --- README.md | 4 ++++ core/recorder.py | 12 +++++++----- fay_booter.py | 12 ++++++------ gui/window.py | 3 +++ system.conf | 24 +++++++++++------------- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index fa9c87e..a06c7de 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,10 @@ Fay(服务端)与数字人的通讯接口: [`ws://127.0.0.1:10002`](ws://127 ## **三、升级日志** +**2023.07.05:** + ++ 修复无法运行唇型算法而导致的不播放声音问题。 + **2023.06.28:** + 重构NLP模块管理逻辑,便于自由扩展; diff --git a/core/recorder.py b/core/recorder.py index 46d8130..346dddc 100644 --- a/core/recorder.py +++ b/core/recorder.py @@ -104,11 +104,13 @@ class Recorder: data = stream.read(1024, exception_on_overflow=False) if not data: continue - #只获取第一声道 - data = np.frombuffer(data, dtype=np.int16) - data = np.reshape(data, (-1, cfg.config['source']['record']['channels'])) # reshaping the array to split the channels - mono = data[:, 0] # taking the first channel - data = mono.tobytes() + + if cfg.config['source']['record'].get("channels"): + #只获取第一声道 + data = np.frombuffer(data, dtype=np.int16) + data = np.reshape(data, (-1, cfg.config['source']['record']['channels'])) # reshaping the array to split the channels + mono = data[:, 0] # taking the first channel + data = mono.tobytes() level = audioop.rms(data, 2) if len(self.__history_data) >= 5: diff --git a/fay_booter.py b/fay_booter.py index 878af96..cc085a8 100644 --- a/fay_booter.py +++ b/fay_booter.py @@ -164,9 +164,9 @@ def stop(): if recorderListener is not None: util.log(1, '正在关闭录音服务...') recorderListener.stop() - # if deviceInputListener is not None: - # util.log(1, '正在关闭远程音频输入输出服务...') - # deviceInputListener.stop() + if deviceInputListener is not None: + util.log(1, '正在关闭远程音频输入输出服务...') + deviceInputListener.stop() util.log(1, '正在关闭核心服务...') feiFei.stop() util.log(1, '服务已关闭!') @@ -196,9 +196,9 @@ def start(): recorderListener.start() #edit by xszyou on 20230113:通过此服务来连接k210、手机等音频输入设备 - # util.log(1,'开启远程设备音频输入服务...') - # deviceInputListener = DeviceInputListener(feiFei) # 设备音频输入输出麦克风 - # deviceInputListener.start() + util.log(1,'开启远程设备音频输入服务...') + deviceInputListener = DeviceInputListener(feiFei) # 设备音频输入输出麦克风 + deviceInputListener.start() util.log(1, '注册命令...') MyThread(target=console_listener).start() # 监听控制台 diff --git a/gui/window.py b/gui/window.py index c3805b7..9be8598 100644 --- a/gui/window.py +++ b/gui/window.py @@ -24,6 +24,9 @@ class MainWindow(QMainWindow): self.showMaximized() # self.center() self.browser = QWebEngineView() + #清空缓存 + # profile = QWebEngineProfile.defaultProfile() + # profile.clearHttpCache() self.browser.load(QUrl('http://127.0.0.1:5000')) self.setCentralWidget(self.browser) MyThread(target=self.runnable).start() diff --git a/system.conf b/system.conf index eed369e..6c0e683 100644 --- a/system.conf +++ b/system.conf @@ -20,28 +20,26 @@ ms_tts_region= xf_ltp_app_id= xf_ltp_api_key= -#NLP五选一:yuan、gpt、chatgpt、rasa(需启动chatglm及rasa,https://m.bilibili.com/video/BV1D14y1f7pr)、lingju +#NLP多选一:lingju、yuan、gpt、chatgpt、rasa(需启动chatglm及rasa,https://m.bilibili.com/video/BV1D14y1f7pr)、VisualGLM chat_module=lingju +#灵聚 服务密钥(NLP多选1) https://open.lingju.ai +lingju_api_key= +lingju_api_authcode= -#浪.潮源大模型 服务密钥(NLP5选1) https://air.inspur.com/ +#浪.潮源大模型 服务密钥(NLP多选1) https://air.inspur.com/ yuan_1_0_account= yuan_1_0_phone= -#gpt 服务密钥(NLP5选1) https://openai.com/ +#gpt 服务密钥(NLP多选1) https://openai.com/ chatgpt_api_key= -#灵聚 服务密钥 https://open.lingju.ai -lingju_api_key= -lingju_api_authcode= +#ChatGPT对接(NLP多选1)(非必须,https://chat.openai.com登录后访问https://chat.openai.com/api/auth/session获取) +gpt_access_token= +gpt_conversation_id= +#gpt代理 +proxy_config=http://127.0.0.1:7890 #ngrok内网穿透id,远程设备可以通过互联网连接Fay(非必须)http://ngrok.cc ngrok_cc_id= -#revChatGPT对接(非必须,https://chat.openai.com登录后访问https://chat.openai.com/api/auth/session获取) -gpt_access_token= -gpt_conversation_id= - -#gpt代理 -proxy_config=http://192.168.1.13:7890 -