You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.1 KiB
Markdown

A streaming digital human based on the Ernerf model realize audio video synchronous dialogue. It can basically achieve commercial effects.
基于ernerf模型的流式数字人实现音视频同步对话。基本可以达到商用效果
2 years ago
2 years ago
[![Watch the video]](/assets/demo.mp4)
2 years ago
2 years ago
## 1. Installation
2 years ago
2 years ago
Tested on Ubuntu 20.04, Python3.10, Pytorch 1.12 and CUDA 11.3
2 years ago
2 years ago
### 1.1 Install dependency
2 years ago
```bash
2 years ago
conda create -n nerfstream python=3.10
conda install pytorch==1.12.1 torchvision==0.13.1 cudatoolkit=11.3 -c pytorch
conda activate nerfstream
2 years ago
pip install -r requirements.txt
pip install "git+https://github.com/facebookresearch/pytorch3d.git"
pip install tensorflow-gpu==2.8.0
2 years ago
```
linux cuda环境搭建可以参考这篇文章 https://zhuanlan.zhihu.com/p/674972886
2 years ago
2 years ago
### 1.2 安装rtmpstream库
参照 https://github.com/lipku/python_rtmpstream
2 years ago
2 years ago
## 2. Run
2 years ago
2 years ago
### 2.1 运行rtmpserver (srs)
2 years ago
```
docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5
2 years ago
```
2 years ago
### 2.2 启动数字人:
2 years ago
```python
python app.py
2 years ago
```
如果访问不了huggingface在运行前
2 years ago
```
export HF_ENDPOINT=https://hf-mirror.com
2 years ago
```
运行成功后用vlc访问rtmp://serverip/live/livestream
2 years ago
2 years ago
### 2.3 网页端数字人播报输入文字
安装并启动nginx
2 years ago
```
apt install nginx
nginx
2 years ago
```
将echo.html和mpegts-1.7.3.min.js拷到/var/www/html下
2 years ago
2 years ago
用浏览器打开http://serverip/echo.html, 在文本框输入任意文字,提交。数字人播报该段文字
## 3. 更多使用
### 3.1 使用LLM模型进行数字人对话
2 years ago
2 years ago
目前借鉴数字人对话系统[LinlyTalker](https://github.com/Kedreamix/Linly-Talker)的方式LLM模型支持Chatgpt,Qwen和GeminiPro。需要在app.py中填入自己的api_key。
2 years ago
安装并启动nginx将chat.html和mpegts-1.7.3.min.js拷到/var/www/html下
用浏览器打开http://serverip/chat.html
1 year ago
### 3.2 使用本地tts服务,支持声音克隆
1 year ago
运行xtts服务参照 https://github.com/coqui-ai/xtts-streaming-server
```
docker run --gpus=all -e COQUI_TOS_AGREED=1 --rm -p 9000:80 ghcr.io/coqui-ai/xtts-streaming-server:latest
```
1 year ago
然后运行其中ref.wav为需要克隆的声音文件
1 year ago
```
python app.py --tts xtts --ref_file data/ref.wav
```
### 3.3 音频特征用hubert
如果训练模型时用的hubert提取音频特征用如下命令启动数字人
```
python app.py --asr_model facebook/hubert-large-ls960-ft
```
2 years ago
## 4. Docker Run
2 years ago
不需要第1步的安装直接运行。
2 years ago
```
2 years ago
docker run --gpus all -it --network=host --rm registry.cn-hangzhou.aliyuncs.com/lipku/nerfstream:v1.3
2 years ago
```
2 years ago
srs和nginx的运行同2.1和2.3
2 years ago
## 5. Data flow
![](/assets/dataflow.png)
2 years ago
## 6. 数字人模型文件
可以替换成自己训练的模型(https://github.com/Fictionarry/ER-NeRF)
2 years ago
```python
.
├── data
1 year ago
│ ├── data_kf.json
│ ├── au.csv
2 years ago
│ ├── pretrained
2 years ago
│ └── └── ngp_kf.pth
2 years ago
```
## 7. 性能分析
2 years ago
1. 帧率
1 year ago
在Tesla T4显卡上测试整体fps为18左右如果去掉音视频编码推流帧率在20左右。用4090显卡可以达到40多帧/秒。
2 years ago
优化:新开一个线程运行音视频编码推流
2. 延时
整体延时5s多
1tts延时2s左右目前用的edgetts需要将每句话转完后一次性输入可以优化tts改成流式输入
2wav2vec延时1s多需要缓存50帧音频做计算可以通过-m设置context_size来减少延时
2 years ago
3srs转发延时设置srs服务器减少缓冲延时。具体配置可看 https://ossrs.net/lts/zh-cn/docs/v5/doc/low-latency, 配置了一个低延时版本
```python
docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/lipku/srs:v1.1
```
2 years ago
## 8. TODO
2 years ago
- [x] 添加chatgpt实现数字人对话
1 year ago
- [x] 声音克隆
2 years ago
- [ ] 数字人静音时用一段视频代替
2 years ago
如果本项目对你有帮助帮忙点个star。也欢迎感兴趣的朋友一起来完善该项目。
1 year ago
Email: lipku@foxmail.com
1 year ago
微信公众号:数字人技术
![](https://mmbiz.qpic.cn/sz_mmbiz_jpg/l3ZibgueFiaeyfaiaLZGuMGQXnhLWxibpJUS2gfs8Dje6JuMY8zu2tVyU9n8Zx1yaNncvKHBMibX0ocehoITy5qQEZg/640?wxfrom=12&tp=wxpic&usePicPrefetch=1&wx_fmt=jpeg&from=appmsg)