3月更新

1、web socket接口增加数字人文字内容同步,以便数人字可以远程运行;
2、优化数字人数据web socket同步逻辑;
3、更改gpt 3.5对接方式.
This commit is contained in:
xszyou 2023-03-29 17:30:26 +08:00
parent 2dca3ad6db
commit a42a72081d
4 changed files with 28 additions and 15 deletions

View File

@ -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作为选择。
@ -279,6 +282,6 @@ python main.py
技术交流群
<img src="images/20230315021425.jpg" alt="微信群">
<img src="images/20230329172514.jpg" alt="微信群">

View File

@ -1,10 +1,16 @@
from utils import config_util as cfg
import openai
import json
import requests
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
from utils import config_util as cfg
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

View File

@ -29,7 +29,7 @@ from utils import config_util as cfg
class FeiFei:
def __init__(self):
pygame.init()
pygame.mixer.init()
self.q_msg = '你叫什么名字?'
self.a_msg = 'hi,我叫菲菲英文名是fay'
self.mood = 0.0 # 情绪值
@ -255,6 +255,10 @@ class FeiFei:
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": ""})
@ -411,7 +415,7 @@ class FeiFei:
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)
@ -496,9 +500,9 @@ class FeiFei:
# 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:

BIN
images/20230329172514.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB