1 Star 0 Fork 1

RexHuang936 / metahuman-stream

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

A streaming digital human based on the Ernerf model, realize audio video synchronous dialogue. It can basically achieve commercial effects.
基于ernerf模型的流式数字人,实现音视频同步对话。基本可以达到商用效果

![Watch the video]

1. Installation

Tested on Ubuntu 20.04, Python3.10, Pytorch 1.12 and CUDA 11.3

1.1 Install dependency

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
pip install -r requirements.txt
pip install "git+https://github.com/facebookresearch/pytorch3d.git"
pip install tensorflow-gpu==2.8.0

linux cuda环境搭建可以参考这篇文章 https://zhuanlan.zhihu.com/p/674972886

1.2 安装rtmpstream库

参照 https://github.com/lipku/python_rtmpstream

2. Run

2.1 运行rtmpserver (srs)

docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5

2.2 启动数字人:

python app.py

如果访问不了huggingface,在运行前

export HF_ENDPOINT=https://hf-mirror.com

运行成功后,用vlc访问rtmp://serverip/live/livestream

2.3 网页端数字人播报输入文字

安装并启动nginx

apt install nginx
nginx

将echo.html和mpegts-1.7.3.min.js拷到/var/www/html下

用浏览器打开http://serverip/echo.html, 在文本框输入任意文字,提交。数字人播报该段文字

2.4 使用LLM模型进行数字人对话

目前借鉴数字人对话系统LinlyTalker的方式,LLM模型支持Chatgpt,Qwen和GeminiPro。需要在app.py中填入自己的api_key。
安装并启动nginx,将chat.html和mpegts-1.7.3.min.js拷到/var/www/html下

用浏览器打开http://serverip/chat.html

2.5 使用本地tts服务,支持声音克隆

运行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

3. Docker Run

不需要第1步的安装,直接运行。

docker run --gpus all -it --network=host --rm  registry.cn-hangzhou.aliyuncs.com/lipku/nerfstream:v1.3

srs和nginx的运行同2.1和2.3

4. Data flow

5. 数字人模型文件

可以替换成自己训练的模型(https://github.com/Fictionarry/ER-NeRF)

.
├── data
   ├── data_kf.json
   ├── au.csv			
   ├── pretrained
   └── └── ngp_kf.pth

6. 性能分析

  1. 帧率
    在Tesla T4显卡上测试整体fps为18左右,如果去掉音视频编码推流,帧率在20左右。用4090显卡可以达到40多帧/秒。
    优化:新开一个线程运行音视频编码推流
  2. 延时
    整体延时5s多
    (1)tts延时2s左右,目前用的edgetts,需要将每句话转完后一次性输入,可以优化tts改成流式输入
    (2)wav2vec延时1s多,需要缓存50帧音频做计算,可以通过-m设置context_size来减少延时
    (3)srs转发延时,设置srs服务器减少缓冲延时。具体配置可看 https://ossrs.net/lts/zh-cn/docs/v5/doc/low-latency, 配置了一个低延时版本
docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/lipku/srs:v1.1

7. TODO

  • 添加chatgpt实现数字人对话
  • 声音克隆
  • 数字人静音时用一段视频代替

如果本项目对你有帮助,帮忙点个star。也欢迎感兴趣的朋友一起来完善该项目。
Email: lipku@foxmail.com
微信公众号:数字人技术

MIT License Copyright (c) 2023 LiHengzhong Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
Python 等 6 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/RexHuang936/metahuman-stream.git
git@gitee.com:RexHuang936/metahuman-stream.git
RexHuang936
metahuman-stream
metahuman-stream
main

搜索帮助