diff --git a/README.md b/README.md index 6f7e994..93a885e 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,7 @@ export HF_ENDPOINT=https://hf-mirror.com apt install nginx nginx ``` -修改echo.html中websocket和视频播放地址,将serverip替换成实际服务器ip -然后将echo.html和mpegts-1.7.3.min.js拷到/var/www/html下 - +将echo.html和mpegts-1.7.3.min.js拷到/var/www/html下 用浏览器打开http://serverip/echo.html, 在文本框输入任意文字,提交。数字人播报该段文字 diff --git a/app.py b/app.py index cf8380d..bc7a730 100644 --- a/app.py +++ b/app.py @@ -66,7 +66,27 @@ def echo_socket(ws): if len(message)==0: return '输入信息为空' else: - txt_to_audio(message) + txt_to_audio(message) + +@sockets.route('/humanchat') +def chat_socket(ws): + # 获取WebSocket对象 + #ws = request.environ.get('wsgi.websocket') + # 如果没有获取到,返回错误信息 + if not ws: + print('未建立连接!') + return 'Please use WebSocket' + # 否则,循环接收和发送消息 + else: + print('建立连接!') + while True: + message = ws.receive() + + if len(message)==0: + return '输入信息为空' + else: + res=llm(message) + txt_to_audio(res) def render(): nerfreal.render() diff --git a/chat.html b/chat.html new file mode 100644 index 0000000..bb117f8 --- /dev/null +++ b/chat.html @@ -0,0 +1,63 @@ + + +
+ + + + + + + + +