3月更新
1、web socket接口增加数字人文字内容同步,以便数人字可以远程运行; 2、优化数字人数据web socket同步逻辑; 3、更改gpt 3.5对接方式.
This commit is contained in:
parent
2dca3ad6db
commit
a42a72081d
@ -28,7 +28,10 @@
|
|||||||
|
|
||||||
2023.03:
|
2023.03:
|
||||||
1、增加edge-tts语音合成(免费)可替换azure-tts(支持情绪化语音);
|
1、增加edge-tts语音合成(免费)可替换azure-tts(支持情绪化语音);
|
||||||
2、替换flask发行版运行方式。
|
2、替换flask发行版运行方式;
|
||||||
|
4、web socket接口增加数字人文字内容同步,以便数人字可以远程运行;
|
||||||
|
5、优化数字人数据web socket同步逻辑;
|
||||||
|
6、更改gpt 3.5对接方式。
|
||||||
|
|
||||||
2023.02:
|
2023.02:
|
||||||
1、提供chatgpt及yuan1.0作为选择。
|
1、提供chatgpt及yuan1.0作为选择。
|
||||||
@ -279,6 +282,6 @@ python main.py
|
|||||||
|
|
||||||
技术交流群
|
技术交流群
|
||||||
|
|
||||||
<img src="images/20230315021425.jpg" alt="微信群">
|
<img src="images/20230329172514.jpg" alt="微信群">
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
from utils import config_util as cfg
|
import json
|
||||||
import openai
|
import requests
|
||||||
|
|
||||||
def question(text):
|
from utils import config_util as cfg
|
||||||
cfg.load_config()
|
|
||||||
openai.api_key = cfg.key_chatgpt_api_key
|
def question(cont):
|
||||||
prompt = text
|
url="https://api.openai.com/v1/chat/completions"
|
||||||
completions = openai.Completion.create(engine="text-davinci-002", prompt=prompt, max_tokens=1024)
|
req = json.dumps({
|
||||||
a_msg = completions.choices[0].text
|
"model": "gpt-3.5-turbo",
|
||||||
return a_msg
|
"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
|
@ -29,7 +29,7 @@ from utils import config_util as cfg
|
|||||||
|
|
||||||
class FeiFei:
|
class FeiFei:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pygame.init()
|
pygame.mixer.init()
|
||||||
self.q_msg = '你叫什么名字?'
|
self.q_msg = '你叫什么名字?'
|
||||||
self.a_msg = 'hi,我叫菲菲,英文名是fay'
|
self.a_msg = 'hi,我叫菲菲,英文名是fay'
|
||||||
self.mood = 0.0 # 情绪值
|
self.mood = 0.0 # 情绪值
|
||||||
@ -255,6 +255,10 @@ class FeiFei:
|
|||||||
else:
|
else:
|
||||||
raise RuntimeError('讯飞key、yuan key、chatgpt key都没有配置!')
|
raise RuntimeError('讯飞key、yuan key、chatgpt key都没有配置!')
|
||||||
util.log(1, '自然语言处理完成. 耗时: {} ms'.format(math.floor((time.time() - tm) * 1000)))
|
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 == '':
|
if text == '哎呀,你这么说我也不懂,详细点呗' or text == '':
|
||||||
util.log(1, '[!] 自然语言无语了!')
|
util.log(1, '[!] 自然语言无语了!')
|
||||||
wsa_server.get_web_instance().add_cmd({"panelMsg": ""})
|
wsa_server.get_web_instance().add_cmd({"panelMsg": ""})
|
||||||
@ -411,7 +415,7 @@ class FeiFei:
|
|||||||
def __send_mood(self):
|
def __send_mood(self):
|
||||||
while self.__running:
|
while self.__running:
|
||||||
time.sleep(3)
|
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}}
|
content = {'Topic': 'Unreal', 'Data': {'Key': 'mood', 'Value': self.mood}}
|
||||||
wsa_server.get_instance().add_cmd(content)
|
wsa_server.get_instance().add_cmd(content)
|
||||||
|
|
||||||
@ -496,9 +500,9 @@ class FeiFei:
|
|||||||
# with wave.open(file_url, 'rb') as wav_file: #wav音频长度
|
# with wave.open(file_url, 'rb') as wav_file: #wav音频长度
|
||||||
# audio_length = wav_file.getnframes() / float(wav_file.getframerate())
|
# audio_length = wav_file.getnframes() / float(wav_file.getframerate())
|
||||||
if audio_length <= config_util.config["interact"]["maxInteractTime"] or say_type == "script":
|
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)
|
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}}
|
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)
|
wsa_server.get_instance().add_cmd(content)
|
||||||
if self.deviceConnect is not None:
|
if self.deviceConnect is not None:
|
||||||
|
BIN
images/20230329172514.jpg
Normal file
BIN
images/20230329172514.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 147 KiB |
Loading…
Reference in New Issue
Block a user