Skip to content

Commit

Permalink
Fay数字人助理版提交
Browse files Browse the repository at this point in the history
+ 打出Fay数字人助理版作为主分支(带货版移到分支[`fay-sales-edition`]);
+ 添加Fay助理的文字沟通窗口(文字与语音同步);
+ 添加沟通记录本地保存功能;
+ 升级ChatGLM-6B的应用逻辑,长文本与语音回复分享;
  • Loading branch information
xszyou committed May 12, 2023
1 parent 83229a7 commit d90d699
Show file tree
Hide file tree
Showing 24 changed files with 788 additions and 397 deletions.
175 changes: 42 additions & 133 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@
<br>
<img src="images/icon.png" alt="Fay">
<h1>FAY</h1>
<h3>数 字 人 Fay 控 制 器(这是元宇宙吗?)</h3>
<h3>Fay数字人助理</h3>
</div>


Fay是一个完整的开源项目,包含Fay控制器及数字人模型,可灵活组合出不同的应用场景:虚拟主播、现场推销货、商品导购、语音助理、远程语音助理、数字人互动、数字人面试官及心理测评、贾维斯、Her。开发人员可以利用该项目简单地构建各种类型的数字人或数字助理。该项目各模块之间耦合度非常低,包括声音来源、语音识别、情绪分析、NLP处理、情绪语音合成、语音输出和表情动作输出等模块。每个模块都可以轻松地更换
Fay数字人助理版是fay开源项目的重要分支,专注于构建智能数字助理的开源解决方案。它提供了灵活的模块化设计,使开发人员能够定制和组合各种功能模块,包括情绪分析、NLP处理、语音合成和语音输出等。Fay数字人助理版为开发人员提供了强大的工具和资源,用于构建智能、个性化和多功能的数字助理应用。通过该版本,开发人员可以轻松创建适用于各种场景和领域的数字人助理,为用户提供智能化的语音交互和个性化服务

## **推荐集成的开源仓库**
## **推荐集成**

消费级pc大模型:https://github.com/THUDM/ChatGLM-6B

全平台抖音抓包:https://github.com/wwengg/douyin
消费级pc大模型(ChatGLM-6B的基础上前置Rasa会话管理):https://m.bilibili.com/video/BV1D14y1f7pr

UE5工程:https://github.com/xszyou/fay-ue5

实时照片驱动集成:https://github.com/waityousea/xuniren
视频三维重建(真人2D驱动):https://github.com/waityousea/xuniren



## **Fay数字人助理版**

## **一、Fay控制器用途**
注:带货版移到分支[`fay-sales-edition`](https://github.com/TheRamU/Fay/tree/fay-sales-edition)

![](images/controller.png)

![](images/kzq.jpg)


### **远程语音助理** [`PC demo`](https://github.com/TheRamU/Fay/tree/main/python_connector_demo)
### **PC远程助理** [`PC demo`](https://github.com/TheRamU/Fay/tree/main/python_connector_demo)

### **远程语音助理** [`android demo`](https://github.com/TheRamU/Fay/tree/main/android_connector_demo)
### **手机远程助理** [`android demo`](https://github.com/TheRamU/Fay/tree/main/android_connector_demo)



Expand All @@ -48,8 +48,6 @@ UE5工程:https://github.com/xszyou/fay-ue5

工程及运行包:https://github.com/xszyou/fay-ue5

**发您的Fay运行效果视频至公众号领取最新的UE5模型哦**

通讯地址: [`ws://127.0.0.1:10002`](ws://127.0.0.1:10002)(已接通)

消息格式: 查看 [WebSocket.md](https://github.com/TheRamU/Fay/blob/main/WebSocket.md)
Expand All @@ -76,16 +74,7 @@ UE5工程:https://github.com/xszyou/fay-ue5

**注:**

1、去API及会话管理功能将在下一版本发布;

2、以上每个模块可轻易替换成自家核心产品。

3、本地nlp(rasa+chatglm)的替换方法(https://m.bilibili.com/video/BV1D14y1f7pr?wxfid=o7omF0Vs6RIQFUGAzB6LXOBHa6Yg):
1、安装启动chatglm(github)
2、安装rasa 包:rasa、rasa-sdk
3、进入test/rasa目录启动actions:rasa run actions
4、启动rasa api server:rasa run --enable-api -p 5006
5、fay_core.py 引入nlp_rasa.py
以上每个模块可轻易替换成自家核心产品。


### **目录结构**
Expand All @@ -102,7 +91,8 @@ UE5工程:https://github.com/xszyou/fay-ue5
│   ├── xf_aiui.py # 讯飞 人机交互-自然语言处理
│   ├── chatgpt.py # gpt3.5对接
│   ├── yuan_1_0.py # 浪潮.源大模型对接
│   └── xf_ltp.py # 讯飞 性感分析
│   ├── nlp_rasa.py # ChatGLM-6B的基础上前置Rasa会话管理(强烈推荐)
│   └── xf_ltp.py # 讯飞 情感分析
├── bin # 可执行文件目录
├── core # 数字人核心
│   ├── fay_core.py # 数字人核心模块
Expand All @@ -126,68 +116,20 @@ UE5工程:https://github.com/xszyou/fay-ue5

## **三、升级日志**

**2023.04:**

+ 抖音直播互动数据对接更换成系统代理抓包pd解码的方式(运行直播伴侣即可);
+ 提供本地nlp的对接代码(rasa+chatglm);
+ 修复若干逻辑及说明错误;
+ 提高抖音字幕监听的稳定性及包兼容性;
+ 更新gpt接口:局部接入代理、prompt上补充角色模拟及简化回复内容(感谢 江湖墨明);
+ 修复控制台输入测试消息的bug;
+ 补充推荐两个优秀仓库:chatglm、全平台的抖音抓包。




**2023.03:**

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

**2023.02:**

+ 提供chatgpt及yuan1.0作为选择。

**2023.01:**

+ 控制器pc内网穿透,音频输入输出设备远程直连;
+ 提供android 音频输入输出工程示例代码;
+ 提供python音频输入输出工程示例代码(远程PC、树莓派等可用);
+ 补传1.0语音指令音乐播放模块(暂不支持远程播放);
+ 重构及补充若干工具模块:websocket、多线程、缓冲器、音频流录制器等;
+ 修复1.x版本的多个bug;
+ 集成看板娘;

**2022.12:**

+ 上传bin目录(用于直播互动);

**2022.11:**

+ 更新抖音直播获取粉丝互动数据的xpath;

**2022.10.27:**

+ 更新mac上的麦克风参数;
+ 解决mac上无法重启问题;
+ 上传brew安装脚本。

**2022.10.17:**
+ 更新语音指令;
+ 补充人设语法;

**2023.05.12:**

+ 打出Fay数字人助理版作为主分支(带货版移到分支[`fay-sales-edition`](https://github.com/TheRamU/Fay/tree/fay-sales-edition));
+ 添加Fay助理的文字沟通窗口(文字与语音同步);
+ 添加沟通记录本地保存功能;
+ 升级ChatGLM-6B的应用逻辑,长文本与语音回复分享;


## **四、安装说明**


### **环境**
- Python 3.8.0 +
- Chrome 浏览器 (若不开启直播功能,可跳过)
- Python 3.8、3.9、3.10
- Windows、macos、linux

### **安装依赖**

Expand Down Expand Up @@ -215,9 +157,10 @@ python main.py
| ./ai_module/ms_tts_sdk.py | 微软 文本转情绪语音(可选) | https://azure.microsoft.com/zh-cn/services/cognitive-services/text-to-speech/ |
| ./ai_module/xf_ltp.py | 讯飞 情感分析 | https://www.xfyun.cn/service/emotion-analysis |
| ./utils/ngrok_util.py | ngrok.cc 外网穿透(可选) | http://ngrok.cc |
| ./ai_module/yuan_1_0.py | 浪潮源大模型(NLP 3选1) | https://air.inspur.com/ |
| ./ai_module/chatgpt.py | ChatGPT(NLP 3选1) | ******* |
| ./ai_module/xf_aiui.py | 讯飞自然语言处理(NLP 3选1) | https://aiui.xfyun.cn/solution/webapi |
| ./ai_module/yuan_1_0.py | 浪潮源大模型(NLP 4选1) | https://air.inspur.com/ |
| ./ai_module/chatgpt.py | ChatGPT(NLP 4选1) | ******* |
| ./ai_module/xf_aiui.py | 讯飞自然语言处理(NLP 4选1) | https://aiui.xfyun.cn/solution/webapi |
| ./ai_module/nlp_rasa.py | ChatGLM-6B的基础上前置Rasa会话管理(NLP 4选1) | https://m.bilibili.com/video/BV1D14y1f7pr |



Expand All @@ -226,47 +169,21 @@ python main.py

### **使用说明**

+ 抖音虚拟主播:启动bin/Release_2.85/2.85.exe + fay控制器(抖音输入源开启、展板播放关闭)+ 数字人 + 抖音伴侣(测试时直接通过浏览器打开别人的直播间);
+ 现场推销货:fay控制器(展板播放关闭、填写商品信息)+ 数字人;
+ 商品导购:fay控制器(麦克风输入源开启、展板播放关闭、填写商品信息、填写商品Q&A)+ 数字人;
+ 语音助理:fay控制器(麦克风输入源开启、展板播放开启);
+ 远程语音助理:fay控制器(展板播放关闭)+ 远程设备接入;
+ 数字人互动:fay控制器(麦克风输入源开启、展板播放关闭、填写性格Q&A)+ 数字人;
+ 数字人面试官及心理测评:联系免费领取;
+ 语音助理:fay控制器(麦克风输入源开启、面板播放开启);
+ 远程语音助理:fay控制器(面板播放关闭)+ 远程设备接入;
+ 数字人互动:fay控制器(麦克风输入源开启、面板播放关闭、填写性格Q&A)+ 数字人;
+ 贾维斯、Her:加入我们一起完成。


### **语音指令**

- **关闭核心**
关闭
再见
你走吧
- **静音**
静音
闭嘴
我想静静
- **取消静音**
取消静音
你在哪呢?
你可以说话了
- **播放歌曲**(网易音乐库不可用,寻找替代中)
播放歌曲
播放音乐
唱首歌
放首歌
听音乐
你会唱歌吗?
- **暂停播放**
暂停播放
别唱了
我不想听了


### **图形界面**

![](images/controller.png)
| 关闭核心 | 静音 | 取消静音 |
| ------------------------- | -------------------------- | ------------------------------------------------------------ |
| 关闭、再见、你走吧 | 静音、闭嘴、我想静静 | 取消静音、你在哪呢、你可以说话了 |

| 播放歌曲(音乐库暂不可用) | 暂停播放 | 更多 |
| ------------------------- | -------------------------- | ------------------------------------------------------------ |
| 播放歌曲、播放音乐、唱首歌、放首歌、听音乐、你会唱歌吗 | 暂停播放、别唱了、我不想听了 | 没有了... |

### **人设**
数字人属性,与用户交互中能做出相应的响应。
Expand All @@ -276,9 +193,9 @@ python main.py

### **接收来源**

#### 抖音
#### 文本输入

填入直播间地址,实现与直播间粉丝交互
通过沟通窗口与助理文本沟通

#### 麦克风

Expand All @@ -289,34 +206,26 @@ python main.py
可以接入远程音频输入,远程音频输出


#### 商品栏

填入商品介绍,数字人将自动讲解商品。

当用户对商品有疑问时,数字人可自动跳转至对应商品并解答问题。

配合抖音接收来源,实现直播间自动带货。



### 相关文章:
1、集成消费级pc大模型(ChatGLM-6B的基础上前置Rasa会话管理):https://m.bilibili.com/video/BV1D14y1f7pr

1、[(34条消息) 非常全面的数字人解决方案_郭泽斌之心的博客-CSDN博客_数字人算法](https://blog.csdn.net/aa84758481/article/details/124758727)

2、[(34条消息) Fay数字人开源项目在mac 上的安装办法_郭泽斌之心的博客-CSDN博客](https://blog.csdn.net/aa84758481/article/details/127551258)
2、[(34条消息) 非常全面的数字人解决方案_郭泽斌之心的博客-CSDN博客_数字人算法](https://blog.csdn.net/aa84758481/article/details/124758727)

3、【开源项目:数字人FAY——Fay新架构使用讲解】 https://www.bilibili.com/video/BV1NM411B7Ab/?share_source=copy_web&vd_source=64cd9062f5046acba398177b62bea9ad

4、【开源项目FAY——UE工程讲解】https://www.bilibili.com/video/BV1C8411P7Ac?vd_source=64cd9062f5046acba398177b62bea9ad

5、m1机器安装办法(Gason提供):https://www.zhihu.com/question/437075754

6、bilbil主页:[xszyou的个人空间_哔哩哔哩_bilibili](https://space.bilibili.com/2111554564)



二次开发指导联系QQ 467665317
商务联系QQ 467665317,我们提供:开发顾问、数字人模型定制及高校教学资源实施服务
http://yafrm.com/forum.php?mod=viewthread&tid=302

关注公众号获取最新微信技术交流群二维码(请先star本仓库)
关注公众号获取最新微信技术交流群二维码(**请先star本仓库**

![](images/gzh.jpg)

Expand Down
1 change: 0 additions & 1 deletion ai_module/ali_nls.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def __connect(self):
self.finalResults = ""
self.done = False
self.__frames.clear()
websocket.enableTrace(False)
self.__ws = websocket.WebSocketApp(self.__URL + '?token=' + _token, on_message=self.on_message)
self.__ws.on_open = self.on_open
self.__ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
Expand Down
11 changes: 11 additions & 0 deletions ai_module/nlp_rasa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import json
import requests

def question(cont):
url="http://localhost:5005/webhooks/rest/webhook"
req = json.dumps({"sender": "user", "message": cont})
headers = {'content-type': 'application/json'}
r = requests.post(url, headers=headers, data=req)
lists = json.loads(r.text)

return lists
79 changes: 79 additions & 0 deletions core/content_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import sqlite3
import time
import threading
import functools
def synchronized(func):
@functools.wraps(func)
def wrapper(self, *args, **kwargs):
with self.lock:
return func(self, *args, **kwargs)
return wrapper
class Content_Db:

def __init__(self) -> None:
self.lock = threading.Lock()



#初始化
def init_db(self):
conn = sqlite3.connect('fay.db')
c = conn.cursor()
c.execute('''CREATE TABLE T_Msg
(id INTEGER PRIMARY KEY autoincrement,
type char(10),
way char(10),
content TEXT NOT NULL,
createtime Int);''')
conn.commit()
conn.close()




#添加对话
@synchronized
def add_content(self,type,way,content):
conn = sqlite3.connect("fay.db")
cur = conn.cursor()
cur.execute("insert into T_Msg (type,way,content,createtime) values (?,?,?,?)",(type,way,content,int(time.time())))

conn.commit()
conn.close()
return cur.lastrowid



#获取对话内容
@synchronized
def get_list(self,way,order,limit):
conn = sqlite3.connect("fay.db")
cur = conn.cursor()
if(way == 'all'):
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg order by createtime "+order+" limit ?",(limit,))
elif(way == 'notappended'):
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg where way != 'appended' order by createtime "+order+" limit ?",(limit,))
else:
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg where way = ? order by createtime "+order+" limit ?",(way,limit,))

list = cur.fetchall()
conn.close()
return list





# a = Content_Db()
# s = a.get_list('all','desc',10)
# print(s)










Loading

0 comments on commit d90d699

Please sign in to comment.