Real time interactive streaming digital human
Real time interactive streaming digital human, realize audio video synchronous dialogue. It can basically achieve commercial effects.
实时交互流式数字人,实现音视频同步对话。基本可以达到商用效果
Tested on Ubuntu 20.04, Python3.10, Pytorch 1.12 and CUDA 11.3
conda create -n nerfstream python=3.10
conda activate nerfstream
conda install pytorch==1.12.1 torchvision==0.13.1 cudatoolkit=11.3 -c pytorch
pip install -r requirements.txt
#如果只用musetalk模型,不需要安装下面的库
pip install "git+https://github.com/facebookresearch/pytorch3d.git"
pip install tensorflow-gpu==2.8.0
pip install --upgrade "protobuf<=3.20.1"
安装常见问题FAQ
linux cuda环境搭建可以参考这篇文章 https://zhuanlan.zhihu.com/p/674972886
默认采用ernerf模型,webrtc推流到srs
export CANDIDATE='<服务器外网ip>'
docker run --rm --env CANDIDATE=$CANDIDATE \
-p 1935:1935 -p 8080:8080 -p 1985:1985 -p 8000:8000/udp \
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5 \
objs/srs -c conf/rtc.conf
python app.py
如果访问不了huggingface,在运行前
export HF_ENDPOINT=https://hf-mirror.com
用浏览器打开http://serverip:8010/rtcpush.html, 在文本框输入任意文字,提交。数字人播报该段文字
备注:服务端需要开放端口 tcp:8000,8010,1985; udp:8000
目前借鉴数字人对话系统LinlyTalker的方式,LLM模型支持Chatgpt,Qwen和GeminiPro。需要在app.py中填入自己的api_key。
用浏览器打开http://serverip:8010/rtcpushchat.html
可以任意选用下面两种服务,推荐用gpt-sovits
服务部署参照gpt-sovits
运行
python app.py --tts gpt-sovits --TTS_SERVER http://127.0.0.1:5000 --CHARACTER test --EMOTION default
运行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
然后运行,其中ref.wav为需要克隆的声音文件
python app.py --tts xtts --REF_FILE data/ref.wav --TTS_SERVER http://localhost:9000
如果训练模型时用的hubert提取音频特征,用如下命令启动数字人
python app.py --asr_model facebook/hubert-large-ls960-ft
python app.py --bg_img bc.jpg
ffmpeg -i fullbody.mp4 -vf crop="400:400:100:5" train.mp4
用train.mp4训练模型
ffmpeg -i fullbody.mp4 -vf fps=25 -qmin 1 -q:v 1 -start_number 0 data/fullbody/img/%d.jpg
python app.py --fullbody --fullbody_img data/fullbody/img --fullbody_offset_x 100 --fullbody_offset_y 5 --fullbody_width 580 --fullbody_height 1080 --W 400 --H 400
ffmpeg -i silence.mp4 -vf fps=25 -qmin 1 -q:v 1 -start_number 0 data/customvideo/img/%d.png
python app.py --customvideo --customvideo_img data/customvideo/img --customvideo_imgnum 100
此种模式不需要srs
python app.py --transport webrtc
用浏览器打开http://serverip:8010/webrtc.html
安装rtmpstream库
参照 https://github.com/lipku/python_rtmpstream
启动srs
docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5
python app.py --transport rtmp --push_url 'rtmp://localhost/live/livestream'
用浏览器打开http://serverip:8010/echo.html
暂不支持rtmp推送
conda install ffmpeg
pip install --no-cache-dir -U openmim
mim install mmengine
mim install "mmcv>=2.0.1"
mim install "mmdet>=3.1.0"
mim install "mmpose>=1.1.0"
git clone https://github.com/TMElyralab/MuseTalk.git
cd MuseTalk
修改configs/inference/realtime.yaml,将preparation改为True
python -m scripts.realtime_inference --inference_config configs/inference/realtime.yaml
运行后将results/avatars下文件拷到本项目的data/avatars下
不需要第1步的安装,直接运行。
docker run --gpus all -it --network=host --rm registry.cn-hangzhou.aliyuncs.com/lipku/nerfstream:v1.3
docker版本已经不是最新代码,可以作为一个空环境,把最新代码拷进去运行。
另外提供autodl教程: autodl教程
可以替换成自己训练的模型(https://github.com/Fictionarry/ER-NeRF)
.
├── data
│ ├── data_kf.json
│ ├── au.csv
│ ├── pretrained
│ └── └── ngp_kf.pth
如果本项目对你有帮助,帮忙点个star。也欢迎感兴趣的朋友一起来完善该项目。
知识星球: https://t.zsxq.com/7NMyO
微信公众号:数字人技术
Buy me a coffee