livetalking/README.md

96 lines
2.9 KiB
Markdown
Raw Normal View History

2023-12-28 13:11:18 +08:00
A streaming digital human based on the Ernerf model realize audio video synchronous dialogue. It can basically achieve commercial effects.
基于ernerf模型的流式数字人实现音视频同步对话。基本可以达到商用效果
2023-12-19 09:41:52 +08:00
2024-01-10 15:14:22 +08:00
[![Watch the video]](/assets/demo.mp4)
2023-12-19 09:41:52 +08:00
2024-01-13 20:12:08 +08:00
## 1. Installation
2023-12-19 09:41:52 +08:00
2024-01-13 20:12:08 +08:00
Tested on Ubuntu 20.04, Python3.10, Pytorch 1.12 and CUDA 11.3
2023-12-19 09:41:52 +08:00
2024-01-13 20:12:08 +08:00
### 1.1 Install dependency
2023-12-19 09:41:52 +08:00
2023-12-28 13:11:18 +08:00
```bash
2024-01-06 21:17:34 +08:00
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
2023-12-19 09:41:52 +08:00
pip install -r requirements.txt
pip install "git+https://github.com/facebookresearch/pytorch3d.git"
2023-12-28 13:11:18 +08:00
pip install tensorflow-gpu==2.8.0
2023-12-19 09:41:52 +08:00
```
2023-12-28 13:11:18 +08:00
linux cuda环境搭建可以参考这篇文章 https://zhuanlan.zhihu.com/p/674972886
2023-12-19 09:41:52 +08:00
2024-01-13 20:15:09 +08:00
### 1.2 安装rtmpstream库
2023-12-28 13:11:18 +08:00
参照 https://github.com/lipku/python_rtmpstream
2023-12-19 09:41:52 +08:00
2024-01-13 20:12:08 +08:00
## 2. Run
2023-12-19 09:41:52 +08:00
2024-01-13 20:12:08 +08:00
### 2.1 运行rtmpserver (srs)
2023-12-19 09:41:52 +08:00
```
2023-12-28 13:11:18 +08:00
docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5
2023-12-19 09:41:52 +08:00
```
2024-01-13 20:12:08 +08:00
### 2.2 启动数字人:
2023-12-19 09:41:52 +08:00
2023-12-28 13:11:18 +08:00
```python
python app.py
2023-12-19 09:41:52 +08:00
```
2023-12-28 13:11:18 +08:00
如果访问不了huggingface在运行前
2023-12-19 09:41:52 +08:00
```
2023-12-28 13:11:18 +08:00
export HF_ENDPOINT=https://hf-mirror.com
2023-12-19 09:41:52 +08:00
```
2023-12-28 13:11:18 +08:00
运行成功后用vlc访问rtmp://serverip/live/livestream
2023-12-19 09:41:52 +08:00
2024-01-13 20:12:08 +08:00
### 2.3 网页端数字人播报输入文字
2023-12-28 13:11:18 +08:00
安装并启动nginx
2023-12-19 09:41:52 +08:00
```
2023-12-28 13:11:18 +08:00
apt install nginx
nginx
2023-12-19 09:41:52 +08:00
```
2023-12-28 13:11:18 +08:00
修改echo.html中websocket和视频播放地址将serverip替换成实际服务器ip
然后将echo.html和mpegts-1.7.3.min.js拷到/var/www/html下
2023-12-19 09:41:52 +08:00
2024-01-13 20:12:08 +08:00
用浏览器打开http://serverip/echo.html, 在文本框输入任意文字,提交。数字人播报该段文字
2024-01-13 20:15:09 +08:00
2024-01-13 20:12:08 +08:00
## 3. Docker Run
不需要第1步的安装直接运行。
2024-01-07 14:19:21 +08:00
```
2024-01-13 20:12:08 +08:00
docker run --gpus all -it --network=host --rm registry.cn-hangzhou.aliyuncs.com/lipku/nerfstream:v1.3
2024-01-07 14:19:21 +08:00
```
2024-01-13 20:12:08 +08:00
srs和nginx的运行同2.1和2.3
2024-01-07 14:19:21 +08:00
2024-01-13 20:12:08 +08:00
## 4. Data flow
2023-12-28 13:11:18 +08:00
![](/assets/dataflow.png)
2023-12-19 09:41:52 +08:00
2024-01-13 20:12:08 +08:00
## 5. 数字人模型文件
2023-12-28 13:11:18 +08:00
可以替换成自己训练的模型(https://github.com/Fictionarry/ER-NeRF)
2023-12-19 09:41:52 +08:00
```python
.
├── data
2023-12-28 13:11:18 +08:00
│ ├── data_kf.json
2023-12-19 09:41:52 +08:00
│ ├── pretrained
│ └── └── ngp_kg.pth
```
2024-01-13 20:12:08 +08:00
## 6. 性能分析
1. 帧率
在Tesla T4显卡上测试整体fps为18左右如果去掉音视频编码推流帧率在20左右。用4090显卡应该能达到25帧欢迎有显卡资源的同学提供数据。
优化:新开一个线程运行音视频编码推流
2. 延时
整体延时5s多
1tts延时2s左右目前用的edgetts需要将每句话转完后一次性输入可以优化tts改成流式输入
2wav2vec延时1s多需要缓存50帧音频做计算可以通过-m设置context_size来减少延时
3srs转发延时设置srs服务器减少缓冲延时
## 7. TODO
2023-12-28 13:11:18 +08:00
- 添加chatgpt实现数字人对话
- 声音克隆
- 数字人静音时用一段视频代替
2023-12-19 09:41:52 +08:00
2023-12-28 13:11:18 +08:00
如果本项目对你有帮助帮忙点个star。也欢迎感兴趣的朋友一起来完善该项目。
Email: lipku@foxmail.com