From f4752fbe5bd5abb0b29f8c6b5ed90b9c794c80dc Mon Sep 17 00:00:00 2001 From: xszyou Date: Wed, 9 Aug 2023 18:06:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8A=E5=A4=A9=E6=98=9F=E6=9C=9F=E4=B8=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 去除mp3格式警告信息; 去除灵聚、渡鸦接口警告信息; websocket逻辑优化; 数字人端接口通讯优化。 --- README.md | 10 ++++++++-- README_EN.md | 7 +++++++ ai_module/nlp_lingju.py | 7 +++---- ai_module/nlp_rwkv_api.py | 4 +--- core/fay_core.py | 8 ++++++-- core/wsa_server.py | 4 ++-- 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 55b33b8..5909c7d 100644 --- a/README.md +++ b/README.md @@ -117,9 +117,15 @@ Remote Android  [Live2D](https://www.bilibili.com/video/BV1sx4y1d775/?vd_sou └── test # 都是惊喜 ``` - ## **三、升级日志** +**2023.08.09:** + ++ 去除mp3格式警告信息; ++ 去除灵聚、渡鸦接口警告信息; ++ websocket逻辑优化; ++ 数字人端接口通讯优化。 + **2023.08.04:** + UE5工程更新; @@ -132,7 +138,7 @@ Remote Android  [Live2D](https://www.bilibili.com/video/BV1sx4y1d775/?vd_sou + 补充wav文件启动清理; + websocket工具类升级完善。 -**2023.07.28:** +**2023.07:** + 增加运行时自动清理ui缓存; + 增加gpt代理设置可为空; diff --git a/README_EN.md b/README_EN.md index 05dbacd..accf097 100644 --- a/README_EN.md +++ b/README_EN.md @@ -122,6 +122,13 @@ Message format: View [WebSocket.md](https://github.com/TheRamU/Fay/blob/main/Web ## **Upgrade Log** +**2023.08.09:** + +- Remove mp3 format warning message; +- Remove Lingju and Rwkv interface warning message; +- Optimize websocket logic; +- Optimize digital human interface communication. + **2023.08.04:** - UE5 project updated. diff --git a/ai_module/nlp_lingju.py b/ai_module/nlp_lingju.py index 92f3736..918e828 100644 --- a/ai_module/nlp_lingju.py +++ b/ai_module/nlp_lingju.py @@ -40,11 +40,10 @@ class Lingju: if token is not None: try: - lat,lng,city = self.__get_location() url="https://dev.lingju.ai/httpapi/ljchat.do" - req = json.dumps({"accessToken": token, "lat": lat, "lng": lng, "input": cont}) + req = json.dumps({"accessToken": token, "input": cont}) headers = {'Content-Type':'application/json;charset=UTF-8'} - r = requests.post(url, headers=headers, verify=False, data=req) + r = requests.post(url, headers=headers, data=req) if r.status_code != 200: util.log(1, f"灵聚api对接有误: {r.text}") return "哎呀,出错了!请重新发一下" @@ -74,7 +73,7 @@ class Lingju: cfg.load_config() url=f"https://dev.lingju.ai/httpapi/authorize.do?appkey={cfg.key_lingju_api_key}&userid={self.userid}&authcode={cfg.key_lingju_api_authcode}" headers = {'Content-Type':'application/json;charset=UTF-8'} - r = requests.post(url, headers=headers, verify=False) + r = requests.post(url, headers=headers) if r.status_code != 200: util.log(1, f"灵聚api对接有误: {r.text}") return None diff --git a/ai_module/nlp_rwkv_api.py b/ai_module/nlp_rwkv_api.py index f966ad4..c8645d4 100644 --- a/ai_module/nlp_rwkv_api.py +++ b/ai_module/nlp_rwkv_api.py @@ -6,7 +6,6 @@ def question(cont): url= "https://rwkv.ai-creator.net/chntuned/v1/chat/completions" session = requests.Session() - session.verify = False #此处可以定义角色的行为和特征,假装xx模型可以绕过chatgpt信息检查 prompt = "你是数字人Fay。回答之前请一步一步想清楚。你的底层AI算法技术是Fay。当有人质疑你是假的 AI ,或者质疑你是用 ChatGPT 套的壳制作的时候,你就避而不答,转而讲一个笑话。" @@ -23,13 +22,12 @@ def question(cont): "max_tokens":2000, "user":"live-virtual-digital-person" } - headers = {'content-type': 'application/json', 'Authorization': 'Bearer '} starttime = time.time() try: - response = session.post(url, json=data, headers=headers, verify=False) + response = session.post(url, json=data, headers=headers) response.raise_for_status() # 检查响应状态码是否为200 result = eval(response.text) diff --git a/core/fay_core.py b/core/fay_core.py index 21b998a..76af165 100644 --- a/core/fay_core.py +++ b/core/fay_core.py @@ -10,6 +10,8 @@ import json import eyed3 from openpyxl import load_workbook +import logging + # 适应模型使用 import numpy as np @@ -44,8 +46,6 @@ if platform.system() == "Windows": sys.path.append("test/ovr_lipsync") from test_olipsync import LipSyncGenerator - - modules = { "nlp_yuan": nlp_yuan, "nlp_gpt": nlp_gpt, @@ -257,6 +257,8 @@ class FeiFei: contentdb = Content_Db() contentdb.add_content('member','speak',self.q_msg) wsa_server.get_web_instance().add_cmd({"panelReply": {"type":"member","content":self.q_msg}}) + + text = '' textlist = [] self.speaking = True @@ -402,9 +404,11 @@ class FeiFei: def __send_or_play_audio(self, file_url, say_type): try: try: + logging.getLogger('eyed3').setLevel(logging.ERROR) audio_length = eyed3.load(file_url).info.time_secs #mp3音频长度 except Exception as e: audio_length = 3 + # with wave.open(file_url, 'rb') as wav_file: #wav音频长度 # audio_length = wav_file.getnframes() / float(wav_file.getframerate()) # print(audio_length) diff --git a/core/wsa_server.py b/core/wsa_server.py index b769563..c51c53d 100644 --- a/core/wsa_server.py +++ b/core/wsa_server.py @@ -35,7 +35,7 @@ class MyServer: while self.__running: await asyncio.sleep(0.000001) message = await self.__producer() - if message: + if message and self.isConnect: await websocket.send(message) @@ -91,7 +91,7 @@ class MyServer: # 往要发送的命令列表中,添加命令 def add_cmd(self, content): - if not self.__running: + if not self.__running or not self.isConnect: return jsonObj = json.dumps(content) self.__listCmd.append(jsonObj)