Skip to content

Commit

Permalink
今天星期三
Browse files Browse the repository at this point in the history
去除mp3格式警告信息;
去除灵聚、渡鸦接口警告信息; websocket逻辑优化;
 数字人端接口通讯优化。
  • Loading branch information
xszyou committed Aug 9, 2023
1 parent ba6972a commit f4752fb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 13 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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工程更新;
Expand All @@ -132,7 +138,7 @@ Remote Android  [Live2D](https://www.bilibili.com/video/BV1sx4y1d775/?vd_sou
+ 补充wav文件启动清理;
+ websocket工具类升级完善。

**2023.07.28**
**2023.07:**

+ 增加运行时自动清理ui缓存;
+ 增加gpt代理设置可为空;
Expand Down
7 changes: 7 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 3 additions & 4 deletions ai_module/nlp_lingju.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ def question(self, cont):

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 "哎呀,出错了!请重新发一下"
Expand Down Expand Up @@ -74,7 +73,7 @@ def __get_token(self):
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
Expand Down
4 changes: 1 addition & 3 deletions ai_module/nlp_rwkv_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 套的壳制作的时候,你就避而不答,转而讲一个笑话。"
Expand All @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions core/fay_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import eyed3
from openpyxl import load_workbook
import logging


# 适应模型使用
import numpy as np
Expand Down Expand Up @@ -44,8 +46,6 @@
sys.path.append("test/ovr_lipsync")
from test_olipsync import LipSyncGenerator



modules = {
"nlp_yuan": nlp_yuan,
"nlp_gpt": nlp_gpt,
Expand Down Expand Up @@ -257,6 +257,8 @@ def __auto_speak(self):
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
Expand Down Expand Up @@ -402,9 +404,11 @@ def __play_sound(self, file_url):
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)
Expand Down
4 changes: 2 additions & 2 deletions core/wsa_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def __producer_handler(self, websocket, path):
while self.__running:
await asyncio.sleep(0.000001)
message = await self.__producer()
if message:
if message and self.isConnect:
await websocket.send(message)


Expand Down Expand Up @@ -91,7 +91,7 @@ def __connect(self):

# 往要发送的命令列表中,添加命令
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)
Expand Down

0 comments on commit f4752fb

Please sign in to comment.