Skip to content

Commit

Permalink
3月更新
Browse files Browse the repository at this point in the history
1、web socket接口增加数字人文字内容同步,以便数人字可以远程运行;
2、优化数字人数据web socket同步逻辑;
3、更改gpt 3.5对接方式.
  • Loading branch information
xszyou committed Mar 29, 2023
1 parent 2dca3ad commit a42a720
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@

2023.03:
1、增加edge-tts语音合成(免费)可替换azure-tts(支持情绪化语音);
2、替换flask发行版运行方式。
2、替换flask发行版运行方式;
4、web socket接口增加数字人文字内容同步,以便数人字可以远程运行;
5、优化数字人数据web socket同步逻辑;
6、更改gpt 3.5对接方式。

2023.02:
1、提供chatgpt及yuan1.0作为选择。
Expand Down Expand Up @@ -279,6 +282,6 @@ python main.py

技术交流群

<img src="images/20230315021425.jpg" alt="微信群">
<img src="images/20230329172514.jpg" alt="微信群">


22 changes: 14 additions & 8 deletions ai_module/chatgpt.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import json
import requests

from utils import config_util as cfg
import openai

def question(text):
cfg.load_config()
openai.api_key = cfg.key_chatgpt_api_key
prompt = text
completions = openai.Completion.create(engine="text-davinci-002", prompt=prompt, max_tokens=1024)
a_msg = completions.choices[0].text
return a_msg
def question(cont):
url="https://api.openai.com/v1/chat/completions"
req = json.dumps({
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": cont}],
"temperature": 0.7})
headers = {'content-type': 'application/json', 'Authorization': 'Bearer ' + cfg.key_chatgpt_api_key}
r = requests.post(url, headers=headers, data=req)
rsp = json.loads(r.text).get('choices')
a = rsp[0]['message']['content']
return a
12 changes: 8 additions & 4 deletions core/fay_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

class FeiFei:
def __init__(self):
pygame.init()
pygame.mixer.init()
self.q_msg = '你叫什么名字?'
self.a_msg = 'hi,我叫菲菲,英文名是fay'
self.mood = 0.0 # 情绪值
Expand Down Expand Up @@ -255,6 +255,10 @@ def __auto_speak(self):
else:
raise RuntimeError('讯飞key、yuan key、chatgpt key都没有配置!')
util.log(1, '自然语言处理完成. 耗时: {} ms'.format(math.floor((time.time() - tm) * 1000)))
#同步文字内容给ue5
if text is not None and not config_util.config["interact"]["playSound"]: # 非展板播放
content = {'Topic': 'Unreal', 'Data': {'Key': 'text', 'Value': text}}
wsa_server.get_instance().add_cmd(content)
if text == '哎呀,你这么说我也不懂,详细点呗' or text == '':
util.log(1, '[!] 自然语言无语了!')
wsa_server.get_web_instance().add_cmd({"panelMsg": ""})
Expand Down Expand Up @@ -411,7 +415,7 @@ def __fay(self, index):
def __send_mood(self):
while self.__running:
time.sleep(3)
if not self.sleep:
if not self.sleep and not config_util.config["interact"]["playSound"]:
content = {'Topic': 'Unreal', 'Data': {'Key': 'mood', 'Value': self.mood}}
wsa_server.get_instance().add_cmd(content)

Expand Down Expand Up @@ -496,9 +500,9 @@ def __send_audio(self, file_url, say_type):
# with wave.open(file_url, 'rb') as wav_file: #wav音频长度
# audio_length = wav_file.getnframes() / float(wav_file.getframerate())
if audio_length <= config_util.config["interact"]["maxInteractTime"] or say_type == "script":
if config_util.config["interact"]["playSound"]: # 播放音频
if config_util.config["interact"]["playSound"]: # 展板播放
self.__play_sound(file_url)
else:#TODO 发送音频给ue和socket
else:#发送音频给ue和socket
content = {'Topic': 'Unreal', 'Data': {'Key': 'audio', 'Value': os.path.abspath(file_url), 'Time': audio_length, 'Type': say_type}}
wsa_server.get_instance().add_cmd(content)
if self.deviceConnect is not None:
Expand Down
Binary file added images/20230329172514.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a42a720

Please sign in to comment.