Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bffed8bb8a | ||
|
|
ff3c0ab7ca | ||
|
|
6d0addf005 | ||
|
|
1520874432 | ||
|
|
eaade698fb | ||
|
|
b4f4995ff9 | ||
|
|
76a7ac04c9 | ||
|
|
3e1765a26d | ||
|
|
95b80f6bb1 | ||
|
|
caf5f3f04c | ||
|
|
41b8fac3aa | ||
|
|
f6f240bc4b | ||
|
|
a79d8d61e3 | ||
|
|
a5e748f775 | ||
|
|
0fc4edc431 | ||
|
|
3378d2cd8f | ||
|
|
e004a85f53 | ||
|
|
91cd843cfe | ||
|
|
880b669877 | ||
|
|
e53ba28c65 | ||
|
|
bdb6d3c093 | ||
|
|
9af77d0f47 | ||
|
|
15291bfcf2 | ||
|
|
ae228f3b86 | ||
|
|
b8803f92e7 | ||
|
|
1515784700 | ||
|
|
06e2909fda | ||
|
|
9012deeae7 | ||
|
|
31657e1dc0 | ||
|
|
5a08a41cc8 | ||
|
|
3e48d7e331 | ||
|
|
5993470d3f | ||
|
|
18acec1a81 | ||
|
|
701936326d | ||
|
|
5b7d613a35 | ||
|
|
0ce55ff7a4 | ||
|
|
595edb6f80 | ||
|
|
d4b75c5d99 | ||
|
|
1988bced60 | ||
|
|
60f8dbf418 | ||
|
|
a708382cfd | ||
|
|
1d95e1420a | ||
|
|
e1bcff82e2 | ||
|
|
216f1b701f | ||
|
|
0ea18d87a3 | ||
|
|
6a79d57a93 | ||
|
|
31f596f96c | ||
|
|
7f99895116 | ||
|
|
789d756ce1 | ||
|
|
570fb29d3c | ||
|
|
d7dc636d3f | ||
|
|
67d3a8f94f | ||
|
|
7d7b8ddfb1 | ||
|
|
74826c1c59 | ||
|
|
d138e1dcef | ||
|
|
372dc8ecb0 | ||
|
|
e8bfe9850e | ||
|
|
ad50fbe3c9 | ||
|
|
61636dd085 | ||
|
|
5ea669be5a | ||
|
|
5260b62287 | ||
|
|
984a84edc1 | ||
|
|
32548878e4 | ||
|
|
093db56c98 | ||
|
|
a17f8518d6 | ||
|
|
e9e9c5355d | ||
|
|
61ee21d627 | ||
|
|
a86707f1ff | ||
|
|
be42d80061 | ||
|
|
16da6f9696 | ||
|
|
427b0aa197 | ||
|
|
a2432d45cc | ||
|
|
f62b5d4f22 | ||
|
|
001225c27b | ||
|
|
3e68f188fa | ||
|
|
2d75eb76f1 | ||
|
|
bcc3ebb6bb | ||
|
|
52c4e65686 | ||
|
|
44a5afb8a2 | ||
|
|
3057d35111 | ||
|
|
bdf99bc554 | ||
|
|
e70415690c | ||
|
|
9b5e4eb9b7 | ||
|
|
e2324d3c37 | ||
|
|
c395c31e46 | ||
|
|
94662e17ba | ||
|
|
0bfa5cf723 | ||
|
|
d2f29f335e | ||
|
|
4423cb85c2 | ||
|
|
46fb997b52 | ||
|
|
dcf8c134a2 | ||
|
|
7c0df908e9 | ||
|
|
7bb76d7ced | ||
|
|
1cfb8de3a0 | ||
|
|
768d2b82d6 | ||
|
|
7a4431d80c | ||
|
|
7e63e1d607 | ||
|
|
bda6c1e3ed | ||
|
|
a9d116df2f | ||
|
|
e7c6c32d40 | ||
|
|
cdfe24fcdb | ||
|
|
a9199171df | ||
|
|
76b9542507 | ||
|
|
d30b6a8dcf | ||
|
|
76b5ad1c99 | ||
|
|
7840e83ada | ||
|
|
c4ac9da3e5 | ||
|
|
311e5d5cfd | ||
|
|
a1f6795d44 | ||
|
|
f8a30ce261 | ||
|
|
ccfd15bda0 | ||
|
|
a9610e6ee7 | ||
|
|
733b36b869 | ||
|
|
70c3f9f929 | ||
|
|
210bda15b8 | ||
|
|
93be1b3443 | ||
|
|
533a001aeb | ||
|
|
0b57d78732 | ||
|
|
dce9d1a1e2 | ||
|
|
1cff39cec4 | ||
|
|
c7392dcf5a | ||
|
|
3eb39ebef2 | ||
|
|
041d8d5643 | ||
|
|
1c19046442 | ||
|
|
3d696aaa64 | ||
|
|
76516336af | ||
|
|
fc18677409 | ||
|
|
029d3730a8 | ||
|
|
8509e62114 | ||
|
|
6e8f9ca22e | ||
|
|
dbc1a515d2 | ||
|
|
70221e7f62 | ||
|
|
28f921c38d | ||
|
|
30a773601f | ||
|
|
6cddd5c704 | ||
|
|
709bc12b1c | ||
|
|
171892a894 | ||
|
|
535ab315d9 | ||
|
|
de28247b7e | ||
|
|
6186eb753a | ||
|
|
a18bc85a9b | ||
|
|
806e4c398d | ||
|
|
a4f1abfa42 | ||
|
|
f2efd9718e | ||
|
|
031c56e30b | ||
|
|
994715d9eb | ||
|
|
90f7af7afa | ||
|
|
2f3c466833 | ||
|
|
d742bca205 | ||
|
|
8e51d52155 | ||
|
|
a1c4f72470 | ||
|
|
2c11bba25e | ||
|
|
42a5b4fae7 | ||
|
|
a61aedc906 | ||
|
|
7b72d517ab | ||
|
|
1c43295fbc | ||
|
|
747c432ea3 | ||
|
|
235bdba42a | ||
|
|
b3f603732e | ||
|
|
6091eae7fc | ||
|
|
ef36ad1ec1 | ||
|
|
f832611d41 | ||
|
|
4d50eeb830 | ||
|
|
abf1fa0ef4 | ||
|
|
903c0e51ee | ||
|
|
ce6a711c8e | ||
|
|
095fe72db0 | ||
|
|
1b6cd01eaf | ||
|
|
ac1e19f621 | ||
|
|
faf2890695 | ||
|
|
75f0773247 | ||
|
|
8b81b918cc | ||
|
|
5fe91a80fa | ||
|
|
6f3dee74be | ||
|
|
9391e8cc1a | ||
|
|
8aa5537029 | ||
|
|
f40c3ec0f6 | ||
|
|
408143e55e | ||
|
|
71eef4693d | ||
|
|
0b7814882d | ||
|
|
99cf26ee9e | ||
|
|
775f754ff3 | ||
|
|
b6ee2dee68 | ||
|
|
ef25e82544 | ||
|
|
14b7631dd6 | ||
|
|
ef0099b3c9 | ||
|
|
38d60affce | ||
|
|
c8a2c9bbd4 | ||
|
|
9c2084b62e | ||
|
|
9edd083411 | ||
|
|
80e8ecc4f4 | ||
|
|
e5d3048fb2 | ||
|
|
67c4622ca7 | ||
|
|
121f1c4698 | ||
|
|
ff9fb9eb1b | ||
|
|
b07a8796ff | ||
|
|
8ad5ff457e | ||
|
|
99f6209c57 | ||
|
|
1b3a55b105 | ||
|
|
8b59a94324 | ||
|
|
b17f20eece | ||
|
|
d9062a0bb0 | ||
|
|
6066c20676 | ||
|
|
1c7ba50def | ||
|
|
e53b24ef47 | ||
|
|
1a978abcc1 | ||
|
|
b91f4e4281 | ||
|
|
86978329eb | ||
|
|
337ecf0efe | ||
|
|
4c3eb90bfc | ||
|
|
018a0422b7 | ||
|
|
f18ac169fa | ||
|
|
04746961f2 | ||
|
|
3939c81044 | ||
|
|
fdbe5fa556 | ||
|
|
dff8b8ccec | ||
|
|
8d11b47241 | ||
|
|
78e5c52932 | ||
|
|
46c7759718 | ||
|
|
2f5e8c2019 | ||
|
|
2508d3f965 | ||
|
|
3699d28dd0 | ||
|
|
be7146fa89 | ||
|
|
66f4ea0a84 | ||
|
|
84ff897b46 | ||
|
|
29c7b2a920 | ||
|
|
83ded8458a | ||
|
|
e93053d412 | ||
|
|
2370936dfd | ||
|
|
06bd7aed36 | ||
|
|
ff560a317c | ||
|
|
6892befa15 | ||
|
|
fadf18b7fc | ||
|
|
d9b632c031 | ||
|
|
35fd4d2770 | ||
|
|
1b8963f311 | ||
|
|
710218b5b5 | ||
|
|
60cbe1571c | ||
|
|
6740d6a723 | ||
|
|
eb14e50941 | ||
|
|
37ac778ff4 | ||
|
|
bc5586a077 | ||
|
|
eb7ac93e72 | ||
|
|
bf8a8bddf1 | ||
|
|
d1badcb28c | ||
|
|
f6e79e17b7 | ||
|
|
eead126f7a | ||
|
|
e5ef61dfd3 | ||
|
|
eb130aa57f | ||
|
|
c9b10494d8 | ||
|
|
b8136ac1dc | ||
|
|
6d5b53fcd5 | ||
|
|
5cf8eb5e71 | ||
|
|
f037f4c7de | ||
|
|
618be6d108 | ||
|
|
7fb028205f | ||
|
|
a09e56bbfd | ||
|
|
c0c01a0285 | ||
|
|
af0854a840 | ||
|
|
f70652f165 | ||
|
|
7c440f47b6 | ||
|
|
6967cc2293 | ||
|
|
97ad1f6f22 | ||
|
|
f62f530f97 | ||
|
|
815647ae02 | ||
|
|
ce1e3fb04d | ||
|
|
1a86828ae6 | ||
|
|
8831ea22b7 | ||
|
|
1a411da133 | ||
|
|
e2a7534aa5 | ||
|
|
f8a92e1710 | ||
|
|
953a232654 | ||
|
|
4afa29554f | ||
|
|
dc78057823 | ||
|
|
53ca586847 | ||
|
|
4f7e96ed7d | ||
|
|
0397ef3fad | ||
|
|
aa38591d90 | ||
|
|
b87b82bec9 | ||
|
|
2e719e2ccc | ||
|
|
909b41174b | ||
|
|
2c33ee5b32 | ||
|
|
82beae0e59 | ||
|
|
7f979e2f52 | ||
|
|
e94eb302a8 | ||
|
|
8ffbb614f7 | ||
|
|
7a589f4a7b | ||
|
|
04ed5ed980 | ||
|
|
8e5d933745 | ||
|
|
23cd453af8 | ||
|
|
26a3b51162 | ||
|
|
6da3138814 | ||
|
|
b2e6156bbb | ||
|
|
fbd4a22e3e | ||
|
|
dede73e9a5 | ||
|
|
ce358dcd65 | ||
|
|
d533fb83eb | ||
|
|
155ba92ba6 | ||
|
|
039badd265 | ||
|
|
90a9631450 |
@@ -175,3 +175,11 @@ uploadfile
|
|||||||
*.json
|
*.json
|
||||||
.vscode
|
.vscode
|
||||||
.cursor
|
.cursor
|
||||||
|
|
||||||
|
!package.json
|
||||||
|
!**/package.json
|
||||||
|
|
||||||
|
# Do not ignore env and json files inside manager-mobile
|
||||||
|
!main/manager-mobile/**/env/
|
||||||
|
!main/manager-mobile/**/.env*
|
||||||
|
!main/manager-mobile/**/*.json
|
||||||
@@ -21,6 +21,7 @@ RUN apt-get update && \
|
|||||||
|
|
||||||
# 从构建阶段复制Python包和前端构建产物
|
# 从构建阶段复制Python包和前端构建产物
|
||||||
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
||||||
|
COPY --from=builder /usr/local/bin/mcp-proxy /usr/local/bin/mcp-proxy
|
||||||
|
|
||||||
# 复制应用代码
|
# 复制应用代码
|
||||||
COPY main/xiaozhi-server .
|
COPY main/xiaozhi-server .
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<h1 align="center">小智后端服务xiaozhi-esp32-server</h1>
|
<h1 align="center">小智后端服务xiaozhi-esp32-server</h1>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
本项目为开源智能硬件项目
|
本项目基于人机共生智能理论和技术研发智能终端软硬件体系<br/>为开源智能硬件项目
|
||||||
<a href="https://github.com/78/xiaozhi-esp32">xiaozhi-esp32</a>提供后端服务<br/>
|
<a href="https://github.com/78/xiaozhi-esp32">xiaozhi-esp32</a>提供后端服务<br/>
|
||||||
根据<a href="https://ccnphfhqs21z.feishu.cn/wiki/M0XiwldO9iJwHikpXD5cEx71nKh">小智通信协议</a>使用Python、Java、Vue实现<br/>
|
根据<a href="https://ccnphfhqs21z.feishu.cn/wiki/M0XiwldO9iJwHikpXD5cEx71nKh">小智通信协议</a>使用Python、Java、Vue实现<br/>
|
||||||
支持MCP接入点和声纹识别
|
支持MCP接入点和声纹识别
|
||||||
@@ -37,6 +37,14 @@
|
|||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
Spearheaded by Professor Siyuan Liu's Team (South China University of Technology)
|
||||||
|
</br>
|
||||||
|
刘思源教授团队主导研发(华南理工大学)
|
||||||
|
</br>
|
||||||
|
<img src="./docs/images/hnlg.jpg" alt="华南理工大学" width="50%">
|
||||||
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 适用人群 👥
|
## 适用人群 👥
|
||||||
@@ -49,9 +57,9 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="https://www.bilibili.com/video/BV1FMFyejExX" target="_blank">
|
<a href="https://www.bilibili.com/video/BV1C1tCzUEZh" target="_blank">
|
||||||
<picture>
|
<picture>
|
||||||
<img alt="小智esp32连接自己的后台模型" src="docs/images/demo1.png" />
|
<img alt="小智医疗救护车场景" src="docs/images/demo1.png" />
|
||||||
</picture>
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@@ -86,7 +94,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="https://www.bilibili.com/video/BV1Vy96YCE3R" target="_blank">
|
<a href="https://www.bilibili.com/video/BV1vchQzaEse" target="_blank">
|
||||||
<picture>
|
<picture>
|
||||||
<img alt="自定义音色" src="docs/images/demo6.png" />
|
<img alt="自定义音色" src="docs/images/demo6.png" />
|
||||||
</picture>
|
</picture>
|
||||||
@@ -181,13 +189,15 @@
|
|||||||
| 部署方式 | 特点 | 适用场景 | 部署文档 | 配置要求 | 视频教程 |
|
| 部署方式 | 特点 | 适用场景 | 部署文档 | 配置要求 | 视频教程 |
|
||||||
|---------|------|---------|---------|---------|---------|
|
|---------|------|---------|---------|---------|---------|
|
||||||
| **最简化安装** | 智能对话、IOT、MCP、视觉感知 | 低配置环境,数据存储在配置文件,无需数据库 | [①Docker版](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E5%8F%AA%E8%BF%90%E8%A1%8Cserver) / [②源码部署](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%BA%8C%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E5%8F%AA%E8%BF%90%E8%A1%8Cserver)| 如果使用`FunASR`要2核4G,如果全API,要2核2G | - |
|
| **最简化安装** | 智能对话、IOT、MCP、视觉感知 | 低配置环境,数据存储在配置文件,无需数据库 | [①Docker版](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E5%8F%AA%E8%BF%90%E8%A1%8Cserver) / [②源码部署](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%BA%8C%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E5%8F%AA%E8%BF%90%E8%A1%8Cserver)| 如果使用`FunASR`要2核4G,如果全API,要2核2G | - |
|
||||||
| **全模块安装** | 智能对话、IOT、MCP接入点、视觉感知、OTA、智控台 | 完整功能体验,数据存储在数据库 |[①Docker版](./docs/Deployment_all.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E8%BF%90%E8%A1%8C%E5%85%A8%E6%A8%A1%E5%9D%97) / [②源码部署](./docs/Deployment_all.md#%E6%96%B9%E5%BC%8F%E4%BA%8C%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E8%BF%90%E8%A1%8C%E5%85%A8%E6%A8%A1%E5%9D%97) / [③源码部署自动更新教程](./docs/dev-ops-integration.md) | 如果使用`FunASR`要4核8G,如果全API,要2核4G| [本地源码启动视频教程](https://www.bilibili.com/video/BV1wBJhz4Ewe) |
|
| **全模块安装** | 智能对话、IOT、MCP接入点、声纹识别、视觉感知、OTA、智控台 | 完整功能体验,数据存储在数据库 |[①Docker版](./docs/Deployment_all.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E8%BF%90%E8%A1%8C%E5%85%A8%E6%A8%A1%E5%9D%97) / [②源码部署](./docs/Deployment_all.md#%E6%96%B9%E5%BC%8F%E4%BA%8C%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E8%BF%90%E8%A1%8C%E5%85%A8%E6%A8%A1%E5%9D%97) / [③源码部署自动更新教程](./docs/dev-ops-integration.md) | 如果使用`FunASR`要4核8G,如果全API,要2核4G| [本地源码启动视频教程](https://www.bilibili.com/video/BV1wBJhz4Ewe) |
|
||||||
|
|
||||||
|
常见问题及相关教程,可参考[这个链接](./docs/FAQ.md)
|
||||||
|
|
||||||
> 💡 提示:以下是按最新代码部署后的测试平台,有需要可烧录测试,并发为6个,每天会清空数据
|
> 💡 提示:以下是按最新代码部署后的测试平台,有需要可烧录测试,并发为6个,每天会清空数据,
|
||||||
|
|
||||||
```
|
```
|
||||||
智控台地址: https://2662r3426b.vicp.fun
|
智控台地址: https://2662r3426b.vicp.fun
|
||||||
|
智控台(h5版): https://2662r3426b.vicp.fun/h5/index.html
|
||||||
|
|
||||||
服务测试工具: https://2662r3426b.vicp.fun/test/
|
服务测试工具: https://2662r3426b.vicp.fun/test/
|
||||||
OTA接口地址: https://2662r3426b.vicp.fun/xiaozhi/ota/
|
OTA接口地址: https://2662r3426b.vicp.fun/xiaozhi/ota/
|
||||||
@@ -206,28 +216,29 @@ Websocket接口地址: wss://2662r3426b.vicp.fun/xiaozhi/v1/
|
|||||||
|
|
||||||
| 模块名称 | 入门全免费设置 | 流式配置 |
|
| 模块名称 | 入门全免费设置 | 流式配置 |
|
||||||
|:---:|:---:|:---:|
|
|:---:|:---:|:---:|
|
||||||
| ASR(语音识别) | FunASR(本地) | 👍FunASRServer 或 👍DoubaoStreamASR |
|
| ASR(语音识别) | FunASR(本地) | 👍FunASR(本地GPU模式) |
|
||||||
| LLM(大模型) | ChatGLMLLM(智谱glm-4-flash) | 👍DoubaoLLM(火山doubao-1-5-pro-32k-250115) |
|
| LLM(大模型) | ChatGLMLLM(智谱glm-4-flash) | 👍AliLLM(qwen3-235b-a22b-instruct-2507) 或 👍DoubaoLLM(doubao-1-5-pro-32k-250115) |
|
||||||
| VLLM(视觉大模型) | ChatGLMVLLM(智谱glm-4v-flash) | 👍QwenVLVLLM(千问qwen2.5-vl-3b-instructh) |
|
| VLLM(视觉大模型) | ChatGLMVLLM(智谱glm-4v-flash) | 👍QwenVLVLLM(千问qwen2.5-vl-3b-instructh) |
|
||||||
| TTS(语音合成) | ✅LinkeraiTTS(灵犀流式) | 👍HuoshanDoubleStreamTTS(火山双流式语音合成) |
|
| TTS(语音合成) | ✅LinkeraiTTS(灵犀流式) | 👍HuoshanDoubleStreamTTS(火山双流式语音合成) 或 👍AliyunStreamTTS(阿里云流式语音合成) |
|
||||||
| Intent(意图识别) | function_call(函数调用) | function_call(函数调用) |
|
| Intent(意图识别) | function_call(函数调用) | function_call(函数调用) |
|
||||||
| Memory(记忆功能) | mem_local_short(本地短期记忆) | mem_local_short(本地短期记忆) |
|
| Memory(记忆功能) | mem_local_short(本地短期记忆) | mem_local_short(本地短期记忆) |
|
||||||
|
|
||||||
|
如果您关心各组件的耗时,请查阅[小智各组件性能测试报告](https://github.com/xinnan-tech/xiaozhi-performance-research),可按报告中的测试方法在您的环境中实际测试。
|
||||||
|
|
||||||
#### 🔧 测试工具
|
#### 🔧 测试工具
|
||||||
本项目提供以下测试工具,帮助您验证系统和选择合适的模型:
|
本项目提供以下测试工具,帮助您验证系统和选择合适的模型:
|
||||||
|
|
||||||
| 工具名称 | 位置 | 使用方法 | 功能说明 |
|
| 工具名称 | 位置 | 使用方法 | 功能说明 |
|
||||||
|:---:|:---|:---:|:---:|
|
|:---:|:---|:---:|:---:|
|
||||||
| 音频交互测试工具 | main》xiaozhi-server》test》test_page.html | 使用谷歌浏览器直接打开 | 测试音频播放和接收功能,验证Python端音频处理是否正常 |
|
| 音频交互测试工具 | main》xiaozhi-server》test》test_page.html | 使用谷歌浏览器直接打开 | 测试音频播放和接收功能,验证Python端音频处理是否正常 |
|
||||||
| 模型响应测试工具1 | main》xiaozhi-server》performance_tester.py | 执行 `python performance_tester.py` | 测试ASR(语音识别)、LLM(大模型)、TTS(语音合成)三个核心模块的响应速度 |
|
| 模型响应测试工具 | main》xiaozhi-server》performance_tester.py | 执行 `python performance_tester.py` | 测试ASR(语音识别)、LLM(大模型)、VLLM(视觉模型)、TTS(语音合成)三个核心模块的响应速度 |
|
||||||
| 模型响应测试工具2 | main》xiaozhi-server》performance_tester_vllm.py | 执行 `python performance_tester_vllm.py` | 测试VLLM(视觉模型)的响应速度 |
|
|
||||||
|
|
||||||
> 💡 提示:测试模型速度时,只会测试配置了密钥的模型。
|
> 💡 提示:测试模型速度时,只会测试配置了密钥的模型。
|
||||||
|
|
||||||
---
|
---
|
||||||
## 功能清单 ✨
|
## 功能清单 ✨
|
||||||
### 已实现 ✅
|
### 已实现 ✅
|
||||||
|

|
||||||
| 功能模块 | 描述 |
|
| 功能模块 | 描述 |
|
||||||
|:---:|:---|
|
|:---:|:---|
|
||||||
| 核心架构 | 基于WebSocket和HTTP服务器,提供完整的控制台管理和认证系统 |
|
| 核心架构 | 基于WebSocket和HTTP服务器,提供完整的控制台管理和认证系统 |
|
||||||
@@ -245,7 +256,7 @@ Websocket接口地址: wss://2662r3426b.vicp.fun/xiaozhi/v1/
|
|||||||
|
|
||||||
### 正在开发 🚧
|
### 正在开发 🚧
|
||||||
|
|
||||||
想了解具体开发计划进度,[请点击这里](https://github.com/users/xinnan-tech/projects/3)
|
想了解具体开发计划进度,[请点击这里](https://github.com/users/xinnan-tech/projects/3)。常见问题及相关教程,可参考[这个链接](./docs/FAQ.md)
|
||||||
|
|
||||||
如果你是一名软件开发者,这里有一份[《致开发者的公开信》](docs/contributor_open_letter.md),欢迎加入!
|
如果你是一名软件开发者,这里有一份[《致开发者的公开信》](docs/contributor_open_letter.md),欢迎加入!
|
||||||
|
|
||||||
@@ -263,7 +274,6 @@ Websocket接口地址: wss://2662r3426b.vicp.fun/xiaozhi/v1/
|
|||||||
---
|
---
|
||||||
|
|
||||||
## 本项目支持的平台/组件列表 📋
|
## 本项目支持的平台/组件列表 📋
|
||||||
|
|
||||||
### LLM 语言模型
|
### LLM 语言模型
|
||||||
|
|
||||||
| 使用方式 | 支持平台 | 免费平台 |
|
| 使用方式 | 支持平台 | 免费平台 |
|
||||||
@@ -347,8 +357,10 @@ Websocket接口地址: wss://2662r3426b.vicp.fun/xiaozhi/v1/
|
|||||||
| <img src="./docs/images/logo_bailing.png" width="160"> | [百聆语音对话机器人](https://github.com/wwbin2017/bailing) | 本项目受[百聆语音对话机器人](https://github.com/wwbin2017/bailing)启发,并在其基础上实现 |
|
| <img src="./docs/images/logo_bailing.png" width="160"> | [百聆语音对话机器人](https://github.com/wwbin2017/bailing) | 本项目受[百聆语音对话机器人](https://github.com/wwbin2017/bailing)启发,并在其基础上实现 |
|
||||||
| <img src="./docs/images/logo_tenclass.png" width="160"> | [十方融海](https://www.tenclass.com/) | 感谢[十方融海](https://www.tenclass.com/)为小智生态制定了标准的通讯协议、多设备兼容性方案及高并发场景实践示范;为本项目提供了全链路技术文档支持 |
|
| <img src="./docs/images/logo_tenclass.png" width="160"> | [十方融海](https://www.tenclass.com/) | 感谢[十方融海](https://www.tenclass.com/)为小智生态制定了标准的通讯协议、多设备兼容性方案及高并发场景实践示范;为本项目提供了全链路技术文档支持 |
|
||||||
| <img src="./docs/images/logo_xuanfeng.png" width="160"> | [玄凤科技](https://github.com/Eric0308) | 感谢[玄凤科技](https://github.com/Eric0308)贡献函数调用框架、MCP通信协议及插件化调用机制的实现代码,通过标准化的指令调度体系与动态扩展能力,显著提升了前端设备(IoT)的交互效率和功能延展性 |
|
| <img src="./docs/images/logo_xuanfeng.png" width="160"> | [玄凤科技](https://github.com/Eric0308) | 感谢[玄凤科技](https://github.com/Eric0308)贡献函数调用框架、MCP通信协议及插件化调用机制的实现代码,通过标准化的指令调度体系与动态扩展能力,显著提升了前端设备(IoT)的交互效率和功能延展性 |
|
||||||
|
| <img src="./docs/images/logo_junsen.png" width="160"> | [huangjunsen](https://github.com/huangjunsen0406) | 感谢[huangjunsen](https://github.com/huangjunsen0406) 贡献`智控台移动端`模块,实现了跨平台移动设备的高效控制与实时交互,大幅提升了系统在移动场景下的操作便捷性和管理效率 |
|
||||||
| <img src="./docs/images/logo_huiyuan.png" width="160"> | [汇远设计](http://ui.kwd988.net/) | 感谢[汇远设计](http://ui.kwd988.net/)为本项目提供专业视觉解决方案,用其服务超千家企业的设计实战经验,赋能本项目产品用户体验 |
|
| <img src="./docs/images/logo_huiyuan.png" width="160"> | [汇远设计](http://ui.kwd988.net/) | 感谢[汇远设计](http://ui.kwd988.net/)为本项目提供专业视觉解决方案,用其服务超千家企业的设计实战经验,赋能本项目产品用户体验 |
|
||||||
| <img src="./docs/images/logo_qinren.png" width="160"> | [西安勤人信息科技](https://www.029app.com/) | 感谢[西安勤人信息科技](https://www.029app.com/)深化本项目视觉体系,确保整体设计风格在多场景应用中的一致性和扩展性 |
|
| <img src="./docs/images/logo_qinren.png" width="160"> | [西安勤人信息科技](https://www.029app.com/) | 感谢[西安勤人信息科技](https://www.029app.com/)深化本项目视觉体系,确保整体设计风格在多场景应用中的一致性和扩展性 |
|
||||||
|
| <img src="./docs/images/logo_contributors.png" width="160"> | [代码贡献者](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors) | 感谢[所有代码贡献者](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors)贡献者,你们的付出让项目更加健壮和强大。 |
|
||||||
|
|
||||||
|
|
||||||
<a href="https://star-history.com/#xinnan-tech/xiaozhi-esp32-server&Date">
|
<a href="https://star-history.com/#xinnan-tech/xiaozhi-esp32-server&Date">
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
<h1 align="center">Xiaozhi Backend Service xiaozhi-esp32-server</h1>
|
<h1 align="center">Xiaozhi Backend Service xiaozhi-esp32-server</h1>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
This project provides backend services for the open-source smart hardware project
|
This project is based on human-machine symbiotic intelligence theory and technology to develop intelligent terminal hardware and software systems<br/>providing backend services for the open-source intelligent hardware project
|
||||||
<a href="https://github.com/78/xiaozhi-esp32">xiaozhi-esp32</a><br/>
|
<a href="https://github.com/78/xiaozhi-esp32">xiaozhi-esp32</a><br/>
|
||||||
Implemented using Python, Java, and Vue according to the <a href="https://ccnphfhqs21z.feishu.cn/wiki/M0XiwldO9iJwHikpXD5cEx71nKh">Xiaozhi Communication Protocol</a><br/>
|
Implemented using Python, Java, and Vue according to the <a href="https://ccnphfhqs21z.feishu.cn/wiki/M0XiwldO9iJwHikpXD5cEx71nKh">Xiaozhi Communication Protocol</a><br/>
|
||||||
Helps you quickly set up your Xiaozhi server
|
Supports MCP endpoints and voiceprint recognition
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="./README.md">中文</a>
|
<a href="./README.md">中文</a>
|
||||||
· <a href="./docs/FAQ.md">FAQ</a>
|
· <a href="./docs/FAQ.md">FAQ</a>
|
||||||
· <a href="https://github.com/xinnan-tech/xiaozhi-esp32-server/issues">Report Issues</a>
|
· <a href="https://github.com/xinnan-tech/xiaozhi-esp32-server/issues">Report Issues</a>
|
||||||
· <a href="./README_en.md#deployment-documentation">Deployment Guide</a>
|
· <a href="./README.md#%E9%83%A8%E7%BD%B2%E6%96%87%E6%A1%A3">Deployment Docs</a>
|
||||||
· <a href="https://github.com/xinnan-tech/xiaozhi-esp32-server/releases">Release Notes</a>
|
· <a href="https://github.com/xinnan-tech/xiaozhi-esp32-server/releases">Release Notes</a>
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
@@ -37,41 +37,49 @@ Helps you quickly set up your Xiaozhi server
|
|||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
Spearheaded by Professor Siyuan Liu's Team (South China University of Technology)
|
||||||
|
</br>
|
||||||
|
刘思源教授团队主导研发(华南理工大学)
|
||||||
|
</br>
|
||||||
|
<img src="./docs/images/hnlg.jpg" alt="South China University of Technology" width="50%">
|
||||||
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Target Users 👥
|
## Target Users 👥
|
||||||
|
|
||||||
This project requires ESP32 hardware devices. If you have purchased ESP32-related hardware, successfully connected to Brother Xia's backend service, and want to set up your own `xiaozhi-esp32` backend service, then this project is perfect for you.
|
This project requires ESP32 hardware devices to work. If you have purchased ESP32-related hardware, successfully connected to Brother Xia's deployed backend service, and want to build your own `xiaozhi-esp32` backend service independently, then this project is perfect for you.
|
||||||
|
|
||||||
Want to see it in action? Check out these videos 🎥
|
Want to see the usage effects? Click the videos below 🎥
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="https://www.bilibili.com/video/BV1FMFyejExX" target="_blank">
|
<a href="https://www.bilibili.com/video/BV1FMFyejExX" target="_blank">
|
||||||
<picture>
|
<picture>
|
||||||
<img alt="Xiaozhi esp32 connecting to own backend model" src="docs/images/demo1.png" />
|
<img alt="Xiaozhi ESP32 connecting to own backend model" src="docs/images/demo1.png" />
|
||||||
</picture>
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="https://www.bilibili.com/video/BV1CDKWemEU6" target="_blank">
|
<a href="https://www.bilibili.com/video/BV1CDKWemEU6" target="_blank">
|
||||||
<picture>
|
<picture>
|
||||||
<img alt="Custom voice" src="docs/images/demo2.png" />
|
<img alt="Custom voice timbre" src="docs/images/demo2.png" />
|
||||||
</picture>
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="https://www.bilibili.com/video/BV12yA2egEaC" target="_blank">
|
<a href="https://www.bilibili.com/video/BV12yA2egEaC" target="_blank">
|
||||||
<picture>
|
<picture>
|
||||||
<img alt="Using Cantonese" src="docs/images/demo3.png" />
|
<img alt="Using Cantonese for communication" src="docs/images/demo3.png" />
|
||||||
</picture>
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="https://www.bilibili.com/video/BV1pNXWYGEx1" target="_blank">
|
<a href="https://www.bilibili.com/video/BV1pNXWYGEx1" target="_blank">
|
||||||
<picture>
|
<picture>
|
||||||
<img alt="Control home appliances" src="docs/images/demo5.png" />
|
<img alt="Controlling home appliances" src="docs/images/demo5.png" />
|
||||||
</picture>
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@@ -85,16 +93,16 @@ Want to see it in action? Check out these videos 🎥
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="https://www.bilibili.com/video/BV1Vy96YCE3R" target="_blank">
|
<a href="https://www.bilibili.com/video/BV1vchQzaEse" target="_blank">
|
||||||
<picture>
|
<picture>
|
||||||
<img alt="Custom voice" src="docs/images/demo6.png" />
|
<img alt="Custom voice timbre" src="docs/images/demo6.png" />
|
||||||
</picture>
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="https://www.bilibili.com/video/BV1VC96Y5EMH" target="_blank">
|
<a href="https://www.bilibili.com/video/BV1VC96Y5EMH" target="_blank">
|
||||||
<picture>
|
<picture>
|
||||||
<img alt="Play music" src="docs/images/demo7.png" />
|
<img alt="Playing music" src="docs/images/demo7.png" />
|
||||||
</picture>
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@@ -108,14 +116,14 @@ Want to see it in action? Check out these videos 🎥
|
|||||||
<td>
|
<td>
|
||||||
<a href="https://www.bilibili.com/video/BV178XuYfEpi" target="_blank">
|
<a href="https://www.bilibili.com/video/BV178XuYfEpi" target="_blank">
|
||||||
<picture>
|
<picture>
|
||||||
<img alt="IOT command control" src="docs/images/demo9.png" />
|
<img alt="IOT command control devices" src="docs/images/demo9.png" />
|
||||||
</picture>
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="https://www.bilibili.com/video/BV17LXWYvENb" target="_blank">
|
<a href="https://www.bilibili.com/video/BV17LXWYvENb" target="_blank">
|
||||||
<picture>
|
<picture>
|
||||||
<img alt="News broadcast" src="docs/images/demo0.png" />
|
<img alt="News broadcasting" src="docs/images/demo0.png" />
|
||||||
</picture>
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@@ -131,7 +139,7 @@ Want to see it in action? Check out these videos 🎥
|
|||||||
<td>
|
<td>
|
||||||
<a href="https://www.bilibili.com/video/BV1Co76z7EvK" target="_blank">
|
<a href="https://www.bilibili.com/video/BV1Co76z7EvK" target="_blank">
|
||||||
<picture>
|
<picture>
|
||||||
<img alt="Photo recognition" src="docs/images/demo12.png" />
|
<img alt="Photo recognition of objects" src="docs/images/demo12.png" />
|
||||||
</picture>
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@@ -143,20 +151,29 @@ Want to see it in action? Check out these videos 🎥
|
|||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<a href="https://www.bilibili.com/video/BV1ZQKUzYExM" target="_blank">
|
||||||
|
<picture>
|
||||||
|
<img alt="MCP endpoint" src="docs/images/demo13.png" />
|
||||||
|
</picture>
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<a href="https://www.bilibili.com/video/BV1Exu3zqEDe" target="_blank">
|
||||||
|
<picture>
|
||||||
|
<img alt="Voiceprint recognition" src="docs/images/demo14.png" />
|
||||||
|
</picture>
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Warning ⚠️
|
## Warnings ⚠️
|
||||||
|
|
||||||
1. This project is open-source software. This software has no commercial relationship with any third-party API service providers (including but not limited to speech recognition, large models, speech synthesis, and other platforms) and does not provide any form of guarantee for their service quality or financial security.
|
1. This project is open-source software. This software has no commercial partnership with any third-party API service providers (including but not limited to speech recognition, large models, speech synthesis, and other platforms) that it interfaces with, and does not provide any form of guarantee for their service quality or financial security. It is recommended that users prioritize service providers with relevant business licenses and carefully read their service agreements and privacy policies. This software does not host any account keys, does not participate in fund flows, and does not bear the risk of recharge fund losses.
|
||||||
It is recommended that users prioritize service providers with relevant business licenses and carefully read their service agreements and privacy policies. This software does not host any account keys, does not participate in fund transfers, and does not bear the risk of recharge fund losses.
|
|
||||||
|
|
||||||
2. This project's functionality is not complete and has not passed network security testing. Please do not use it in production environments. If you deploy this project for learning in a public network environment, please ensure necessary protection measures are in place.
|
2. The functionality of this project is not complete and has not passed network security assessment. Please do not use it in production environments. If you deploy this project for learning purposes in a public network environment, please ensure necessary protection measures are in place.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -164,18 +181,20 @@ It is recommended that users prioritize service providers with relevant business
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
This project provides two deployment methods. Please choose according to your specific needs:
|
This project provides two deployment methods. Please choose based on your specific needs:
|
||||||
|
|
||||||
#### 🚀 Deployment Method Selection
|
#### 🚀 Deployment Method Selection
|
||||||
| Deployment Method | Features | Suitable Scenarios | Deployment Guide | Requirements | Video Tutorial |
|
| Deployment Method | Features | Applicable Scenarios | Deployment Docs | Configuration Requirements | Video Tutorials |
|
||||||
|---------|------|---------|---------|---------|---------|
|
|---------|------|---------|---------|---------|---------|
|
||||||
| **Simplified Installation** | Smart dialogue, IOT functionality, data stored in configuration files | Low-configuration environment, no database needed | [Docker Version](./docs/Deployment.md#method-1-docker-server-only) / [Source Code Deployment](./docs/Deployment.md#method-2-local-source-code-server-only) | 2 cores 4G if using `FunASR`, 2 cores 2G if using all APIs | - |
|
| **Simplified Installation** | Intelligent dialogue, IOT, MCP, visual perception | Low-configuration environments, data stored in config files, no database required | [①Docker Version](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E5%8F%AA%E8%BF%90%E8%A1%8Cserver) / [②Source Code Deployment](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%BA%8C%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E5%8F%AA%E8%BF%90%E8%A1%8Cserver)| 2 cores 4GB if using `FunASR`, 2 cores 2GB if all APIs | - |
|
||||||
| **Full Module Installation** | Smart dialogue, IOT, OTA, Control Panel, data stored in database | Complete functionality experience | [Docker Version](./docs/Deployment_all.md#method-1-docker-full-modules) / [Source Code Deployment](./docs/Deployment_all.md#method-2-local-source-code-full-modules) | 4 cores 8G if using `FunASR`, 2 cores 4G if using all APIs | [Local Source Code Startup Video Tutorial](https://www.bilibili.com/video/BV1wBJhz4Ewe) / [Local Source Code Auto-Update Tutorial](./docs/dev-ops-integration.md) |
|
| **Full Module Installation** | Intelligent dialogue, IOT, MCP endpoints, voiceprint recognition, visual perception, OTA, intelligent control console | Complete functionality experience, data stored in database |[①Docker Version](./docs/Deployment_all.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E8%BF%90%E8%A1%8C%E5%85%A8%E6%A8%A1%E5%9D%97) / [②Source Code Deployment](./docs/Deployment_all.md#%E6%96%B9%E5%BC%8F%E4%BA%8C%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E8%BF%90%E8%A1%8C%E5%85%A8%E6%A8%A1%E5%9D%97) / [③Source Code Deployment Auto-Update Tutorial](./docs/dev-ops-integration.md) | 4 cores 8GB if using `FunASR`, 2 cores 4GB if all APIs| [Local Source Code Startup Video Tutorial](https://www.bilibili.com/video/BV1wBJhz4Ewe) |
|
||||||
|
|
||||||
> 💡 Note: Below are the test platforms deployed with the latest code. You can flash and test if needed. Concurrent users: 6, data will be cleared daily
|
|
||||||
|
> 💡 Note: Below is a test platform deployed with the latest code. You can burn and test if needed. Concurrent users: 6, data will be cleared daily.
|
||||||
|
|
||||||
```
|
```
|
||||||
Control Panel Address: https://2662r3426b.vicp.fun
|
Intelligent Control Console Address: https://2662r3426b.vicp.fun
|
||||||
|
Intelligent Control Console Address (H5): https://2662r3426b.vicp.fun/h5/index.html
|
||||||
|
|
||||||
Service Test Tool: https://2662r3426b.vicp.fun/test/
|
Service Test Tool: https://2662r3426b.vicp.fun/test/
|
||||||
OTA Interface Address: https://2662r3426b.vicp.fun/xiaozhi/ota/
|
OTA Interface Address: https://2662r3426b.vicp.fun/xiaozhi/ota/
|
||||||
@@ -184,74 +203,103 @@ Websocket Interface Address: wss://2662r3426b.vicp.fun/xiaozhi/v1/
|
|||||||
|
|
||||||
#### 🚩 Configuration Description and Recommendations
|
#### 🚩 Configuration Description and Recommendations
|
||||||
> [!Note]
|
> [!Note]
|
||||||
> The default configuration of this project is `Entry Level Free` settings. For better results, we recommend using `Full Streaming Configuration`.
|
> This project provides two configuration schemes:
|
||||||
>
|
>
|
||||||
> Since version `0.5.2`, this project supports full streaming throughout the entire lifecycle. Compared to versions before `0.5`, response speed has improved by approximately `2.5 seconds`
|
> 1. `Entry Level Free Settings`: Suitable for personal and home use, all components use free solutions, no additional payment required.
|
||||||
|
>
|
||||||
|
> 2. `Streaming Configuration`: Suitable for demonstrations, training, scenarios with more than 2 concurrent users, etc. Uses streaming processing technology for faster response speed and better experience.
|
||||||
|
>
|
||||||
|
> Starting from version `0.5.2`, the project supports streaming configuration. Compared to earlier versions, response speed is improved by approximately `2.5 seconds`, significantly improving user experience.
|
||||||
|
|
||||||
| Module Name | Entry Level Free Settings | Full Streaming Configuration |
|
| Module Name | Entry Level Free Settings | Streaming Configuration |
|
||||||
|---------|---------|------|
|
|:---:|:---:|:---:|
|
||||||
| ASR(Speech Recognition) | FunASR(Local) | ✅DoubaoASR(Volcano Streaming Speech Recognition) |
|
| ASR(Speech Recognition) | FunASR(Local) | 👍FunASRServer or 👍DoubaoStreamASR |
|
||||||
| LLM(Large Language Model) | ChatGLMLLM(Zhipu glm-4-flash) | ✅DoubaoLLM(Volcano doubao-1-5-pro-32k-250115) |
|
| LLM(Large Model) | ChatGLMLLM(Zhipu glm-4-flash) | 👍DoubaoLLM(Volcano doubao-1-5-pro-32k-250115) |
|
||||||
| VLLM(Vision Large Model) | ChatGLMVLLM(Zhipu glm-4v-flash) | ✅ChatGLMVLLM(Zhipu glm-4v-flash) |
|
| VLLM(Vision Large Model) | ChatGLMVLLM(Zhipu glm-4v-flash) | 👍QwenVLVLLM(Qwen qwen2.5-vl-3b-instructh) |
|
||||||
| TTS(Speech Synthesis) | EdgeTTS(Microsoft Speech) | ✅HuoshanDoubleStreamTTS(Volcano Double Streaming Speech Synthesis) |
|
| TTS(Speech Synthesis) | ✅LinkeraiTTS(Lingxi streaming) | 👍HuoshanDoubleStreamTTS(Volcano dual-stream speech synthesis) |
|
||||||
| Intent(Intent Recognition) | function_call(Function Call) | ✅function_call(Function Call) |
|
| Intent(Intent Recognition) | function_call(Function calling) | function_call(Function calling) |
|
||||||
| Memory(Memory Function) | mem_local_short(Local Short-term Memory) | ✅mem_local_short(Local Short-term Memory) |
|
| Memory(Memory function) | mem_local_short(Local short-term memory) | mem_local_short(Local short-term memory) |
|
||||||
|
|
||||||
|
#### 🔧 Testing Tools
|
||||||
|
This project provides the following testing tools to help you verify the system and choose suitable models:
|
||||||
|
|
||||||
|
| Tool Name | Location | Usage Method | Function Description |
|
||||||
|
|:---:|:---|:---:|:---:|
|
||||||
|
| Audio Interaction Test Tool | main》xiaozhi-server》test》test_page.html | Open directly with Google Chrome | Tests audio playback and reception functions, verifies if Python-side audio processing is normal |
|
||||||
|
| Model Response Test Tool 1 | main》xiaozhi-server》performance_tester.py | Execute `python performance_tester.py` | Tests response speed of three core modules: ASR(speech recognition), LLM(large model), TTS(speech synthesis) |
|
||||||
|
| Model Response Test Tool 2 | main》xiaozhi-server》performance_tester_vllm.py | Execute `python performance_tester_vllm.py` | Tests VLLM(vision model) response speed |
|
||||||
|
|
||||||
|
> 💡 Note: When testing model speed, only models with configured keys will be tested.
|
||||||
|
|
||||||
---
|
---
|
||||||
## Feature List ✨
|
## Feature List ✨
|
||||||
### Implemented ✅
|
### Implemented ✅
|
||||||
|

|
||||||
| Feature Module | Description |
|
| Feature Module | Description |
|
||||||
|---------|------|
|
|:---:|:---|
|
||||||
| Communication Protocol | Based on `xiaozhi-esp32` protocol, implements data interaction through WebSocket |
|
| Core Architecture | Based on WebSocket and HTTP servers, provides complete console management and authentication system |
|
||||||
| Dialogue Interaction | Supports wake-up dialogue, manual dialogue, and real-time interruption. Auto-sleep after long periods of no dialogue |
|
| Voice Interaction | Supports streaming ASR(speech recognition), streaming TTS(speech synthesis), VAD(voice activity detection), supports multi-language recognition and voice processing |
|
||||||
| Intent Recognition | Supports LLM intent recognition, function call, reducing hard-coded intent judgment |
|
| Voiceprint Recognition | Supports multi-user voiceprint registration, management, and recognition, processes in parallel with ASR, real-time speaker identity recognition and passes to LLM for personalized responses |
|
||||||
| Multi-language Recognition | Supports Mandarin, Cantonese, English, Japanese, Korean (default using FunASR) |
|
| Intelligent Dialogue | Supports multiple LLM(large language models), implements intelligent dialogue |
|
||||||
| LLM Module | Supports flexible LLM module switching, default using ChatGLMLLM, can also use Ali Bailian, DeepSeek, Ollama, etc. |
|
| Visual Perception | Supports multiple VLLM(vision large models), implements multimodal interaction |
|
||||||
| TTS Module | Supports EdgeTTS (default), Volcano Engine Doubao TTS, and other TTS interfaces |
|
| Intent Recognition | Supports LLM intent recognition, Function Call function calling, provides plugin-based intent processing mechanism |
|
||||||
| Memory Function | Supports ultra-long memory, local summary memory, and no memory modes |
|
| Memory System | Supports local short-term memory, mem0ai interface memory, with memory summarization functionality |
|
||||||
| IOT Function | Supports managing registered device IOT functionality, supports smart IoT control based on dialogue context |
|
| Tool Calling | Supports client IOT protocol, client MCP protocol, server MCP protocol, MCP endpoint protocol, custom tool functions |
|
||||||
| Control Panel | Provides Web management interface, supports agent management, user management, system configuration, etc. |
|
| Management Backend | Provides Web management interface, supports user management, system configuration, and device management |
|
||||||
|
| Testing Tools | Provides performance testing tools, vision model testing tools, and audio interaction testing tools |
|
||||||
|
| Deployment Support | Supports Docker deployment and local deployment, provides complete configuration file management |
|
||||||
|
| Plugin System | Supports functional plugin extensions, custom plugin development, and plugin hot-loading |
|
||||||
|
|
||||||
### In Development 🚧
|
### Under Development 🚧
|
||||||
|
|
||||||
To learn about specific development progress, [click here](https://github.com/users/xinnan-tech/projects/3)
|
To learn about specific development plan progress, [click here](https://github.com/users/xinnan-tech/projects/3)
|
||||||
|
|
||||||
If you are a software developer, here is an [Open Letter to Developers](docs/contributor_open_letter.md). Welcome to join!
|
If you are a software developer, here is an [Open Letter to Developers](docs/contributor_open_letter.md). Welcome to join!
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Product Ecosystem 👬
|
## Product Ecosystem 👬
|
||||||
Xiaozhi is an ecosystem. When using this product, you might also want to check out other excellent projects in this ecosystem
|
Xiaozhi is an ecosystem. When using this product, you can also check out other excellent projects in this ecosystem
|
||||||
|
|
||||||
| Project Name | Project Address | Project Description |
|
| Project Name | Project Address | Project Description |
|
||||||
|:---------------------|:--------|:--------|
|
|:---------------------|:--------|:--------|
|
||||||
| Xiaozhi Android Client | [xiaozhi-android-client](https://github.com/TOM88812/xiaozhi-android-client) | A Flutter-based Android and iOS voice dialogue application supporting real-time voice interaction and text dialogue. |
|
| Xiaozhi Android Client | [xiaozhi-android-client](https://github.com/TOM88812/xiaozhi-android-client) | An Android and iOS voice dialogue application based on xiaozhi-server, supporting real-time voice interaction and text dialogue.<br/>Currently a Flutter version, connecting iOS and Android platforms. |
|
||||||
| Xiaozhi PC Client | [py-xiaozhi](https://github.com/Huang-junsen/py-xiaozhi) | This project provides a Python-based Xiaozhi AI client, allowing you to experience Xiaozhi AI's functionality through code even without physical hardware. |
|
| Xiaozhi Desktop Client | [py-xiaozhi](https://github.com/Huang-junsen/py-xiaozhi) | This project provides a Python-based AI client for beginners, allowing users to experience Xiaozhi AI functionality through code even without physical hardware conditions. |
|
||||||
| Xiaozhi Java Server | [xiaozhi-esp32-server-java](https://github.com/joey-zhou/xiaozhi-esp32-server-java) | The Java version of Xiaozhi open-source backend service is a Java-based open-source project.<br/>It includes both frontend and backend services, aiming to provide users with a complete backend service solution. |
|
| Xiaozhi Java Server | [xiaozhi-esp32-server-java](https://github.com/joey-zhou/xiaozhi-esp32-server-java) | Xiaozhi open-source backend service Java version is a Java-based open-source project.<br/>It includes frontend and backend services, aiming to provide users with a complete backend service solution. |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Supported Platforms/Components List 📋
|
## Supported Platforms/Components List 📋
|
||||||
|
|
||||||
### LLM Language Models
|
### LLM Language Models
|
||||||
|
|
||||||
| Usage Method | Supported Platforms | Free Platforms |
|
| Usage Method | Supported Platforms | Free Platforms |
|
||||||
|:---:|:---:|:---:|
|
|:---:|:---:|:---:|
|
||||||
| openai interface call | Ali Bailian, Volcano Engine Doubao, DeepSeek, Zhipu ChatGLM, Gemini | Zhipu ChatGLM, Gemini |
|
| OpenAI interface calls | Alibaba Bailian, Volcano Engine Doubao, DeepSeek, Zhipu ChatGLM, Gemini | Zhipu ChatGLM, Gemini |
|
||||||
| ollama interface call | Ollama | - |
|
| Ollama interface calls | Ollama | - |
|
||||||
| dify interface call | Dify | - |
|
| Dify interface calls | Dify | - |
|
||||||
| fastgpt interface call | Fastgpt | - |
|
| FastGPT interface calls | FastGPT | - |
|
||||||
| coze interface call | Coze | - |
|
| Coze interface calls | Coze | - |
|
||||||
|
|
||||||
In fact, any LLM that supports openai interface calls can be integrated and used.
|
In fact, any LLM that supports OpenAI interface calls can be integrated and used.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VLLM Vision Models
|
||||||
|
|
||||||
|
| Usage Method | Supported Platforms | Free Platforms |
|
||||||
|
|:---:|:---:|:---:|
|
||||||
|
| OpenAI interface calls | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM |
|
||||||
|
|
||||||
|
In fact, any VLLM that supports OpenAI interface calls can be integrated and used.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### TTS Speech Synthesis
|
### TTS Speech Synthesis
|
||||||
|
|
||||||
| Usage Method | Supported Platforms | Free Platforms |
|
| Usage Method | Supported Platforms | Free Platforms |
|
||||||
|:---:|:---:|:---:|
|
|:---:|:---:|:---:|
|
||||||
| API Call | EdgeTTS, Volcano Engine Doubao TTS, Tencent Cloud, Alibaba Cloud TTS, CosyVoiceSiliconflow, TTS302AI, CozeCnTTS, GizwitsTTS, ACGNTTS, OpenAITTS | EdgeTTS, CosyVoiceSiliconflow(partial) |
|
| Interface calls | EdgeTTS, Volcano Engine Doubao TTS, Tencent Cloud, Alibaba Cloud TTS, CosyVoiceSiliconflow, TTS302AI, CozeCnTTS, GizwitsTTS, ACGNTTS, OpenAITTS, Lingxi Streaming TTS | Lingxi Streaming TTS, EdgeTTS, CosyVoiceSiliconflow(partial) |
|
||||||
| Local Service | FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3, MinimaxTTS | FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3, MinimaxTTS |
|
| Local services | FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3, MinimaxTTS | FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3, MinimaxTTS |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -259,7 +307,7 @@ In fact, any LLM that supports openai interface calls can be integrated and used
|
|||||||
|
|
||||||
| Type | Platform Name | Usage Method | Pricing Model | Notes |
|
| Type | Platform Name | Usage Method | Pricing Model | Notes |
|
||||||
|:---:|:---------:|:----:|:----:|:--:|
|
|:---:|:---------:|:----:|:----:|:--:|
|
||||||
| VAD | SileroVAD | Local Usage | Free | |
|
| VAD | SileroVAD | Local use | Free | |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -267,8 +315,16 @@ In fact, any LLM that supports openai interface calls can be integrated and used
|
|||||||
|
|
||||||
| Usage Method | Supported Platforms | Free Platforms |
|
| Usage Method | Supported Platforms | Free Platforms |
|
||||||
|:---:|:---:|:---:|
|
|:---:|:---:|:---:|
|
||||||
| Local Usage | FunASR, SherpaASR | FunASR, SherpaASR |
|
| Local use | FunASR, SherpaASR | FunASR, SherpaASR |
|
||||||
| API Call | DoubaoASR, FunASRServer, TencentASR, AliyunASR | FunASRServer |
|
| Interface calls | DoubaoASR, FunASRServer, TencentASR, AliyunASR | FunASRServer |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Voiceprint Recognition
|
||||||
|
|
||||||
|
| Usage Method | Supported Platforms | Free Platforms |
|
||||||
|
|:---:|:---:|:---:|
|
||||||
|
| Local use | 3D-Speaker | 3D-Speaker |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -276,8 +332,8 @@ In fact, any LLM that supports openai interface calls can be integrated and used
|
|||||||
|
|
||||||
| Type | Platform Name | Usage Method | Pricing Model | Notes |
|
| Type | Platform Name | Usage Method | Pricing Model | Notes |
|
||||||
|:------:|:---------------:|:----:|:---------:|:--:|
|
|:------:|:---------------:|:----:|:---------:|:--:|
|
||||||
| Memory | mem0ai | API Call | 1000 calls/month quota | |
|
| Memory | mem0ai | Interface calls | 1000 times/month quota | |
|
||||||
| Memory | mem_local_short | Local Summary | Free | |
|
| Memory | mem_local_short | Local summarization | Free | |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -285,8 +341,8 @@ In fact, any LLM that supports openai interface calls can be integrated and used
|
|||||||
|
|
||||||
| Type | Platform Name | Usage Method | Pricing Model | Notes |
|
| Type | Platform Name | Usage Method | Pricing Model | Notes |
|
||||||
|:------:|:-------------:|:----:|:-------:|:---------------------:|
|
|:------:|:-------------:|:----:|:-------:|:---------------------:|
|
||||||
| Intent | intent_llm | API Call | Based on LLM pricing | Uses large model for intent recognition, highly versatile |
|
| Intent | intent_llm | Interface calls | Based on LLM pricing | Recognizes intent through large models, strong generalization |
|
||||||
| Intent | function_call | API Call | Based on LLM pricing | Uses large model function calls for intent, fast and effective |
|
| Intent | function_call | Interface calls | Based on LLM pricing | Completes intent through large model function calling, fast speed, good effect |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -294,11 +350,13 @@ In fact, any LLM that supports openai interface calls can be integrated and used
|
|||||||
|
|
||||||
| Logo | Project/Company | Description |
|
| Logo | Project/Company | Description |
|
||||||
|:---:|:---:|:---|
|
|:---:|:---:|:---|
|
||||||
| <img src="./docs/images/logo_bailing.png" width="160"> | [Bailing Voice Dialogue Robot](https://github.com/wwbin2017/bailing) | This project was inspired by [Bailing Voice Dialogue Robot](https://github.com/wwbin2017/bailing) and implemented based on it |
|
| <img src="./docs/images/logo_bailing.png" width="160"> | [Bailing Voice Dialogue Robot](https://github.com/wwbin2017/bailing) | This project is inspired by [Bailing Voice Dialogue Robot](https://github.com/wwbin2017/bailing) and implemented on its basis |
|
||||||
| <img src="./docs/images/logo_tenclass.png" width="160"> | [Tenclass](https://www.tenclass.com/) | Thanks to [Tenclass](https://www.tenclass.com/) for establishing standard communication protocols, multi-device compatibility solutions, and high-concurrency scenario practices for the Xiaozhi ecosystem; providing full-chain technical documentation support for this project |
|
| <img src="./docs/images/logo_tenclass.png" width="160"> | [Tenclass](https://www.tenclass.com/) | Thanks to [Tenclass](https://www.tenclass.com/) for formulating standard communication protocols, multi-device compatibility solutions, and high-concurrency scenario practice demonstrations for the Xiaozhi ecosystem; providing full-link technical documentation support for this project |
|
||||||
| <img src="./docs/images/logo_xuanfeng.png" width="160"> | [Xuanfeng Technology](https://github.com/Eric0308) | Thanks to [Xuanfeng Technology](https://github.com/Eric0308) for contributing the function call framework, MCP communication protocol, and plugin call mechanism implementation code, significantly improving front-end device (IoT) interaction efficiency and functional extensibility through standardized instruction scheduling system and dynamic expansion capabilities |
|
| <img src="./docs/images/logo_xuanfeng.png" width="160"> | [Xuanfeng Technology](https://github.com/Eric0308) | Thanks to [Xuanfeng Technology](https://github.com/Eric0308) for contributing function calling framework, MCP communication protocol, and plugin-based calling mechanism implementation code. Through standardized instruction scheduling system and dynamic expansion capabilities, it significantly improves the interaction efficiency and functional extensibility of frontend devices (IoT) |
|
||||||
| <img src="./docs/images/logo_huiyuan.png" width="160"> | [Huiyuan Design](http://ui.kwd988.net/) | Thanks to [Huiyuan Design](http://ui.kwd988.net/) for providing professional visual solutions for this project, empowering the product user experience with their design experience serving over a thousand enterprises |
|
| <img src="./docs/images/logo_junsen.png" width="160"> | [huangjunsen](https://github.com/huangjunsen0406) | Thanks to [huangjunsen](https://github.com/huangjunsen0406) for contributing the `Smart Control Console Mobile` module, which enables efficient control and real-time interaction across mobile devices, significantly enhancing the system's operational convenience and management efficiency in mobile scenarios. |
|
||||||
| <img src="./docs/images/logo_qinren.png" width="160"> | [Xi'an Qinren Information Technology](https://www.029app.com/) | Thanks to [Xi'an Qinren Information Technology](https://www.029app.com/) for deepening the visual system of this project, ensuring consistency and extensibility of the overall design style in multi-scenario applications |
|
| <img src="./docs/images/logo_huiyuan.png" width="160"> | [Huiyuan Design](http://ui.kwd988.net/) | Thanks to [Huiyuan Design](http://ui.kwd988.net/) for providing professional visual solutions for this project, using their design practical experience serving over a thousand enterprises to empower this project's product user experience |
|
||||||
|
| <img src="./docs/images/logo_qinren.png" width="160"> | [Xi'an Qinren Information Technology](https://www.029app.com/) | Thanks to [Xi'an Qinren Information Technology](https://www.029app.com/) for deepening this project's visual system, ensuring consistency and extensibility of overall design style in multi-scenario applications |
|
||||||
|
| <img src="./docs/images/logo_contributors.png" width="160"> | [Code Contributors](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors) | Thanks to [all code contributors](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors), your efforts have made the project more robust and powerful. |
|
||||||
|
|
||||||
|
|
||||||
<a href="https://star-history.com/#xinnan-tech/xiaozhi-esp32-server&Date">
|
<a href="https://star-history.com/#xinnan-tech/xiaozhi-esp32-server&Date">
|
||||||
|
|||||||
@@ -1,105 +1,413 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# 脚本作者@VanillaNahida
|
||||||
# 本文件是用于一键自动下载本项目所需文件,自动创建好目录
|
# 本文件是用于一键自动下载本项目所需文件,自动创建好目录
|
||||||
# 所需条件(否则无法使用):
|
# 暂且只支持X86版本的Ubuntu系统,其他系统未测试
|
||||||
# 1、请确保你的环境可以正常访问 GitHub 否则无法下载脚本
|
|
||||||
#
|
# 定义中断处理函数
|
||||||
# 检测操作系统类型
|
handle_interrupt() {
|
||||||
case "$(uname -s)" in
|
echo ""
|
||||||
Linux*) OS=Linux;;
|
echo "安装已被用户中断(Ctrl+C或Esc)"
|
||||||
Darwin*) OS=Mac;;
|
echo "如需重新安装,请再次运行脚本"
|
||||||
CYGWIN*) OS=Windows;;
|
exit 1
|
||||||
MINGW*) OS=Windows;;
|
}
|
||||||
MSYS*) OS=Windows;;
|
|
||||||
*) OS=UNKNOWN;;
|
# 设置信号捕获,处理Ctrl+C
|
||||||
|
trap handle_interrupt SIGINT
|
||||||
|
|
||||||
|
# 处理Esc键
|
||||||
|
# 保存终端设置
|
||||||
|
old_stty_settings=$(stty -g)
|
||||||
|
# 设置终端立即响应,不回显
|
||||||
|
stty -icanon -echo min 1 time 0
|
||||||
|
|
||||||
|
# 后台进程检测Esc键
|
||||||
|
(while true; do
|
||||||
|
read -r key
|
||||||
|
if [[ $key == $'\e' ]]; then
|
||||||
|
# 检测到Esc键,触发中断处理
|
||||||
|
kill -SIGINT $$
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done) &
|
||||||
|
|
||||||
|
# 脚本结束时恢复终端设置
|
||||||
|
trap 'stty "$old_stty_settings"' EXIT
|
||||||
|
|
||||||
|
|
||||||
|
# 打印彩色字符画
|
||||||
|
echo -e "\e[1;32m" # 设置颜色为亮绿色
|
||||||
|
cat << "EOF"
|
||||||
|
脚本作者:@Bilibili 香草味的纳西妲喵
|
||||||
|
__ __ _ _ _ _ _ _ _ _
|
||||||
|
\ \ / / (_)| || | | \ | | | | (_) | |
|
||||||
|
\ \ / /__ _ _ __ _ | || | __ _ | \| | __ _ | |__ _ __| | __ _
|
||||||
|
\ \/ // _` || '_ \ | || || | / _` | | . ` | / _` || '_ \ | | / _` | / _` |
|
||||||
|
\ /| (_| || | | || || || || (_| | | |\ || (_| || | | || || (_| || (_| |
|
||||||
|
\/ \__,_||_| |_||_||_||_| \__,_| |_| \_| \__,_||_| |_||_| \__,_| \__,_|
|
||||||
|
EOF
|
||||||
|
echo -e "\e[0m" # 重置颜色
|
||||||
|
echo -e "\e[1;36m 小智服务端全量部署一键安装脚本 Ver 0.2 2025年8月20日更新 \e[0m\n"
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 检查并安装whiptail
|
||||||
|
check_whiptail() {
|
||||||
|
if ! command -v whiptail &> /dev/null; then
|
||||||
|
echo "正在安装whiptail..."
|
||||||
|
apt update
|
||||||
|
apt install -y whiptail
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_whiptail
|
||||||
|
|
||||||
|
# 创建确认对话框
|
||||||
|
whiptail --title "安装确认" --yesno "即将安装小智服务端,是否继续?" \
|
||||||
|
--yes-button "继续" --no-button "退出" 10 50
|
||||||
|
|
||||||
|
# 根据用户选择执行操作
|
||||||
|
case $? in
|
||||||
|
0)
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# 设置颜色(Windows CMD 不支持,但不影响使用)
|
# 检查root权限
|
||||||
if [ "$OS" = "Windows" ]; then
|
if [ $EUID -ne 0 ]; then
|
||||||
GREEN=""
|
whiptail --title "权限错误" --msgbox "请使用root权限运行本脚本" 10 50
|
||||||
RED=""
|
|
||||||
NC=""
|
|
||||||
else
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
RED='\033[0;31m'
|
|
||||||
NC='\033[0m'
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${GREEN}开始安装小智服务端...${NC}"
|
|
||||||
|
|
||||||
# 创建必要的目录
|
|
||||||
echo "创建目录结构..."
|
|
||||||
mkdir -p xiaozhi-server/data xiaozhi-server/models/SenseVoiceSmall
|
|
||||||
cd xiaozhi-server || exit
|
|
||||||
|
|
||||||
# 根据操作系统选择下载命令
|
|
||||||
if [ "$OS" = "Windows" ]; then
|
|
||||||
DOWNLOAD_CMD="curl -L -o"
|
|
||||||
if ! command -v curl >/dev/null 2>&1; then
|
|
||||||
DOWNLOAD_CMD="powershell -Command Invoke-WebRequest -Uri"
|
|
||||||
DOWNLOAD_CMD_SUFFIX="-OutFile"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if command -v curl >/dev/null 2>&1; then
|
|
||||||
DOWNLOAD_CMD="curl -L -o"
|
|
||||||
elif command -v wget >/dev/null 2>&1; then
|
|
||||||
DOWNLOAD_CMD="wget -O"
|
|
||||||
else
|
|
||||||
echo "${RED}错误: 需要安装 curl 或 wget${NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 下载语音识别模型
|
|
||||||
echo "下载语音识别模型..."
|
|
||||||
if [ "$DOWNLOAD_CMD" = "powershell -Command Invoke-WebRequest -Uri" ]; then
|
|
||||||
$DOWNLOAD_CMD "https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt" $DOWNLOAD_CMD_SUFFIX "models/SenseVoiceSmall/model.pt"
|
|
||||||
else
|
|
||||||
$DOWNLOAD_CMD "models/SenseVoiceSmall/model.pt" "https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "${RED}模型下载失败。请手动从以下地址下载:${NC}"
|
|
||||||
echo "1. https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt"
|
|
||||||
echo "2. 百度网盘: https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg (提取码: qvna)"
|
|
||||||
echo "下载后请将文件放置在 models/SenseVoiceSmall/model.pt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 下载配置文件
|
|
||||||
echo "下载配置文件..."
|
|
||||||
if [ "$DOWNLOAD_CMD" = "powershell -Command Invoke-WebRequest -Uri" ]; then
|
|
||||||
$DOWNLOAD_CMD "https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/main/main/xiaozhi-server/docker-compose.yml" $DOWNLOAD_CMD_SUFFIX "docker-compose.yml"
|
|
||||||
$DOWNLOAD_CMD "https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/main/main/xiaozhi-server/config.yaml" $DOWNLOAD_CMD_SUFFIX "data/.config.yaml"
|
|
||||||
else
|
|
||||||
$DOWNLOAD_CMD "docker-compose.yml" "https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/main/main/xiaozhi-server/docker-compose.yml"
|
|
||||||
$DOWNLOAD_CMD "data/.config.yaml" "https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/main/main/xiaozhi-server/config.yaml"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 检查文件是否存在
|
|
||||||
echo "检查文件完整性..."
|
|
||||||
FILES_TO_CHECK="docker-compose.yml data/.config.yaml models/SenseVoiceSmall/model.pt"
|
|
||||||
ALL_FILES_EXIST=true
|
|
||||||
|
|
||||||
for FILE in $FILES_TO_CHECK; do
|
|
||||||
if [ ! -f "$FILE" ]; then
|
|
||||||
echo "${RED}错误: $FILE 不存在${NC}"
|
|
||||||
ALL_FILES_EXIST=false
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$ALL_FILES_EXIST" = false ]; then
|
|
||||||
echo "${RED}某些文件下载失败,请检查上述错误信息并手动下载缺失的文件。${NC}"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${GREEN}文件下载完成!${NC}"
|
# 检查系统版本
|
||||||
echo "请编辑 data/.config.yaml 文件配置你的API密钥。"
|
if [ -f /etc/os-release ]; then
|
||||||
echo "配置完成后,运行以下命令启动服务:"
|
. /etc/os-release
|
||||||
echo "${GREEN}docker-compose up -d${NC}"
|
if [ "$ID" != "debian" ] && [ "$ID" != "ubuntu" ]; then
|
||||||
echo "查看日志请运行:"
|
whiptail --title "系统错误" --msgbox "该脚本只支持Debian/Ubuntu系统执行" 10 60
|
||||||
echo "${GREEN}docker logs -f xiaozhi-esp32-server${NC}"
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
whiptail --title "系统错误" --msgbox "无法确定系统版本,该脚本只支持Debian/Ubuntu系统执行" 10 60
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# 提示用户编辑配置文件
|
# 下载配置文件函数
|
||||||
echo "\n${RED}重要提示:${NC}"
|
check_and_download() {
|
||||||
echo "1. 请确保编辑 data/.config.yaml 文件,配置必要的API密钥"
|
local filepath=$1
|
||||||
echo "2. 特别是 ChatGLM 和 mem0ai 的密钥必须配置"
|
local url=$2
|
||||||
echo "3. 配置完成后再启动 docker 服务"
|
if [ ! -f "$filepath" ]; then
|
||||||
|
if ! curl -fL --progress-bar "$url" -o "$filepath"; then
|
||||||
|
whiptail --title "错误" --msgbox "${filepath}文件下载失败" 10 50
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "${filepath}文件已存在,跳过下载"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 检查是否已安装
|
||||||
|
check_installed() {
|
||||||
|
# 检查目录是否存在且非空
|
||||||
|
if [ -d "/opt/xiaozhi-server/" ] && [ "$(ls -A /opt/xiaozhi-server/)" ]; then
|
||||||
|
DIR_CHECK=1
|
||||||
|
else
|
||||||
|
DIR_CHECK=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查容器是否存在
|
||||||
|
if docker inspect xiaozhi-esp32-server > /dev/null 2>&1; then
|
||||||
|
CONTAINER_CHECK=1
|
||||||
|
else
|
||||||
|
CONTAINER_CHECK=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 两次检查都通过
|
||||||
|
if [ $DIR_CHECK -eq 1 ] && [ $CONTAINER_CHECK -eq 1 ]; then
|
||||||
|
return 0 # 已安装
|
||||||
|
else
|
||||||
|
return 1 # 未安装
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 更新相关
|
||||||
|
if check_installed; then
|
||||||
|
if whiptail --title "已安装检测" --yesno "检测到小智服务端已安装,是否进行升级?" 10 60; then
|
||||||
|
# 用户选择升级,执行清理操作
|
||||||
|
echo "开始升级操作..."
|
||||||
|
|
||||||
|
# 停止并移除所有docker-compose服务
|
||||||
|
docker compose -f /opt/xiaozhi-server/docker-compose_all.yml down
|
||||||
|
|
||||||
|
# 停止并删除特定容器(考虑容器可能不存在的情况)
|
||||||
|
containers=(
|
||||||
|
"xiaozhi-esp32-server"
|
||||||
|
"xiaozhi-esp32-server-web"
|
||||||
|
"xiaozhi-esp32-server-db"
|
||||||
|
"xiaozhi-esp32-server-redis"
|
||||||
|
)
|
||||||
|
|
||||||
|
for container in "${containers[@]}"; do
|
||||||
|
if docker ps -a --format '{{.Names}}' | grep -q "^${container}$"; then
|
||||||
|
docker stop "$container" >/dev/null 2>&1 && \
|
||||||
|
docker rm "$container" >/dev/null 2>&1 && \
|
||||||
|
echo "成功移除容器: $container"
|
||||||
|
else
|
||||||
|
echo "容器不存在,跳过: $container"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# 删除特定镜像(考虑镜像可能不存在的情况)
|
||||||
|
images=(
|
||||||
|
"ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:server_latest"
|
||||||
|
"ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:web_latest"
|
||||||
|
)
|
||||||
|
|
||||||
|
for image in "${images[@]}"; do
|
||||||
|
if docker images --format '{{.Repository}}:{{.Tag}}' | grep -q "^${image}$"; then
|
||||||
|
docker rmi "$image" >/dev/null 2>&1 && \
|
||||||
|
echo "成功删除镜像: $image"
|
||||||
|
else
|
||||||
|
echo "镜像不存在,跳过: $image"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "所有清理操作完成"
|
||||||
|
|
||||||
|
# 备份原有配置文件
|
||||||
|
mkdir -p /opt/xiaozhi-server/backup/
|
||||||
|
if [ -f /opt/xiaozhi-server/data/.config.yaml ]; then
|
||||||
|
cp /opt/xiaozhi-server/data/.config.yaml /opt/xiaozhi-server/backup/.config.yaml
|
||||||
|
echo "已备份原有配置文件到 /opt/xiaozhi-server/backup/.config.yaml"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 下载最新版配置文件
|
||||||
|
check_and_download "/opt/xiaozhi-server/docker-compose_all.yml" "https://ghfast.top/https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/refs/heads/main/main/xiaozhi-server/docker-compose_all.yml"
|
||||||
|
check_and_download "/opt/xiaozhi-server/data/.config.yaml" "https://ghfast.top/https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/refs/heads/main/main/xiaozhi-server/config_from_api.yaml"
|
||||||
|
|
||||||
|
# 启动Docker服务
|
||||||
|
echo "开始启动最新版本服务..."
|
||||||
|
# 升级完成后标记,跳过后续下载步骤
|
||||||
|
UPGRADE_COMPLETED=1
|
||||||
|
docker compose -f /opt/xiaozhi-server/docker-compose_all.yml up -d
|
||||||
|
else
|
||||||
|
whiptail --title "跳过升级" --msgbox "已取消升级,将继续使用当前版本。" 10 50
|
||||||
|
# 跳过升级,继续执行后续安装流程
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# 检查curl安装
|
||||||
|
if ! command -v curl &> /dev/null; then
|
||||||
|
echo "------------------------------------------------------------"
|
||||||
|
echo "未检测到curl,正在安装..."
|
||||||
|
apt update
|
||||||
|
apt install -y curl
|
||||||
|
else
|
||||||
|
echo "------------------------------------------------------------"
|
||||||
|
echo "curl已安装,跳过安装步骤"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查Docker安装
|
||||||
|
if ! command -v docker &> /dev/null; then
|
||||||
|
echo "------------------------------------------------------------"
|
||||||
|
echo "未检测到Docker,正在安装..."
|
||||||
|
|
||||||
|
# 使用国内镜像源替代官方源
|
||||||
|
DISTRO=$(lsb_release -cs)
|
||||||
|
MIRROR_URL="https://mirrors.aliyun.com/docker-ce/linux/ubuntu"
|
||||||
|
GPG_URL="https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg"
|
||||||
|
|
||||||
|
# 安装基础依赖
|
||||||
|
apt update
|
||||||
|
apt install -y apt-transport-https ca-certificates curl software-properties-common gnupg
|
||||||
|
|
||||||
|
# 创建密钥目录并添加国内镜像源密钥
|
||||||
|
mkdir -p /etc/apt/keyrings
|
||||||
|
curl -fsSL "$GPG_URL" | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||||
|
|
||||||
|
# 添加国内镜像源
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] $MIRROR_URL $DISTRO stable" \
|
||||||
|
> /etc/apt/sources.list.d/docker.list
|
||||||
|
|
||||||
|
# 添加备用官方源密钥(避免国内源密钥验证失败)
|
||||||
|
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8 2>/dev/null || \
|
||||||
|
echo "警告:部分密钥添加失败,继续尝试安装..."
|
||||||
|
|
||||||
|
# 安装Docker
|
||||||
|
apt update
|
||||||
|
apt install -y docker-ce docker-ce-cli containerd.io
|
||||||
|
|
||||||
|
# 启动服务
|
||||||
|
systemctl start docker
|
||||||
|
systemctl enable docker
|
||||||
|
|
||||||
|
# 检查是否安装成功
|
||||||
|
if docker --version; then
|
||||||
|
echo "------------------------------------------------------------"
|
||||||
|
echo "Docker安装完成!"
|
||||||
|
else
|
||||||
|
whiptail --title "错误" --msgbox "Docker安装失败,请检查日志。" 10 50
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Docker已安装,跳过安装步骤"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Docker镜像源配置
|
||||||
|
MIRROR_OPTIONS=(
|
||||||
|
"1" "轩辕镜像 (推荐)"
|
||||||
|
"2" "腾讯云镜像源"
|
||||||
|
"3" "中科大镜像源"
|
||||||
|
"4" "网易163镜像源"
|
||||||
|
"5" "华为云镜像源"
|
||||||
|
"6" "阿里云镜像源"
|
||||||
|
"7" "自定义镜像源"
|
||||||
|
"8" "跳过配置"
|
||||||
|
)
|
||||||
|
|
||||||
|
MIRROR_CHOICE=$(whiptail --title "选择Docker镜像源" --menu "请选择要使用的Docker镜像源" 20 60 10 \
|
||||||
|
"${MIRROR_OPTIONS[@]}" 3>&1 1>&2 2>&3) || {
|
||||||
|
echo "用户取消选择,退出脚本"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
case $MIRROR_CHOICE in
|
||||||
|
1) MIRROR_URL="https://docker.xuanyuan.me" ;;
|
||||||
|
2) MIRROR_URL="https://mirror.ccs.tencentyun.com" ;;
|
||||||
|
3) MIRROR_URL="https://docker.mirrors.ustc.edu.cn" ;;
|
||||||
|
4) MIRROR_URL="https://hub-mirror.c.163.com" ;;
|
||||||
|
5) MIRROR_URL="https://05f073ad3c0010ea0f4bc00b7105ec20.mirror.swr.myhuaweicloud.com" ;;
|
||||||
|
6) MIRROR_URL="https://registry.aliyuncs.com" ;;
|
||||||
|
7) MIRROR_URL=$(whiptail --title "自定义镜像源" --inputbox "请输入完整的镜像源URL:" 10 60 3>&1 1>&2 2>&3) ;;
|
||||||
|
8) MIRROR_URL="" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -n "$MIRROR_URL" ]; then
|
||||||
|
mkdir -p /etc/docker
|
||||||
|
if [ -f /etc/docker/daemon.json ]; then
|
||||||
|
cp /etc/docker/daemon.json /etc/docker/daemon.json.bak
|
||||||
|
fi
|
||||||
|
cat > /etc/docker/daemon.json <<EOF
|
||||||
|
{
|
||||||
|
"dns": ["8.8.8.8", "114.114.114.114"],
|
||||||
|
"registry-mirrors": ["$MIRROR_URL"]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
whiptail --title "配置成功" --msgbox "已成功添加镜像源: $MIRROR_URL\n请按Enter键重启Docker服务并继续..." 12 60
|
||||||
|
echo "------------------------------------------------------------"
|
||||||
|
echo "开始重启Docker服务..."
|
||||||
|
systemctl restart docker.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 创建安装目录
|
||||||
|
echo "------------------------------------------------------------"
|
||||||
|
echo "开始创建安装目录..."
|
||||||
|
# 检查并创建数据目录
|
||||||
|
if [ ! -d /opt/xiaozhi-server/data ]; then
|
||||||
|
mkdir -p /opt/xiaozhi-server/data
|
||||||
|
echo "已创建数据目录: /opt/xiaozhi-server/data"
|
||||||
|
else
|
||||||
|
echo "目录xiaozhi-server/data已存在,跳过创建"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查并创建模型目录
|
||||||
|
if [ ! -d /opt/xiaozhi-server/models/SenseVoiceSmall ]; then
|
||||||
|
mkdir -p /opt/xiaozhi-server/models/SenseVoiceSmall
|
||||||
|
echo "已创建模型目录: /opt/xiaozhi-server/models/SenseVoiceSmall"
|
||||||
|
else
|
||||||
|
echo "目录xiaozhi-server/models/SenseVoiceSmall已存在,跳过创建"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "------------------------------------------------------------"
|
||||||
|
echo "开始下载语音识别模型"
|
||||||
|
# 下载模型文件
|
||||||
|
MODEL_PATH="/opt/xiaozhi-server/models/SenseVoiceSmall/model.pt"
|
||||||
|
if [ ! -f "$MODEL_PATH" ]; then
|
||||||
|
(
|
||||||
|
for i in {1..20}; do
|
||||||
|
echo $((i*5))
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
) | whiptail --title "下载中" --gauge "开始下载语音识别模型..." 10 60 0
|
||||||
|
curl -fL --progress-bar https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt -o "$MODEL_PATH" || {
|
||||||
|
whiptail --title "错误" --msgbox "model.pt文件下载失败" 10 50
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
echo "model.pt文件已存在,跳过下载"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 如果不是升级完成,才执行下载
|
||||||
|
if [ -z "$UPGRADE_COMPLETED" ]; then
|
||||||
|
check_and_download "/opt/xiaozhi-server/docker-compose_all.yml" "https://ghfast.top/https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/refs/heads/main/main/xiaozhi-server/docker-compose_all.yml"
|
||||||
|
check_and_download "/opt/xiaozhi-server/data/.config.yaml" "https://ghfast.top/https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/refs/heads/main/main/xiaozhi-server/config_from_api.yaml"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 启动Docker服务
|
||||||
|
(
|
||||||
|
echo "------------------------------------------------------------"
|
||||||
|
echo "正在拉取Docker镜像..."
|
||||||
|
echo "这可能需要几分钟时间,请耐心等待"
|
||||||
|
docker compose -f /opt/xiaozhi-server/docker-compose_all.yml up -d
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
whiptail --title "错误" --msgbox "Docker服务启动失败,请尝试更换镜像源后重新执行本脚本" 10 60
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "------------------------------------------------------------"
|
||||||
|
echo "正在检查服务启动状态..."
|
||||||
|
TIMEOUT=300
|
||||||
|
START_TIME=$(date +%s)
|
||||||
|
while true; do
|
||||||
|
CURRENT_TIME=$(date +%s)
|
||||||
|
if [ $((CURRENT_TIME - START_TIME)) -gt $TIMEOUT ]; then
|
||||||
|
whiptail --title "错误" --msgbox "服务启动超时,未在指定时间内找到预期日志内容" 10 60
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if docker logs xiaozhi-esp32-server-web 2>&1 | grep -q "Started AdminApplication in"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "服务端启动成功!正在完成配置..."
|
||||||
|
echo "正在启动服务..."
|
||||||
|
docker compose -f /opt/xiaozhi-server/docker-compose_all.yml up -d
|
||||||
|
echo "服务启动完成!"
|
||||||
|
)
|
||||||
|
|
||||||
|
# 密钥配置
|
||||||
|
|
||||||
|
# 获取服务器公网地址
|
||||||
|
PUBLIC_IP=$(hostname -I | awk '{print $1}')
|
||||||
|
whiptail --title "配置服务器密钥" --msgbox "请使用浏览器,访问下方链接,打开智控台并注册账号: \n\n内网地址:http://127.0.0.1:8002/\n公网地址:http://$PUBLIC_IP:8002/ (若是云服务器请在服务器安全组放行端口 8000 8001 8002)。\n\n注册的第一个用户即是超级管理员,以后注册的用户都是普通用户。普通用户只能绑定设备和配置智能体; 超级管理员可以进行模型管理、用户管理、参数配置等功能。\n\n注册好后请按Enter键继续" 18 70
|
||||||
|
SECRET_KEY=$(whiptail --title "配置服务器密钥" --inputbox "请使用超级管理员账号登录智控台\n内网地址:http://127.0.0.1:8002/\n公网地址:http://$PUBLIC_IP:8002/\n在顶部菜单 参数字典 → 参数管理 找到参数编码: server.secret (服务器密钥) \n复制该参数值并输入到下面输入框\n\n请输入密钥(留空则跳过配置):" 15 60 3>&1 1>&2 2>&3)
|
||||||
|
|
||||||
|
if [ -n "$SECRET_KEY" ]; then
|
||||||
|
python3 -c "
|
||||||
|
import sys, yaml;
|
||||||
|
config_path = '/opt/xiaozhi-server/data/.config.yaml';
|
||||||
|
with open(config_path, 'r') as f:
|
||||||
|
config = yaml.safe_load(f) or {};
|
||||||
|
config['manager-api'] = {'url': 'http://xiaozhi-esp32-server-web:8002/xiaozhi', 'secret': '$SECRET_KEY'};
|
||||||
|
with open(config_path, 'w') as f:
|
||||||
|
yaml.dump(config, f);
|
||||||
|
"
|
||||||
|
docker restart xiaozhi-esp32-server
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 获取并显示地址信息
|
||||||
|
LOCAL_IP=$(hostname -I | awk '{print $1}')
|
||||||
|
|
||||||
|
# 修复日志文件获取不到ws的问题,改为硬编码
|
||||||
|
whiptail --title "安装完成!" --msgbox "\
|
||||||
|
服务端相关地址如下:\n\
|
||||||
|
管理后台访问地址: http://$LOCAL_IP:8002\n\
|
||||||
|
OTA 地址: http://$LOCAL_IP:8002/xiaozhi/ota/\n\
|
||||||
|
视觉分析接口地址: http://$LOCAL_IP:8003/mcp/vision/explain\n\
|
||||||
|
WebSocket 地址: ws://$LOCAL_IP:8000/xiaozhi/v1/\n\
|
||||||
|
\n安装完毕!感谢您的使用!\n按Enter键退出..." 16 70
|
||||||
|
|||||||
@@ -8,47 +8,13 @@ docker镜像已支持x86架构、arm64架构的CPU,支持在国产操作系统
|
|||||||
|
|
||||||
如果您的电脑还没安装docker,可以按照这里的教程安装:[docker安装](https://www.runoob.com/docker/ubuntu-docker-install.html)
|
如果您的电脑还没安装docker,可以按照这里的教程安装:[docker安装](https://www.runoob.com/docker/ubuntu-docker-install.html)
|
||||||
|
|
||||||
如果你已经安装好docker,你可以[1.1使用懒人脚本](#11-懒人脚本)自动帮你下载所需的文件和配置文件,你可以使用docker[1.2手动部署](#12-手动部署)。
|
安装好docker后,进继续。
|
||||||
|
|
||||||
### 1.1 懒人脚本
|
### 1.1 手动部署
|
||||||
|
|
||||||
你可以使用以下命令一键下载并执行部署脚本:
|
#### 1.1.1 创建目录
|
||||||
请确保你的环境可以正常访问 GitHub 否则无法下载脚本。
|
|
||||||
```bash
|
|
||||||
curl -L -o docker-setup.sh https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/main/docker-setup.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
如果您的电脑是windows系统,请使用使用 Git Bash、WSL、PowerShell 或 CMD 运行以下命令:
|
安装完docker后,你需要为这个项目找一个安放配置文件的目录,例如我们可以新建一个文件夹叫`xiaozhi-server`。
|
||||||
```bash
|
|
||||||
# Git Bash 或 WSL
|
|
||||||
sh docker-setup.sh
|
|
||||||
# PowerShell 或 CMD
|
|
||||||
.\docker-setup.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
如果您的电脑是linux 或者 macos 系统,请使用终端运行以下命令:
|
|
||||||
```bash
|
|
||||||
chmod +x docker-setup.sh
|
|
||||||
./docker-setup.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
脚本会自动完成以下操作:
|
|
||||||
> 1. 创建必要的目录结构
|
|
||||||
> 2. 下载语音识别模型
|
|
||||||
> 3. 下载配置文件
|
|
||||||
> 4. 检查文件完整性
|
|
||||||
>
|
|
||||||
> 执行完成后,请按照提示配置 API 密钥。
|
|
||||||
|
|
||||||
当你一切顺利完成以上操作后,继续操作[配置项目文件](#2-配置项目文件)
|
|
||||||
|
|
||||||
### 1.2 手动部署
|
|
||||||
|
|
||||||
如果懒人脚本无法正常运行,请按本章节1.2进行手动部署。
|
|
||||||
|
|
||||||
#### 1.2.1 创建目录
|
|
||||||
|
|
||||||
安装完后,你需要为这个项目找一个安放配置文件的目录,例如我们可以新建一个文件夹叫`xiaozhi-server`。
|
|
||||||
|
|
||||||
创建好目录后,你需要在`xiaozhi-server`下面创建`data`文件夹和`models`文件夹,`models`下面还要再创建`SenseVoiceSmall`文件夹。
|
创建好目录后,你需要在`xiaozhi-server`下面创建`data`文件夹和`models`文件夹,`models`下面还要再创建`SenseVoiceSmall`文件夹。
|
||||||
|
|
||||||
@@ -61,18 +27,18 @@ xiaozhi-server
|
|||||||
├─ SenseVoiceSmall
|
├─ SenseVoiceSmall
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 1.2.2 下载语音识别模型文件
|
#### 1.1.2 下载语音识别模型文件
|
||||||
|
|
||||||
你需要下载语音识别的模型文件,因为本项目的默认语音识别用的是本地离线语音识别方案。可通过这个方式下载
|
你需要下载语音识别的模型文件,因为本项目的默认语音识别用的是本地离线语音识别方案。可通过这个方式下载
|
||||||
[跳转到下载语音识别模型文件](#模型文件)
|
[跳转到下载语音识别模型文件](#模型文件)
|
||||||
|
|
||||||
下载完后,回到本教程。
|
下载完后,回到本教程。
|
||||||
|
|
||||||
#### 1.2.3 下载配置文件
|
#### 1.1.3 下载配置文件
|
||||||
|
|
||||||
你需要下载两个配置文件:`docker-compose.yaml` 和 `config.yaml`。需要从项目仓库下载这两个文件。
|
你需要下载两个配置文件:`docker-compose.yaml` 和 `config.yaml`。需要从项目仓库下载这两个文件。
|
||||||
|
|
||||||
##### 1.2.3.1 下载 docker-compose.yaml
|
##### 1.1.3.1 下载 docker-compose.yaml
|
||||||
|
|
||||||
用浏览器打开[这个链接](../main/xiaozhi-server/docker-compose.yml)。
|
用浏览器打开[这个链接](../main/xiaozhi-server/docker-compose.yml)。
|
||||||
|
|
||||||
@@ -81,7 +47,7 @@ xiaozhi-server
|
|||||||
|
|
||||||
下载完后,回到本教程继续往下。
|
下载完后,回到本教程继续往下。
|
||||||
|
|
||||||
##### 1.2.3.2 创建 config.yaml
|
##### 1.1.3.2 创建 config.yaml
|
||||||
|
|
||||||
用浏览器打开[这个链接](../main/xiaozhi-server/config.yaml)。
|
用浏览器打开[这个链接](../main/xiaozhi-server/config.yaml)。
|
||||||
|
|
||||||
@@ -260,7 +226,7 @@ LLM:
|
|||||||
文件放在`models/SenseVoiceSmall`
|
文件放在`models/SenseVoiceSmall`
|
||||||
目录下。下面两个下载路线任选一个。
|
目录下。下面两个下载路线任选一个。
|
||||||
|
|
||||||
- 线路一:阿里魔塔下载[SenseVoiceSmall](https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt)
|
- 线路一:阿里魔搭下载[SenseVoiceSmall](https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt)
|
||||||
- 线路二:百度网盘下载[SenseVoiceSmall](https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg&pwd=qvna) 提取码:
|
- 线路二:百度网盘下载[SenseVoiceSmall](https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg&pwd=qvna) 提取码:
|
||||||
`qvna`
|
`qvna`
|
||||||
|
|
||||||
@@ -290,19 +256,30 @@ LLM:
|
|||||||
|
|
||||||
2、 [基于虾哥编译好的固件配置自定义服务器](firmware-setting.md)了。
|
2、 [基于虾哥编译好的固件配置自定义服务器](firmware-setting.md)了。
|
||||||
|
|
||||||
|
# 常见问题
|
||||||
以下是一些常见问题,供参考:
|
以下是一些常见问题,供参考:
|
||||||
|
|
||||||
[1、为什么我说的话,小智识别出来很多韩文、日文、英文](./FAQ.md)
|
1、[为什么我说的话,小智识别出来很多韩文、日文、英文](./FAQ.md)<br/>
|
||||||
|
2、[为什么会出现“TTS 任务出错 文件不存在”?](./FAQ.md)<br/>
|
||||||
[2、为什么会出现“TTS 任务出错 文件不存在”?](./FAQ.md)
|
3、[TTS 经常失败,经常超时](./FAQ.md)<br/>
|
||||||
|
4、[使用Wifi能连接自建服务器,但是4G模式却接不上](./FAQ.md)<br/>
|
||||||
[3、TTS 经常失败,经常超时](./FAQ.md)
|
5、[如何提高小智对话响应速度?](./FAQ.md)<br/>
|
||||||
|
6、[我说话很慢,停顿时小智老是抢话](./FAQ.md)<br/>
|
||||||
[4、使用Wifi能连接自建服务器,但是4G模式却接不上](./FAQ.md)
|
## 部署相关教程
|
||||||
|
1、[如何自动拉取本项目最新代码自动编译和启动](./dev-ops-integration.md)<br/>
|
||||||
[5、如何提高小智对话响应速度?](./FAQ.md)
|
2、[如何与Nginx集成](https://github.com/xinnan-tech/xiaozhi-esp32-server/issues/791)<br/>
|
||||||
|
## 拓展相关教程
|
||||||
[6、我说话很慢,停顿时小智老是抢话](./FAQ.md)
|
1、[如何开启手机号码注册智控台](./ali-sms-integration.md)<br/>
|
||||||
|
2、[如何集成HomeAssistant实现智能家居控制](./homeassistant-integration.md)<br/>
|
||||||
[7、我想通过小智控制电灯、空调、远程开关机等操作](./FAQ.md)
|
3、[如何开启视觉模型实现拍照识物](./mcp-vision-integration.md)<br/>
|
||||||
|
4、[如何部署MCP接入点](./mcp-endpoint-enable.md)<br/>
|
||||||
|
5、[如何接入MCP接入点](./mcp-endpoint-integration.md)<br/>
|
||||||
|
6、[如何开启声纹识别](./voiceprint-integration.md)<br/>
|
||||||
|
10、[新闻插件源配置指南](./newsnow_plugin_config.md)<br/>
|
||||||
|
## 语音克隆、本地语音部署相关教程
|
||||||
|
1、[如何部署集成index-tts本地语音](./index-stream-integration.md)<br/>
|
||||||
|
2、[如何部署集成fish-speech本地语音](./fish-speech-integration.md)<br/>
|
||||||
|
3、[如何部署集成PaddleSpeech本地语音](./paddlespeech-deploy.md)<br/>
|
||||||
|
## 性能测试教程
|
||||||
|
1、[各组件速度测试指南](./performance_tester.md)<br/>
|
||||||
|
2、[定期公开测试结果](https://github.com/xinnan-tech/xiaozhi-performance-research)<br/>
|
||||||
|
|||||||
@@ -7,7 +7,34 @@ docker镜像已支持x86架构、arm64架构的CPU,支持在国产操作系统
|
|||||||
|
|
||||||
如果您的电脑还没安装docker,可以按照这里的教程安装:[docker安装](https://www.runoob.com/docker/ubuntu-docker-install.html)
|
如果您的电脑还没安装docker,可以按照这里的教程安装:[docker安装](https://www.runoob.com/docker/ubuntu-docker-install.html)
|
||||||
|
|
||||||
#### 1.1 创建目录
|
docker 安装全模块有两种方式,你可以[使用懒人脚本](./Deployment_all.md#11-懒人脚本)(作者[@VanillaNahida](https://github.com/VanillaNahida))
|
||||||
|
脚本会自动帮你下载所需的文件和配置文件,你也可以使用[手动部署](./Deployment_all.md#12-手动部署)从零搭建。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### 1.1 懒人脚本
|
||||||
|
部署简便,可以参考[视频教程](https://www.bilibili.com/video/BV17bbvzHExd/) ,文字版教程如下:
|
||||||
|
> [!NOTE]
|
||||||
|
> 暂且只支持Ubuntu服务器一键部署,其他系统未尝试,可能会有一些奇怪的bug
|
||||||
|
|
||||||
|
使用SSH工具连接到服务器,以root权限执行如下脚本
|
||||||
|
```bash
|
||||||
|
sudo bash -c "$(wget -qO- https://ghfast.top/https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/main/docker-setup.sh)"
|
||||||
|
```
|
||||||
|
|
||||||
|
脚本会自动完成以下操作:
|
||||||
|
> 1. 安装Docker
|
||||||
|
> 2. 配置镜像源
|
||||||
|
> 3. 下载/拉取镜像
|
||||||
|
> 4. 下载语音识别模型文件
|
||||||
|
> 5. 引导配置服务端
|
||||||
|
>
|
||||||
|
|
||||||
|
执行完成后简单配置后,再参照[4. 运行程序](#4. 运行程序)和[5.重启xiaozhi-esp32-server](#5.重启xiaozhi-esp32-server)里提到的最重要的3件事情,完成3这三项配置后即可使用。
|
||||||
|
|
||||||
|
### 1.2 手动部署
|
||||||
|
|
||||||
|
#### 1.2.1 创建目录
|
||||||
|
|
||||||
安装完后,你需要为这个项目找一个安放配置文件的目录,例如我们可以新建一个文件夹叫`xiaozhi-server`。
|
安装完后,你需要为这个项目找一个安放配置文件的目录,例如我们可以新建一个文件夹叫`xiaozhi-server`。
|
||||||
|
|
||||||
@@ -22,22 +49,22 @@ xiaozhi-server
|
|||||||
├─ SenseVoiceSmall
|
├─ SenseVoiceSmall
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 1.2 下载语音识别模型文件
|
#### 1.2.2 下载语音识别模型文件
|
||||||
|
|
||||||
本项目语音识别模型,默认使用`SenseVoiceSmall`模型,进行语音转文字。因为模型较大,需要独立下载,下载后把`model.pt`
|
本项目语音识别模型,默认使用`SenseVoiceSmall`模型,进行语音转文字。因为模型较大,需要独立下载,下载后把`model.pt`
|
||||||
文件放在`models/SenseVoiceSmall`
|
文件放在`models/SenseVoiceSmall`
|
||||||
目录下。下面两个下载路线任选一个。
|
目录下。下面两个下载路线任选一个。
|
||||||
|
|
||||||
- 线路一:阿里魔塔下载[SenseVoiceSmall](https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt)
|
- 线路一:阿里魔搭下载[SenseVoiceSmall](https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt)
|
||||||
- 线路二:百度网盘下载[SenseVoiceSmall](https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg&pwd=qvna) 提取码:
|
- 线路二:百度网盘下载[SenseVoiceSmall](https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg&pwd=qvna) 提取码:
|
||||||
`qvna`
|
`qvna`
|
||||||
|
|
||||||
|
|
||||||
#### 1.3 下载配置文件
|
#### 1.2.3 下载配置文件
|
||||||
|
|
||||||
你需要下载两个配置文件:`docker-compose_all.yaml` 和 `config_from_api.yaml`。需要从项目仓库下载这两个文件。
|
你需要下载两个配置文件:`docker-compose_all.yaml` 和 `config_from_api.yaml`。需要从项目仓库下载这两个文件。
|
||||||
|
|
||||||
##### 1.3.1 下载 docker-compose_all.yaml
|
##### 1.2.3.1 下载 docker-compose_all.yaml
|
||||||
|
|
||||||
用浏览器打开[这个链接](../main/xiaozhi-server/docker-compose_all.yml)。
|
用浏览器打开[这个链接](../main/xiaozhi-server/docker-compose_all.yml)。
|
||||||
|
|
||||||
@@ -48,7 +75,7 @@ xiaozhi-server
|
|||||||
|
|
||||||
下载完后,回到本教程继续往下。
|
下载完后,回到本教程继续往下。
|
||||||
|
|
||||||
##### 1.3.2 下载 config_from_api.yaml
|
##### 1.2.3.2 下载 config_from_api.yaml
|
||||||
|
|
||||||
用浏览器打开[这个链接](../main/xiaozhi-server/config_from_api.yaml)。
|
用浏览器打开[这个链接](../main/xiaozhi-server/config_from_api.yaml)。
|
||||||
|
|
||||||
@@ -179,12 +206,12 @@ docker logs -f xiaozhi-esp32-server
|
|||||||
|
|
||||||
OTA接口:
|
OTA接口:
|
||||||
```
|
```
|
||||||
http://你电脑局域网的ip:8002/xiaozhi/ota/
|
http://你宿主机局域网的ip:8002/xiaozhi/ota/
|
||||||
```
|
```
|
||||||
|
|
||||||
Websocket接口:
|
Websocket接口:
|
||||||
```
|
```
|
||||||
ws://你电脑局域网的ip:8000/xiaozhi/v1/
|
ws://你宿主机的ip:8000/xiaozhi/v1/
|
||||||
```
|
```
|
||||||
|
|
||||||
### 第三件重要的事情
|
### 第三件重要的事情
|
||||||
@@ -358,7 +385,7 @@ pip install -r requirements.txt
|
|||||||
文件放在`models/SenseVoiceSmall`
|
文件放在`models/SenseVoiceSmall`
|
||||||
目录下。下面两个下载路线任选一个。
|
目录下。下面两个下载路线任选一个。
|
||||||
|
|
||||||
- 线路一:阿里魔塔下载[SenseVoiceSmall](https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt)
|
- 线路一:阿里魔搭下载[SenseVoiceSmall](https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt)
|
||||||
- 线路二:百度网盘下载[SenseVoiceSmall](https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg&pwd=qvna) 提取码:
|
- 线路二:百度网盘下载[SenseVoiceSmall](https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg&pwd=qvna) 提取码:
|
||||||
`qvna`
|
`qvna`
|
||||||
|
|
||||||
@@ -431,19 +458,29 @@ ws://你电脑局域网的ip:8000/xiaozhi/v1/
|
|||||||
2、 [基于虾哥编译好的固件配置自定义服务器](firmware-setting.md)了。
|
2、 [基于虾哥编译好的固件配置自定义服务器](firmware-setting.md)了。
|
||||||
|
|
||||||
# 常见问题
|
# 常见问题
|
||||||
|
|
||||||
以下是一些常见问题,供参考:
|
以下是一些常见问题,供参考:
|
||||||
|
|
||||||
[1、为什么我说的话,小智识别出来很多韩文、日文、英文](./FAQ.md)
|
1、[为什么我说的话,小智识别出来很多韩文、日文、英文](./FAQ.md)<br/>
|
||||||
|
2、[为什么会出现“TTS 任务出错 文件不存在”?](./FAQ.md)<br/>
|
||||||
[2、为什么会出现“TTS 任务出错 文件不存在”?](./FAQ.md)
|
3、[TTS 经常失败,经常超时](./FAQ.md)<br/>
|
||||||
|
4、[使用Wifi能连接自建服务器,但是4G模式却接不上](./FAQ.md)<br/>
|
||||||
[3、TTS 经常失败,经常超时](./FAQ.md)
|
5、[如何提高小智对话响应速度?](./FAQ.md)<br/>
|
||||||
|
6、[我说话很慢,停顿时小智老是抢话](./FAQ.md)<br/>
|
||||||
[4、使用Wifi能连接自建服务器,但是4G模式却接不上](./FAQ.md)
|
## 部署相关教程
|
||||||
|
1、[如何自动拉取本项目最新代码自动编译和启动](./dev-ops-integration.md)<br/>
|
||||||
[5、如何提高小智对话响应速度?](./FAQ.md)
|
2、[如何与Nginx集成](https://github.com/xinnan-tech/xiaozhi-esp32-server/issues/791)<br/>
|
||||||
|
## 拓展相关教程
|
||||||
[6、我说话很慢,停顿时小智老是抢话](./FAQ.md)
|
1、[如何开启手机号码注册智控台](./ali-sms-integration.md)<br/>
|
||||||
|
2、[如何集成HomeAssistant实现智能家居控制](./homeassistant-integration.md)<br/>
|
||||||
[7、我想通过小智控制电灯、空调、远程开关机等操作](./FAQ.md)
|
3、[如何开启视觉模型实现拍照识物](./mcp-vision-integration.md)<br/>
|
||||||
|
4、[如何部署MCP接入点](./mcp-endpoint-enable.md)<br/>
|
||||||
|
5、[如何接入MCP接入点](./mcp-endpoint-integration.md)<br/>
|
||||||
|
6、[如何开启声纹识别](./voiceprint-integration.md)<br/>
|
||||||
|
10、[新闻插件源配置指南](./newsnow_plugin_config.md)<br/>
|
||||||
|
## 语音克隆、本地语音部署相关教程
|
||||||
|
1、[如何部署集成index-tts本地语音](./index-stream-integration.md)<br/>
|
||||||
|
2、[如何部署集成fish-speech本地语音](./fish-speech-integration.md)<br/>
|
||||||
|
3、[如何部署集成PaddleSpeech本地语音](./paddlespeech-deploy.md)<br/>
|
||||||
|
## 性能测试教程
|
||||||
|
1、[各组件速度测试指南](./performance_tester.md)<br/>
|
||||||
|
2、[定期公开测试结果](https://github.com/xinnan-tech/xiaozhi-performance-research)<br/>
|
||||||
|
|||||||
@@ -34,59 +34,18 @@ conda install conda-forge::ffmpeg
|
|||||||
### 5、如何提高小智对话响应速度? ⚡
|
### 5、如何提高小智对话响应速度? ⚡
|
||||||
|
|
||||||
本项目默认配置为低成本方案,建议初学者先使用默认免费模型,解决"跑得动"的问题,再优化"跑得快"。
|
本项目默认配置为低成本方案,建议初学者先使用默认免费模型,解决"跑得动"的问题,再优化"跑得快"。
|
||||||
如需提升响应速度,可尝试更换各组件。以下为各组件的响应速度测试数据(仅供参考,不构成承诺):
|
如需提升响应速度,可尝试更换各组件。自`0.5.2`版本起,项目支持流式配置,相比早期版本,响应速度提升约`2.5秒`,显著改善用户体验。
|
||||||
|
|
||||||
| 影响因素 | 因素值 |
|
| 模块名称 | 入门全免费设置 | 流式配置 |
|
||||||
|:-----:|:----------------:|
|
|:---:|:---:|:---:|
|
||||||
| 测试地点 | 广东省广州市海珠区 |
|
| ASR(语音识别) | FunASR(本地) | 👍FunASR(本地GPU模式) |
|
||||||
| 测试时间 | 2025年2月19日 12:52 |
|
| LLM(大模型) | ChatGLMLLM(智谱glm-4-flash) | 👍AliLLM(qwen3-235b-a22b-instruct-2507) 或 👍DoubaoLLM(doubao-1-5-pro-32k-250115) |
|
||||||
| 宽带运营商 | 中国联通 |
|
| VLLM(视觉大模型) | ChatGLMVLLM(智谱glm-4v-flash) | 👍QwenVLVLLM(千问qwen2.5-vl-3b-instructh) |
|
||||||
|
| TTS(语音合成) | ✅LinkeraiTTS(灵犀流式) | 👍HuoshanDoubleStreamTTS(火山双流式语音合成) 或 👍AliyunStreamTTS(阿里云流式语音合成) |
|
||||||
|
| Intent(意图识别) | function_call(函数调用) | function_call(函数调用) |
|
||||||
|
| Memory(记忆功能) | mem_local_short(本地短期记忆) | mem_local_short(本地短期记忆) |
|
||||||
|
|
||||||
测试方法:
|
如果您关心各组件的耗时,请查阅[小智各组件性能测试报告](https://github.com/xinnan-tech/xiaozhi-performance-research),可按报告中的测试方法在您的环境中实际测试。
|
||||||
|
|
||||||
1、把各组件的密钥配置上去,只有配置了密钥的组件才参与测试。
|
|
||||||
|
|
||||||
2、配置完密钥后,执行以下方法
|
|
||||||
|
|
||||||
```
|
|
||||||
# 进入项目根目录,执行以下命令:
|
|
||||||
conda activate xiaozhi-esp32-server
|
|
||||||
python performance_tester.py
|
|
||||||
```
|
|
||||||
|
|
||||||
生成报告如下
|
|
||||||
|
|
||||||
LLM 性能排行:
|
|
||||||
|
|
||||||
| 模块名称 | 平均首Token时间 | 平均总响应时间 |
|
|
||||||
|:-----------|:-----------|:--------|
|
|
||||||
| AliLLM | 0.547s | 1.485s |
|
|
||||||
| ChatGLMLLM | 0.677s | 3.057s |
|
|
||||||
|
|
||||||
TTS 性能排行:
|
|
||||||
|
|
||||||
| 模块名称 | 平均合成时间 |
|
|
||||||
|----------------------|--------|
|
|
||||||
| EdgeTTS | 1.019s |
|
|
||||||
| DoubaoTTS | 0.503s |
|
|
||||||
| CosyVoiceSiliconflow | 3.732s |
|
|
||||||
|
|
||||||
推荐配置组合 (综合响应速度):
|
|
||||||
|
|
||||||
| 组合方案 | 综合得分 | LLM首Token | TTS合成 |
|
|
||||||
|-------------------------------|-------|-----------|--------|
|
|
||||||
| AliLLM + DoubaoTTS | 0.539 | 0.547s | 0.503s |
|
|
||||||
| AliLLM + EdgeTTS | 0.642 | 0.547s | 1.019s |
|
|
||||||
| ChatGLMLLM + DoubaoTTS | 0.642 | 0.677s | 0.503s |
|
|
||||||
| ChatGLMLLM + EdgeTTS | 0.745 | 0.677s | 1.019s |
|
|
||||||
| AliLLM + CosyVoiceSiliconflow | 1.184 | 0.547s | 3.732s |
|
|
||||||
|
|
||||||
### 结论 🔍
|
|
||||||
|
|
||||||
`2025年2月19日`,如果我的电脑在`广东省广州市海珠区`,且使用的是`中国联通`网络,我会优先使用:
|
|
||||||
|
|
||||||
- LLM:`AliLLM`
|
|
||||||
- TTS:`DoubaoTTS`
|
|
||||||
|
|
||||||
### 6、我说话很慢,停顿时小智老是抢话 🗣️
|
### 6、我说话很慢,停顿时小智老是抢话 🗣️
|
||||||
|
|
||||||
@@ -100,30 +59,34 @@ VAD:
|
|||||||
min_silence_duration_ms: 700 # 如果说话停顿较长,可将此值调大
|
min_silence_duration_ms: 700 # 如果说话停顿较长,可将此值调大
|
||||||
```
|
```
|
||||||
|
|
||||||
### 7、我想通过小智控制电灯、空调、远程开关机等操作 💡
|
### 7、部署相关教程
|
||||||
|
1、[如何进行最简化部署](./Deployment.md)<br/>
|
||||||
|
2、[如何进行全模块部署](./Deployment_all.md)<br/>
|
||||||
|
3、[如何自动拉取本项目最新代码自动编译和启动](./dev-ops-integration.md)<br/>
|
||||||
|
4、[如何与Nginx集成](https://github.com/xinnan-tech/xiaozhi-esp32-server/issues/791)<br/>
|
||||||
|
|
||||||
参考教程[ESP32设备与HomeAssistant集成指南](./homeassistant-integration.md)
|
### 8、编译固件相关教程
|
||||||
|
1、[如何自己编译小智固件](./firmware-build.md)<br/>
|
||||||
|
2、[如何基于虾哥编译好的固件修改OTA地址](./firmware-setting.md)<br/>
|
||||||
|
|
||||||
### 8、如何开启手机注册智控台 📱
|
### 8、拓展相关教程
|
||||||
|
1、[如何开启手机号码注册智控台](./ali-sms-integration.md)<br/>
|
||||||
|
2、[如何集成HomeAssistant实现智能家居控制](./homeassistant-integration.md)<br/>
|
||||||
|
3、[如何开启视觉模型实现拍照识物](./mcp-vision-integration.md)<br/>
|
||||||
|
4、[如何部署MCP接入点](./mcp-endpoint-enable.md)<br/>
|
||||||
|
5、[如何接入MCP接入点](./mcp-endpoint-integration.md)<br/>
|
||||||
|
6、[如何开启声纹识别](./voiceprint-integration.md)<br/>
|
||||||
|
10、[新闻插件源配置指南](./newsnow_plugin_config.md)<br/>
|
||||||
|
|
||||||
参考教程[阿里云短信集成指南](./ali-sms-integration.md)
|
### 9、语音克隆、本地语音部署相关教程
|
||||||
|
1、[如何部署集成index-tts本地语音](./index-stream-integration.md)<br/>
|
||||||
|
2、[如何部署集成fish-speech本地语音](./fish-speech-integration.md)<br/>
|
||||||
|
3、[如何部署集成PaddleSpeech本地语音](./paddlespeech-deploy.md)<br/>
|
||||||
|
|
||||||
### 9、如何开启视觉模型实现拍照识物 📷
|
### 10、性能测试教程
|
||||||
|
1、[各组件速度测试指南](./performance_tester.md)<br/>
|
||||||
参考教程[视觉模型使用指南](./mcp-vision-integration.md)
|
2、[定期公开测试结果](https://github.com/xinnan-tech/xiaozhi-performance-research)<br/>
|
||||||
|
|
||||||
### 10、如何开启MCP接入点 🔧
|
|
||||||
|
|
||||||
1、先参考教程[MCP 接入点部署使用指南](./mcp-endpoint-enable.md)
|
|
||||||
|
|
||||||
2、再参考教程[MCP 接入点使用指南](./mcp-endpoint-integration.md)
|
|
||||||
|
|
||||||
### 12、如何开启声纹识别 🔊
|
|
||||||
|
|
||||||
参考教程[声纹识别启用指南](./voiceprint-integration.md)
|
|
||||||
|
|
||||||
### 13、更多问题,可联系我们反馈 💬
|
### 13、更多问题,可联系我们反馈 💬
|
||||||
|
|
||||||
可以在[issues](https://github.com/xinnan-tech/xiaozhi-esp32-server/issues)提交您的问题。
|
可以在[issues](https://github.com/xinnan-tech/xiaozhi-esp32-server/issues)提交您的问题。
|
||||||
|
|
||||||
也可以发邮件我们取得联系:huangrongzhuang@xin-nan.com
|
|
||||||
@@ -105,6 +105,8 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
nohup java -jar xiaozhi-esp32-api.jar --spring.profiles.active=dev &
|
nohup java -jar xiaozhi-esp32-api.jar --spring.profiles.active=dev &
|
||||||
|
|
||||||
|
tail tail -f nohup.out
|
||||||
```
|
```
|
||||||
|
|
||||||
保存好后执行赋权命令
|
保存好后执行赋权命令
|
||||||
@@ -134,8 +136,12 @@ else
|
|||||||
echo "已杀掉进程 $PID"
|
echo "已杀掉进程 $PID"
|
||||||
fi
|
fi
|
||||||
cd main/xiaozhi-server
|
cd main/xiaozhi-server
|
||||||
|
# 初始化conda环境
|
||||||
|
source ~/.bashrc
|
||||||
|
conda activate xiaozhi-esp32-server
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
nohup python app.py >/dev/null &
|
nohup python app.py >/dev/null &
|
||||||
|
tail -f /home/system/xiaozhi/xiaozhi-esp32-server/main/xiaozhi-server/tmp/server.log
|
||||||
```
|
```
|
||||||
|
|
||||||
保存好后执行赋权命令
|
保存好后执行赋权命令
|
||||||
@@ -149,8 +155,6 @@ chmod 777 update_8000.sh
|
|||||||
以上的脚本都建立好后,日常更新,我们只要依次执行以下命令就可以做到自动更新和启动
|
以上的脚本都建立好后,日常更新,我们只要依次执行以下命令就可以做到自动更新和启动
|
||||||
|
|
||||||
```
|
```
|
||||||
# 进入pyhton环境
|
|
||||||
conda activate xiaozhi-esp32-server
|
|
||||||
cd /home/system/xiaozhi
|
cd /home/system/xiaozhi
|
||||||
# 更新并启动Java程序
|
# 更新并启动Java程序
|
||||||
./update_8001.sh
|
./update_8001.sh
|
||||||
@@ -158,9 +162,11 @@ cd /home/system/xiaozhi
|
|||||||
./update_8002.sh
|
./update_8002.sh
|
||||||
# 更新并启动python程序
|
# 更新并启动python程序
|
||||||
./update_8000.sh
|
./update_8000.sh
|
||||||
# 查看Java日志
|
|
||||||
|
|
||||||
|
# 后期想查看java日志,执行以下命令
|
||||||
tail -f nohup.out
|
tail -f nohup.out
|
||||||
# 查看Python日志
|
# 后期想查看python日志,执行以下命令
|
||||||
tail -f /home/system/xiaozhi/xiaozhi-esp32-server/main/xiaozhi-server/tmp/server.log
|
tail -f /home/system/xiaozhi/xiaozhi-esp32-server/main/xiaozhi-server/tmp/server.log
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 258 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 306 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 644 KiB After Width: | Height: | Size: 210 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 655 KiB |
|
After Width: | Height: | Size: 283 KiB |
|
After Width: | Height: | Size: 402 KiB |
|
After Width: | Height: | Size: 579 KiB |
|
After Width: | Height: | Size: 418 KiB |
@@ -0,0 +1,165 @@
|
|||||||
|
# IndexStreamTTS 使用指南
|
||||||
|
|
||||||
|
## 环境准备
|
||||||
|
### 1. 克隆项目 (这里使用的为VLLM的版本)
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/Ksuriuri/index-tts-vllm.git
|
||||||
|
cd index-tts-vllm
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 创建并激活 conda 环境
|
||||||
|
```bash
|
||||||
|
conda create -n index-tts-vllm python=3.12
|
||||||
|
conda activate index-tts-vllm
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 安装PyTorch
|
||||||
|
#### 查看显卡最高支持的版本和实际安装的版本
|
||||||
|
```bash
|
||||||
|
nvidia-smi
|
||||||
|
nvcc --version
|
||||||
|
```
|
||||||
|
#### 驱动支持的最高 CUDA 版本
|
||||||
|
```bash
|
||||||
|
CUDA Version: 12.8
|
||||||
|
```
|
||||||
|
#### 实际安装的 CUDA 编译器版本
|
||||||
|
```bash
|
||||||
|
Cuda compilation tools, release 12.8, V12.8.89
|
||||||
|
```
|
||||||
|
#### 那么对应的安装命令 (请注意不要横跨大版本!!!)
|
||||||
|
```bash
|
||||||
|
pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0 --index-url https://download.pytorch.org/whl/cu128
|
||||||
|
```
|
||||||
|
优先建议安装 pytorch 2.7.0(对应 vllm 0.9.0),具体安装指令请参考:[pytorch 官网](https://pytorch.org/get-started/locally/]\)
|
||||||
|
若显卡不支持,请安装 pytorch 2.5.1(对应 vllm 0.7.3),并将 requirements.txt 中 vllm==0.9.0 修改为 vllm==0.7.3
|
||||||
|
|
||||||
|
### 4. 安装依赖
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. 下载模型权重
|
||||||
|
此为官方权重文件,下载到本地任意路径即可,支持 IndexTTS-1.5 的权重
|
||||||
|
| HuggingFace | ModelScope |
|
||||||
|
|---------------------------------------------------------------|---------------------------------------------------------------------|
|
||||||
|
| [IndexTTS](https://huggingface.co/IndexTeam/Index-TTS) | [IndexTTS](https://modelscope.cn/models/IndexTeam/Index-TTS) |
|
||||||
|
| [IndexTTS-1.5](https://huggingface.co/IndexTeam/IndexTTS-1.5) | [IndexTTS-1.5](https://modelscope.cn/models/IndexTeam/IndexTTS-1.5) |
|
||||||
|
|
||||||
|
下面以ModelScope的安装方法为例
|
||||||
|
### 请注意:git需要安装并初始化启用lfs(如已安装可以跳过)
|
||||||
|
```bash
|
||||||
|
sudo apt-get install git-lfs
|
||||||
|
git lfs install
|
||||||
|
```
|
||||||
|
创建模型目录,并拉取模型
|
||||||
|
```bash
|
||||||
|
mkkdir model_dir
|
||||||
|
cd model_dir
|
||||||
|
git clone https://www.modelscope.cn/IndexTeam/IndexTTS-1.5.git
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. 模型权重转换
|
||||||
|
```bash
|
||||||
|
bash convert_hf_format.sh /path/to/your/model_dir
|
||||||
|
```
|
||||||
|
例如:你下载的IndexTTS-1.5模型存放在model_dir目录下,则执行以下命令
|
||||||
|
```bash
|
||||||
|
bash convert_hf_format.sh model_dir/IndexTTS-1.5
|
||||||
|
```
|
||||||
|
此操作会将官方的模型权重转换为 transformers 库兼容的版本,保存在模型权重路径下的 vllm 文件夹中,方便后续 vllm 库加载模型权重
|
||||||
|
|
||||||
|
### 6. 更改接口适配一下项目
|
||||||
|
接口返回数据与项目不适配需要调整一下,使其直接返回音频数据
|
||||||
|
```bash
|
||||||
|
@app.post("/tts", responses={
|
||||||
|
200: {"content": {"application/octet-stream": {}}},
|
||||||
|
500: {"content": {"application/json": {}}}
|
||||||
|
})
|
||||||
|
async def tts_api(request: Request):
|
||||||
|
try:
|
||||||
|
data = await request.json()
|
||||||
|
text = data["text"]
|
||||||
|
character = data["character"]
|
||||||
|
|
||||||
|
global tts
|
||||||
|
sr, wav = await tts.infer_with_ref_audio_embed(character, text)
|
||||||
|
|
||||||
|
return Response(content=wav.tobytes(), media_type="application/octet-stream")
|
||||||
|
|
||||||
|
except Exception as ex:
|
||||||
|
tb_str = ''.join(traceback.format_exception(type(ex), ex, ex.__traceback__))
|
||||||
|
print(tb_str)
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=500,
|
||||||
|
content={
|
||||||
|
"status": "error",
|
||||||
|
"error": str(tb_str)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 7.编写sh启动脚本(请注意要在相应的conda环境下运行)
|
||||||
|
```bash
|
||||||
|
vi start_api.sh
|
||||||
|
```
|
||||||
|
### 将下面内容粘贴进去并按:输入wq保存
|
||||||
|
#### 脚本中的/home/system/indexTTS/index-tts-vllm/model_dir/IndexTTS-1.5 请自行修改为实际路径
|
||||||
|
```bash
|
||||||
|
# 激活conda环境
|
||||||
|
conda activate index-tts-vllm
|
||||||
|
echo "激活项目conda环境"
|
||||||
|
sleep 2
|
||||||
|
# 查找占用11996端口的进程号
|
||||||
|
PID_VLLM=$(sudo netstat -tulnp | grep 11996 | awk '{print $7}' | cut -d'/' -f1)
|
||||||
|
|
||||||
|
# 检查是否找到进程号
|
||||||
|
if [ -z "$PID_VLLM" ]; then
|
||||||
|
echo "没有找到占用11996端口的进程"
|
||||||
|
else
|
||||||
|
echo "找到占用11996端口的进程,进程号为: $PID_VLLM"
|
||||||
|
# 先尝试普通kill,等待2秒
|
||||||
|
kill $PID_VLLM
|
||||||
|
sleep 2
|
||||||
|
# 检查进程是否还在
|
||||||
|
if ps -p $PID_VLLM > /dev/null; then
|
||||||
|
echo "进程仍在运行,强制终止..."
|
||||||
|
kill -9 $PID_VLLM
|
||||||
|
fi
|
||||||
|
echo "已终止进程 $PID_VLLM"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 创建tmp目录(如果不存在)
|
||||||
|
mkdir -p tmp
|
||||||
|
|
||||||
|
# 后台运行api_server.py,日志重定向到tmp/server.log
|
||||||
|
export VLLM_USE_V1=0
|
||||||
|
nohup python api_server.py --model_dir /home/system/indexTTS/index-tts-vllm/model_dir/IndexTTS-1.5 --port 11996 > tmp/server.log 2>&1 &
|
||||||
|
echo "api_server.py 已在后台运行,日志请查看 tmp/server.log"
|
||||||
|
```
|
||||||
|
给脚本执行权限并运行脚本
|
||||||
|
```bash
|
||||||
|
chmod +x tmp
|
||||||
|
./start_api.sh
|
||||||
|
```
|
||||||
|
日志会在tmp/server.log中输出,可以通过以下命令查看日志情况
|
||||||
|
```bash
|
||||||
|
tail -f tmp/server.log
|
||||||
|
```
|
||||||
|
## 音色配置
|
||||||
|
index-tts-vllm支持通过配置文件注册自定义音色,支持单音色和混合音色配置。
|
||||||
|
在项目根目录下的assets/speaker.json文件中配置自定义音色
|
||||||
|
### 配置格式说明
|
||||||
|
```bash
|
||||||
|
{
|
||||||
|
"说话人名称1": [
|
||||||
|
"音频文件路径1.wav",
|
||||||
|
"音频文件路径2.wav"
|
||||||
|
],
|
||||||
|
"说话人名称2": [
|
||||||
|
"音频文件路径3.wav"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### 注意
|
||||||
|
添加后需在智控台中添加相应的说话人(单模块则更换相应的voice)
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
# PaddleSpeechTTS集成xiaozhi服务
|
||||||
|
|
||||||
|
## 一、基础环境要求
|
||||||
|
操作系统:Windows / Linux / WSL 2
|
||||||
|
|
||||||
|
Python 版本:3.9以上(请根据Paddle官方教程调整)
|
||||||
|
|
||||||
|
Paddle 版本:官方最新版本 ```https://www.paddlepaddle.org.cn/install```
|
||||||
|
|
||||||
|
依赖管理工具:conda 或 venv
|
||||||
|
|
||||||
|
## 二、启动paddlespeech服务
|
||||||
|
### 1.从paddlespeech官方仓库拉取源码
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/PaddlePaddle/PaddleSpeech.git
|
||||||
|
```
|
||||||
|
### 2.建立虚拟环境
|
||||||
|
```bash
|
||||||
|
#请根据Paddle官方支持的python版本建立环境 ```https://www.paddlepaddle.org.cn/install```
|
||||||
|
conda create -n paddle_env python=3.10 -y
|
||||||
|
conda activate paddle_env
|
||||||
|
```
|
||||||
|
### 3.进入paddlespeech目录
|
||||||
|
```bash
|
||||||
|
cd PaddleSpeech
|
||||||
|
```
|
||||||
|
### 4.安装paddlespeech
|
||||||
|
```bash
|
||||||
|
pip install pytest-runner -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
|
||||||
|
#以下命令使用任意一个
|
||||||
|
pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
|
||||||
|
pip install paddlespeech -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
```
|
||||||
|
### 5.使用命令自动下载语音模型
|
||||||
|
```bash
|
||||||
|
paddlespeech tts --input "你好,这是一次测试"
|
||||||
|
```
|
||||||
|
此步骤会自动下载模型缓存至本地 .paddlespeech/models 目录
|
||||||
|
|
||||||
|
### 6.修改tts_online_application.yaml配置
|
||||||
|
参考目录 ```"PaddleSpeech\demos\streaming_tts_server\conf\tts_online_application.yaml"```
|
||||||
|
选择```tts_online_application.yaml```文件用编辑器打开,设置```protocol```为```websocket```
|
||||||
|
|
||||||
|
### 7.启动服务
|
||||||
|
```yaml
|
||||||
|
paddlespeech_server start --config_file ./demos/streaming_tts_server/conf/tts_online_application.yaml
|
||||||
|
#官方默认启动命令:
|
||||||
|
paddlespeech_server start --config_file ./conf/tts_online_application.yaml
|
||||||
|
```
|
||||||
|
请根据你的```tts_online_application.yaml```的实际目录来启动命令,看到如下日志即启动成功
|
||||||
|
```
|
||||||
|
Prefix dict has been built successfully.
|
||||||
|
[2025-08-07 10:03:11,312] [ DEBUG] __init__.py:166 - Prefix dict has been built successfully.
|
||||||
|
INFO: Started server process [2298]
|
||||||
|
INFO: Waiting for application startup.
|
||||||
|
INFO: Application startup complete.
|
||||||
|
INFO: Uvicorn running on http://0.0.0.0:8092 (Press CTRL+C to quit)
|
||||||
|
```
|
||||||
|
|
||||||
|
## 三、修改小智的配置文件
|
||||||
|
### 1.```main/xiaozhi-server/core/providers/tts/paddle_speech.py```
|
||||||
|
|
||||||
|
### 2.```main/xiaozhi-server/data/.config.yaml```
|
||||||
|
使用单模块部署
|
||||||
|
```yaml
|
||||||
|
selected_module:
|
||||||
|
TTS: PaddleSpeechTTS
|
||||||
|
TTS:
|
||||||
|
PaddleSpeechTTS:
|
||||||
|
type: paddle_speech
|
||||||
|
protocol: websocket
|
||||||
|
url: ws://127.0.0.1:8092/paddlespeech/tts/streaming # TTS 服务的 URL 地址,指向本地服务器 [websocket默认ws://127.0.0.1:8092/paddlespeech/tts/streaming]
|
||||||
|
spk_id: 0 # 发音人 ID,0 通常表示默认的发音人
|
||||||
|
sample_rate: 24000 # 采样率 [websocket默认24000,http默认0 自动选择]
|
||||||
|
speed: 1.0 # 语速,1.0 表示正常语速,>1 表示加快,<1 表示减慢
|
||||||
|
volume: 1.0 # 音量,1.0 表示正常音量,>1 表示增大,<1 表示减小
|
||||||
|
save_path: # 保存路径
|
||||||
|
```
|
||||||
|
### 3.启动xiaozhi服务
|
||||||
|
```py
|
||||||
|
python app.py
|
||||||
|
```
|
||||||
|
打开test目录下的test_page.html,测试连接和发送消息时paddlespeech端是否有输出日志
|
||||||
|
|
||||||
|
输出日志参考:
|
||||||
|
```
|
||||||
|
INFO: 127.0.0.1:44312 - "WebSocket /paddlespeech/tts/streaming" [accepted]
|
||||||
|
INFO: connection open
|
||||||
|
[2025-08-07 11:16:33,355] [ INFO] - sentence: 哈哈,怎么突然找我聊天啦?
|
||||||
|
[2025-08-07 11:16:33,356] [ INFO] - The durations of audio is: 2.4625 s
|
||||||
|
[2025-08-07 11:16:33,356] [ INFO] - first response time: 0.1143045425415039 s
|
||||||
|
[2025-08-07 11:16:33,356] [ INFO] - final response time: 0.4777836799621582 s
|
||||||
|
[2025-08-07 11:16:33,356] [ INFO] - RTF: 0.19402382942625715
|
||||||
|
[2025-08-07 11:16:33,356] [ INFO] - Other info: front time: 0.06514096260070801 s, first am infer time: 0.008037090301513672 s, first voc infer time: 0.04112648963928223 s,
|
||||||
|
[2025-08-07 11:16:33,356] [ INFO] - Complete the synthesis of the audio streams
|
||||||
|
INFO: connection closed
|
||||||
|
|
||||||
|
```
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# 语音识别、大语言模型、非流式语音合成、流式语音合成、视觉模型的性能测试工具使用指南
|
||||||
|
|
||||||
|
1.在main/xiaozhi-server目录下创建data目录
|
||||||
|
2.在data目录下创建.config.yaml文件
|
||||||
|
3.在.data/config.yaml中,写入你的语音识别、大语言模型、流式语音合成、视觉模型的参数
|
||||||
|
例如:
|
||||||
|
```
|
||||||
|
LLM:
|
||||||
|
ChatGLMLLM:
|
||||||
|
# 定义LLM API类型
|
||||||
|
type: openai
|
||||||
|
# glm-4-flash 是免费的,但是还是需要注册填写api_key的
|
||||||
|
# 可在这里找到你的api key https://bigmodel.cn/usercenter/proj-mgmt/apikeys
|
||||||
|
model_name: glm-4-flash
|
||||||
|
url: https://open.bigmodel.cn/api/paas/v4/
|
||||||
|
api_key: 你的chat-glm web key
|
||||||
|
|
||||||
|
TTS:
|
||||||
|
|
||||||
|
VLLM:
|
||||||
|
|
||||||
|
ASR:
|
||||||
|
```
|
||||||
|
4.在main/xiaozhi-server目录下运行performance_tester.py:
|
||||||
|
```
|
||||||
|
python performance_tester.py
|
||||||
|
```
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
# 声纹识别启用指南
|
# 声纹识别启用指南
|
||||||
|
|
||||||
本教程包含2个部分
|
本教程包含3个部分
|
||||||
- 1、如何部署声纹识别这个服务
|
- 1、如何部署声纹识别这个服务
|
||||||
- 2、全模块部署时,怎么配置声纹识别接口
|
- 2、全模块部署时,怎么配置声纹识别接口
|
||||||
|
- 3、最简化部署时,怎么配置声纹识别
|
||||||
|
|
||||||
# 1、如何部署声纹识别这个服务
|
# 1、如何部署声纹识别这个服务
|
||||||
|
|
||||||
@@ -15,7 +16,99 @@
|
|||||||
点击它,下载本项目源码压缩包。下载到你电脑后,解压它,此时它的名字可能叫`voiceprint-api-main`
|
点击它,下载本项目源码压缩包。下载到你电脑后,解压它,此时它的名字可能叫`voiceprint-api-main`
|
||||||
你需要把它重命名成`voiceprint-api`。
|
你需要把它重命名成`voiceprint-api`。
|
||||||
|
|
||||||
## 第二步,启动程序
|
## 第二步, 创建数据库和表
|
||||||
|
|
||||||
|
声纹识别需要依赖`mysql`数据库。如果你之前已经部署`智控台`,说明你已经安装了`mysql`。你可以共用它。
|
||||||
|
|
||||||
|
你可以你试一下在宿主机使用`telnet`命令,看看能不能正常访问`mysql`的`3306`端口。
|
||||||
|
```
|
||||||
|
telnet 127.0.0.1 3306
|
||||||
|
```
|
||||||
|
如果能访问到3306端口,请忽略以下的内容,直接进入第三步。
|
||||||
|
|
||||||
|
如果不能访问,你需要回忆一下,你的`mysql`是怎么安装的。
|
||||||
|
|
||||||
|
如果你的mysql是通过自己使用安装包安装的,说明你的`mysql`做了网络隔离。你可能先解访问`mysql`的`3306`端口这个问题。
|
||||||
|
|
||||||
|
如果你`mysql`是通过本项目的`docker-compose_all.yml`安装的。你需要找一下你当时创建数据库的`docker-compose_all.yml`文件,修改以下的内容
|
||||||
|
|
||||||
|
修改前
|
||||||
|
```
|
||||||
|
xiaozhi-esp32-server-db:
|
||||||
|
...
|
||||||
|
networks:
|
||||||
|
- default
|
||||||
|
expose:
|
||||||
|
- "3306:3306"
|
||||||
|
```
|
||||||
|
|
||||||
|
修改后
|
||||||
|
```
|
||||||
|
xiaozhi-esp32-server-db:
|
||||||
|
...
|
||||||
|
networks:
|
||||||
|
- default
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
|
```
|
||||||
|
|
||||||
|
注意是将`xiaozhi-esp32-server-db`下面的`expose`改成`ports`。改完后,需要重新启动。以下是重启mysql的命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
# 进入你docker-compose_all.yml所在的文件夹,例如我的是xiaozhi-server
|
||||||
|
cd xiaozhi-server
|
||||||
|
docker compose -f docker-compose_all.yml down
|
||||||
|
docker compose -f docker-compose.yml up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
启动完后,在宿主机再使用`telnet`命令,看看能不能正常访问`mysql`的`3306`端口。
|
||||||
|
```
|
||||||
|
telnet 127.0.0.1 3306
|
||||||
|
```
|
||||||
|
正常来说这样就可以访问的了。
|
||||||
|
|
||||||
|
## 第三步, 创建数据库和表
|
||||||
|
如果你的宿主机,能正常访问mysql数据库,那就在mysql上创建一个名字为`voiceprint_db`的数据库和`voiceprints`表。
|
||||||
|
|
||||||
|
```
|
||||||
|
CREATE DATABASE voiceprint_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
USE voiceprint_db;
|
||||||
|
|
||||||
|
CREATE TABLE voiceprints (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
speaker_id VARCHAR(255) NOT NULL UNIQUE,
|
||||||
|
feature_vector LONGBLOB NOT NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
INDEX idx_speaker_id (speaker_id)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
```
|
||||||
|
|
||||||
|
## 第四步, 配置数据库连接
|
||||||
|
|
||||||
|
进入`voiceprint-api`文件夹,创建名字为`data`的文件夹。
|
||||||
|
|
||||||
|
把`voiceprint-api`根目录里的`voiceprint.yaml`,复制到`data`的文件夹,将它重命名为`.voiceprint.yaml`
|
||||||
|
|
||||||
|
接下来,你需要重点配置一下`.voiceprint.yaml`里的数据库连接。
|
||||||
|
|
||||||
|
```
|
||||||
|
mysql:
|
||||||
|
host: "127.0.0.1"
|
||||||
|
port: 3306
|
||||||
|
user: "root"
|
||||||
|
password: "your_password"
|
||||||
|
database: "voiceprint_db"
|
||||||
|
```
|
||||||
|
|
||||||
|
注意!由于你的声纹识别服务是使用docker部署,`host`需要填写成你`mysql所在机器的局域网ip`。
|
||||||
|
|
||||||
|
注意!由于你的声纹识别服务是使用docker部署,`host`需要填写成你`mysql所在机器的局域网ip`。
|
||||||
|
|
||||||
|
注意!由于你的声纹识别服务是使用docker部署,`host`需要填写成你`mysql所在机器的局域网ip`。
|
||||||
|
|
||||||
|
## 第五步,启动程序
|
||||||
这个项目是一个很简单的项目,建议使用docker运行。不过如果你不想使用docker运行,你可以参考[这个页面](https://github.com/xinnan-tech/voiceprint-api/blob/main/README.md)使用源码运行。以下是docker运行的方法
|
这个项目是一个很简单的项目,建议使用docker运行。不过如果你不想使用docker运行,你可以参考[这个页面](https://github.com/xinnan-tech/voiceprint-api/blob/main/README.md)使用源码运行。以下是docker运行的方法
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -94,3 +187,47 @@ http://192.168.1.25:8005/voiceprint/health?key=abcd
|
|||||||
## 第三步 和你的智能体聊天
|
## 第三步 和你的智能体聊天
|
||||||
|
|
||||||
将你的设备通电,问它,你知道我是谁吗?如果他能回答得出,说明声纹识别功能正常。
|
将你的设备通电,问它,你知道我是谁吗?如果他能回答得出,说明声纹识别功能正常。
|
||||||
|
|
||||||
|
# 3、最简化部署时,怎么配置声纹识别
|
||||||
|
|
||||||
|
## 第一步 配置接口
|
||||||
|
打开 `xiaozhi-server/data/.config.yaml` 文件(如果没有需要创建),然后添加/修改以下内容:
|
||||||
|
|
||||||
|
```
|
||||||
|
# 声纹识别配置
|
||||||
|
voiceprint:
|
||||||
|
# 声纹接口地址
|
||||||
|
url: 你的声纹接口地址
|
||||||
|
# 说话人配置:speaker_id,名称,描述
|
||||||
|
speakers:
|
||||||
|
- "test1,张三,张三是一个程序员"
|
||||||
|
- "test2,李四,李四是一个产品经理"
|
||||||
|
- "test3,王五,王五是一个设计师"
|
||||||
|
```
|
||||||
|
|
||||||
|
把上一步得来的 `声纹接口地址` 粘贴到 `url` 里。然后保存。
|
||||||
|
|
||||||
|
`speakers` 参数依据需求添加。这里需要注意这个 `speaker_id` 参数,后面注册声纹会用到。
|
||||||
|
|
||||||
|
## 第二步 注册声纹
|
||||||
|
如果你已经启动了声纹服务,本地浏览器里访问 `http://localhost:8005/voiceprint/docs` 即可查看 API 文档,这里只说明注册声纹的 API 如何使用。
|
||||||
|
|
||||||
|
注册声纹的 API 地址为 `http://localhost:8005/voiceprint/register`,请求方式为 POST。
|
||||||
|
|
||||||
|
请求头需要包含 Bearer Token 认证,token 为 `声纹接口地址` 中 `?key=` 后的部分,比如如果我的声纹注册地址为 `http://127.0.0.1:8005/voiceprint/health?key=abcd`,那么我的 token 就是`abcd`。
|
||||||
|
|
||||||
|
请求体包含说话人 ID(speaker_id),和 WAV 音频文件(file),请求示例如下:
|
||||||
|
|
||||||
|
```
|
||||||
|
curl -X POST \
|
||||||
|
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
|
||||||
|
-F "speaker_id=your_speaker_id_here" \
|
||||||
|
-F "file=@/path/to/your/file" \
|
||||||
|
http://localhost:8005/voiceprint/register
|
||||||
|
```
|
||||||
|
|
||||||
|
这里的 `file` 是要注册的说话人说话的音频文件, `speaker_id` 需要和第一步配置接口的 `speaker_id` 保持一致。比如说我需要注册张三的声纹,在 `.config.yaml` 中填的张三的 `speaker_id` 为 `test1`,那么我注册张三声纹的时候,请求体里填的 `speaker_id` 就是 `test1`, `file` 填的就是张三说一段话的音频文件。
|
||||||
|
|
||||||
|
## 第三步 启动服务
|
||||||
|
|
||||||
|
启动小智服务器和声纹服务,即可正常使用。
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
* [3.1. `xiaozhi-server` (核心AI引擎 - Python实现)](#31-xiaozhi-server-核心ai引擎---python实现)
|
* [3.1. `xiaozhi-server` (核心AI引擎 - Python实现)](#31-xiaozhi-server-核心ai引擎---python实现)
|
||||||
* [3.2. `manager-api` (管理后端 - Java Spring Boot实现)](#32-manager-api-管理后端---java-spring-boot实现)
|
* [3.2. `manager-api` (管理后端 - Java Spring Boot实现)](#32-manager-api-管理后端---java-spring-boot实现)
|
||||||
* [3.3. `manager-web` (Web管理前端 - Vue.js实现)](#33-manager-web-web管理前端---vuejs实现)
|
* [3.3. `manager-web` (Web管理前端 - Vue.js实现)](#33-manager-web-web管理前端---vuejs实现)
|
||||||
|
* [3.4. `manager-mobile` (移动管理端 - uni-app+Vue3实现)](#34-manager-mobile-移动管理端---uni-appvue3实现)
|
||||||
4. [数据流与交互机制](#4-数据流与交互机制)
|
4. [数据流与交互机制](#4-数据流与交互机制)
|
||||||
5. [核心功能概要](#5-核心功能概要)
|
5. [核心功能概要](#5-核心功能概要)
|
||||||
6. [部署与配置概述](#6-部署与配置概述)
|
6. [部署与配置概述](#6-部署与配置概述)
|
||||||
@@ -58,6 +59,14 @@
|
|||||||
* (潜在功能)监控系统运行状态、查看日志、进行故障排查等。
|
* (潜在功能)监控系统运行状态、查看日志、进行故障排查等。
|
||||||
* 与 `manager-api` 提供的所有后端管理功能进行全面的交互。
|
* 与 `manager-api` 提供的所有后端管理功能进行全面的交互。
|
||||||
|
|
||||||
|
5. **`manager-mobile` (智控台移动版 - uni-app实现):**
|
||||||
|
这是一个基于uni-app v3 + Vue 3 + Vite的跨端移动管理端,支持App(Android & iOS)和微信小程序。其主要能力包括:
|
||||||
|
* 提供移动设备上的便捷管理界面,与manager-web功能类似但针对移动端进行了优化。
|
||||||
|
* 支持用户登录、设备管理、AI服务配置等核心功能。
|
||||||
|
* 跨平台适配,一套代码可同时运行在iOS、Android和微信小程序上。
|
||||||
|
* 基于alova + @alova/adapter-uniapp实现网络请求,与manager-api无缝集成。
|
||||||
|
* 使用pinia进行状态管理,确保数据一致性。
|
||||||
|
|
||||||
**高层交互流程概述:**
|
**高层交互流程概述:**
|
||||||
|
|
||||||
* **语音交互主线:** **ESP32设备**捕捉到用户语音后,通过**WebSocket**将音频数据实时传输给**`xiaozhi-server`**。`xiaozhi-server`完成一系列AI处理(VAD、ASR、LLM交互、TTS)后,再通过WebSocket将合成的语音回复发送回ESP32设备进行播放。所有与语音直接相关的实时交互均在此链路完成。
|
* **语音交互主线:** **ESP32设备**捕捉到用户语音后,通过**WebSocket**将音频数据实时传输给**`xiaozhi-server`**。`xiaozhi-server`完成一系列AI处理(VAD、ASR、LLM交互、TTS)后,再通过WebSocket将合成的语音回复发送回ESP32设备进行播放。所有与语音直接相关的实时交互均在此链路完成。
|
||||||
@@ -71,6 +80,7 @@ xiaozhi-esp32-server
|
|||||||
├─ xiaozhi-server 8000 端口 Python语言开发 负责与esp32通信
|
├─ xiaozhi-server 8000 端口 Python语言开发 负责与esp32通信
|
||||||
├─ manager-web 8001 端口 Node.js+Vue开发 负责提供控制台的web界面
|
├─ manager-web 8001 端口 Node.js+Vue开发 负责提供控制台的web界面
|
||||||
├─ manager-api 8002 端口 Java语言开发 负责提供控制台的api
|
├─ manager-api 8002 端口 Java语言开发 负责提供控制台的api
|
||||||
|
└─ manager-mobile 跨平台移动应用 uni-app+Vue3开发 负责提供移动版智控台管理
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -294,6 +304,68 @@ xiaozhi-esp32-server
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### 3.4. `manager-mobile` (智控台移动版 - uni-app实现)
|
||||||
|
|
||||||
|
`manager-mobile` 组件是一个基于uni-app v3 + Vue 3 + Vite的跨端移动管理端,支持App(Android & iOS)和微信小程序。它为系统管理员提供了移动端的管理界面,使得管理操作更加便捷。
|
||||||
|
|
||||||
|
* **核心目标:**
|
||||||
|
* 提供移动设备上的便捷管理界面,与manager-web功能类似但针对移动端进行了优化。
|
||||||
|
* 支持用户登录、设备管理、AI服务配置等核心功能。
|
||||||
|
* 跨平台适配,一套代码可同时运行在iOS、Android和微信小程序上。
|
||||||
|
* 为移动用户提供流畅、高效的管理体验。
|
||||||
|
|
||||||
|
* **平台兼容性:**
|
||||||
|
|
||||||
|
| H5 | iOS | Android | 微信小程序 |
|
||||||
|
| -- | --- | ------- | ---------- |
|
||||||
|
| √ | √ | √ | √ |
|
||||||
|
|
||||||
|
* **核心技术栈:**
|
||||||
|
* **uni-app v3:** 一个使用Vue.js开发所有前端应用的框架,支持iOS、Android、H5、以及各种小程序。
|
||||||
|
* **Vue 3:** 用于构建用户界面的渐进式框架,提供了更好的性能和新特性。
|
||||||
|
* **Vite:** 下一代前端开发与构建工具,提供极速的开发体验。
|
||||||
|
* **pnpm:** 快速、节省磁盘空间的包管理器。
|
||||||
|
* **alova:** 轻量级、灵活的请求策略库,搭配@alova/adapter-uniapp适配uni-app环境。
|
||||||
|
* **pinia:** Vue的状态管理库,替代Vuex,提供更简洁的API和更好的TypeScript支持。
|
||||||
|
* **UnoCSS:** 具有高性能且极具灵活性的即时原子化CSS引擎。
|
||||||
|
* **TypeScript:** 提供类型安全的开发体验。
|
||||||
|
|
||||||
|
* **关键实现细节:**
|
||||||
|
|
||||||
|
1. **跨平台架构:**
|
||||||
|
* 基于uni-app框架,实现了一套代码多端运行的目标,大幅减少了开发和维护成本。
|
||||||
|
* 针对不同平台的特性和限制,通过条件编译进行平台特定的代码处理。
|
||||||
|
|
||||||
|
2. **项目结构:**
|
||||||
|
* **`src/App.vue`:** 应用的根组件,定义了全局的样式和配置。
|
||||||
|
* **`src/main.ts`:** 应用的入口文件,负责初始化Vue实例、注册插件和路由拦截器。
|
||||||
|
* **`src/pages/`:** 存放应用的页面组件,如登录页、设备管理页等。
|
||||||
|
* **`src/layouts/`:** 定义应用的布局组件,如默认布局、带tabbar的布局等。
|
||||||
|
* **`src/api/`:** 封装与后端API的通信逻辑。
|
||||||
|
* **`src/store/`:** 使用pinia进行状态管理。
|
||||||
|
* **`src/components/`:** 存放可复用的组件。
|
||||||
|
* **`src/utils/`:** 提供通用的工具函数。
|
||||||
|
|
||||||
|
3. **网络请求:**
|
||||||
|
* 基于alova + @alova/adapter-uniapp实现网络请求,统一处理请求头、认证、错误等。
|
||||||
|
* 请求地址和环境配置通过.env文件管理,支持不同环境的切换。
|
||||||
|
|
||||||
|
4. **路由与鉴权:**
|
||||||
|
* 使用uni-app的路由系统,结合路由拦截器实现页面的登录验证和权限控制。
|
||||||
|
* 未登录用户访问需要认证的页面时,会被重定向到登录页。
|
||||||
|
|
||||||
|
5. **状态管理:**
|
||||||
|
* 使用pinia管理应用状态,如用户信息、设备列表等。
|
||||||
|
* 通过pinia-plugin-persistedstate插件实现状态的持久化存储。
|
||||||
|
|
||||||
|
6. **构建与发布:**
|
||||||
|
* 支持多种构建命令,如构建微信小程序、Android和iOS App等。
|
||||||
|
* 使用HBuilderX进行App的云打包,简化了打包流程。
|
||||||
|
|
||||||
|
`manager-mobile` 通过这些技术的应用,为用户提供了一个功能完备、体验流畅的移动端管理工具,使得管理员可以随时随地进行系统管理和配置。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 4. 数据流与交互机制
|
## 4. 数据流与交互机制
|
||||||
|
|
||||||
`xiaozhi-esp32-server` 系统通过各组件间定义清晰的数据流和交互协议来协同工作。主要的通信方式依赖于针对实时交互优化的WebSocket协议和适用于客户端-服务器请求的RESTful API。
|
`xiaozhi-esp32-server` 系统通过各组件间定义清晰的数据流和交互协议来协同工作。主要的通信方式依赖于针对实时交互优化的WebSocket协议和适用于客户端-服务器请求的RESTful API。
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
* [3.1. `xiaozhi-server` (Core AI Engine - Python Implementation)](#31-xiaozhi-server-core-ai-engine---python-implementation)
|
* [3.1. `xiaozhi-server` (Core AI Engine - Python Implementation)](#31-xiaozhi-server-core-ai-engine---python-implementation)
|
||||||
* [3.2. `manager-api` (Management Backend - Java Spring Boot Implementation)](#32-manager-api-management-backend---java-spring-boot-implementation)
|
* [3.2. `manager-api` (Management Backend - Java Spring Boot Implementation)](#32-manager-api-management-backend---java-spring-boot-implementation)
|
||||||
* [3.3. `manager-web` (Web Management Frontend - Vue.js Implementation)](#33-manager-web-web-management-frontend---vuejs-implementation)
|
* [3.3. `manager-web` (Web Management Frontend - Vue.js Implementation)](#33-manager-web-web-management-frontend---vuejs-implementation)
|
||||||
|
* [3.4. `manager-mobile` (Mobile Management Console - uni-app Implementation)](#34-manager-mobile-mobile-management-console---uniapp-implementation)
|
||||||
4. [Data Flow and Interaction Mechanisms](#4-data-flow-and-interaction-mechanisms)
|
4. [Data Flow and Interaction Mechanisms](#4-data-flow-and-interaction-mechanisms)
|
||||||
5. [Key Features Summary](#5-key-features-summary)
|
5. [Key Features Summary](#5-key-features-summary)
|
||||||
6. [Deployment and Configuration Overview](#6-deployment-and-configuration-overview)
|
6. [Deployment and Configuration Overview](#6-deployment-and-configuration-overview)
|
||||||
@@ -72,6 +73,7 @@ xiaozhi-esp32-server
|
|||||||
├─ xiaozhi-server Port 8000 Python development Responsible for ESP32 communication
|
├─ xiaozhi-server Port 8000 Python development Responsible for ESP32 communication
|
||||||
├─ manager-web Port 8001 Node.js+Vue development Responsible for providing web interface for console
|
├─ manager-web Port 8001 Node.js+Vue development Responsible for providing web interface for console
|
||||||
├─ manager-api Port 8002 Java development Responsible for providing console API
|
├─ manager-api Port 8002 Java development Responsible for providing console API
|
||||||
|
└─ manager-mobile Cross-platform mobile application uni-app+Vue3 development Responsible for providing mobile console management
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -190,7 +192,70 @@ The `manager-web` is a Single Page Application (SPA) providing the administrativ
|
|||||||
4. **State Management (`src/store/index.js`):** Vuex manages global state (user info, device lists, etc.) via state, getters, mutations, and actions (often involving API calls).
|
4. **State Management (`src/store/index.js`):** Vuex manages global state (user info, device lists, etc.) via state, getters, mutations, and actions (often involving API calls).
|
||||||
5. **API Communication (`src/apis/`):** Modularized API service files make asynchronous calls to `manager-api`.
|
5. **API Communication (`src/apis/`):** Modularized API service files make asynchronous calls to `manager-api`.
|
||||||
6. **Build Process & PWA Features:** Vue CLI (Webpack) bundles assets. Workbox enables PWA features like caching.
|
6. **Build Process & PWA Features:** Vue CLI (Webpack) bundles assets. Workbox enables PWA features like caching.
|
||||||
7. **Environment Configuration (`.env` files):** Manages settings like the `manager-api` base URL for different environments.
|
7. **Environment Configuration (`.env` files):**
|
||||||
|
* The `.env` (and `.env.development`, `.env.production`, etc.) files in the project root directory are used to define environment variables. These variables (such as `VUE_APP_API_BASE_URL` to specify the base URL of `manager-api`) can be accessed in the application code through `process.env.VUE_APP_XXX`, allowing configuration of different parameters for different build environments (development, testing, production).
|
||||||
|
|
||||||
|
`manager-web` constructs a powerful, maintainable, and user-friendly management interface through the comprehensive application of these technologies, providing solid frontend support for the configuration and monitoring of the `xiaozhi-esp32-server` system.
|
||||||
|
|
||||||
|
### 3.4. `manager-mobile` (Mobile Management Console - uni-app Implementation)
|
||||||
|
|
||||||
|
The `manager-mobile` component is a cross-platform mobile management application based on uni-app v3 + Vue 3 + Vite, supporting App (Android & iOS) and WeChat Mini Program. It provides system administrators with a mobile management interface, making management operations more convenient.
|
||||||
|
|
||||||
|
* **Core Objectives:**
|
||||||
|
* Provide a convenient management interface on mobile devices, similar in functionality to manager-web but optimized for mobile platforms.
|
||||||
|
* Support core functions such as user login, device management, and AI service configuration.
|
||||||
|
* Cross-platform adaptation, allowing a single codebase to run on iOS, Android, and WeChat Mini Programs.
|
||||||
|
* Provide mobile users with a smooth and efficient management experience.
|
||||||
|
|
||||||
|
* **Platform Compatibility:**
|
||||||
|
|
||||||
|
| H5 | iOS | Android | WeChat Mini Program |
|
||||||
|
| -- | --- | ------- | ------------------ |
|
||||||
|
| × | √ | √ | √ |
|
||||||
|
|
||||||
|
* **Core Technologies:**
|
||||||
|
* **uni-app v3:** A framework for developing all frontend applications using Vue.js, supporting iOS, Android, H5, and various mini-programs.
|
||||||
|
* **Vue 3:** A progressive framework for building user interfaces, providing better performance and new features.
|
||||||
|
* **Vite:** The next generation frontend development and build tool, offering an extremely fast development experience.
|
||||||
|
* **pnpm:** A fast, disk space-efficient package manager.
|
||||||
|
* **alova:** A lightweight, flexible request strategy library, paired with @alova/adapter-uniapp to adapt to the uni-app environment.
|
||||||
|
* **pinia:** State management library for Vue, replacing Vuex, providing a simpler API and better TypeScript support.
|
||||||
|
* **UnoCSS:** A high-performance and extremely flexible instant atomic CSS engine.
|
||||||
|
* **TypeScript:** Provides a type-safe development experience.
|
||||||
|
|
||||||
|
* **Key Implementation Details:**
|
||||||
|
|
||||||
|
1. **Cross-Platform Architecture:**
|
||||||
|
* Based on the uni-app framework, achieving the goal of "write once, run anywhere," significantly reducing development and maintenance costs.
|
||||||
|
* Handling platform-specific code through conditional compilation to address the characteristics and limitations of different platforms.
|
||||||
|
|
||||||
|
2. **Project Structure:**
|
||||||
|
* **`src/App.vue`:** The root component of the application, defining global styles and configurations.
|
||||||
|
* **`src/main.ts`:** The entry file of the application, responsible for initializing the Vue instance, registering plugins, and setting up route interceptors.
|
||||||
|
* **`src/pages/`:** Stores application page components, such as login pages, device management pages, etc.
|
||||||
|
* **`src/layouts/`:** Defines application layout components, such as default layouts, layouts with tabbar, etc.
|
||||||
|
* **`src/api/`:** Encapsulates communication logic with backend APIs.
|
||||||
|
* **`src/store/`:** Uses pinia for state management.
|
||||||
|
* **`src/components/`:** Stores reusable components.
|
||||||
|
* **`src/utils/`:** Provides common utility functions.
|
||||||
|
|
||||||
|
3. **Network Requests:**
|
||||||
|
* Implements network requests based on alova + @alova/adapter-uniapp, unified handling of request headers, authentication, errors, etc.
|
||||||
|
* Request addresses and environment configurations are managed through .env files, supporting switching between different environments.
|
||||||
|
|
||||||
|
4. **Routing and Authentication:**
|
||||||
|
* Uses uni-app's routing system, combined with route interceptors to implement page login verification and permission control.
|
||||||
|
* When unlogged users access pages requiring authentication, they are redirected to the login page.
|
||||||
|
|
||||||
|
5. **State Management:**
|
||||||
|
* Uses pinia to manage application state, such as user information, device lists, etc.
|
||||||
|
* Implements persistent storage of state through the pinia-plugin-persistedstate plugin.
|
||||||
|
|
||||||
|
6. **Build and Release:**
|
||||||
|
* Supports multiple build commands, such as building WeChat Mini Programs, Android, and iOS Apps.
|
||||||
|
* Uses HBuilderX for cloud packaging of Apps, simplifying the packaging process.
|
||||||
|
|
||||||
|
`manager-mobile` provides users with a fully functional, smooth mobile management tool through the application of these technologies, allowing administrators to perform system management and configuration anytime, anywhere.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
<hutool.version>5.8.24</hutool.version>
|
<hutool.version>5.8.24</hutool.version>
|
||||||
<jsoup.version>1.19.1</jsoup.version>
|
<jsoup.version>1.19.1</jsoup.version>
|
||||||
<knife4j.version>4.6.0</knife4j.version>
|
<knife4j.version>4.6.0</knife4j.version>
|
||||||
|
<springdoc.version>2.8.8</springdoc.version>
|
||||||
|
<commons-lang3.version>3.18.0</commons-lang3.version>
|
||||||
<shiro.version>2.0.2</shiro.version>
|
<shiro.version>2.0.2</shiro.version>
|
||||||
<captcha.version>1.6.2</captcha.version>
|
<captcha.version>1.6.2</captcha.version>
|
||||||
<guava.version>33.0.0-jre</guava.version>
|
<guava.version>33.0.0-jre</guava.version>
|
||||||
@@ -75,6 +77,7 @@
|
|||||||
<version>${captcha.version}</version>
|
<version>${captcha.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
@@ -190,11 +193,24 @@
|
|||||||
<artifactId>jsoup</artifactId>
|
<artifactId>jsoup</artifactId>
|
||||||
<version>${jsoup.version}</version>
|
<version>${jsoup.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--knife4j -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xingfudeshi</groupId>
|
<groupId>com.github.xingfudeshi</groupId>
|
||||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||||
<version>${knife4j.version}</version>
|
<version>${knife4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- springdoc -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
|
<version>${springdoc.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 日常工具包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons-lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ public interface Constant {
|
|||||||
/**
|
/**
|
||||||
* 版本号
|
* 版本号
|
||||||
*/
|
*/
|
||||||
public static final String VERSION = "0.7.1";
|
public static final String VERSION = "0.7.6";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 无效固件URL
|
* 无效固件URL
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package xiaozhi.common.utils;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
/**
|
||||||
|
* JSON-RPC2.0 格式规范对象
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class JsonRpcTwo {
|
||||||
|
private String jsonrpc = "2.0";
|
||||||
|
private String method;
|
||||||
|
private Object params;
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
public JsonRpcTwo(String method, Object params, Integer id) {
|
||||||
|
this.method = method;
|
||||||
|
this.params = params;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package xiaozhi.modules.agent.Enums;
|
||||||
|
|
||||||
|
import xiaozhi.common.utils.JsonUtils;
|
||||||
|
import xiaozhi.common.utils.JsonRpcTwo;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小智MCP JSON-RPC 请求json
|
||||||
|
*/
|
||||||
|
public class XiaoZhiMcpJsonRpcJson {
|
||||||
|
//小智初始化mcp请求json
|
||||||
|
private static final String INITIALIZE_JSON;
|
||||||
|
//小智mcp初始化成功,返回通知请求json
|
||||||
|
private static final String NOTIFICATIONS_INITIALIZED_JSON;
|
||||||
|
//小智mcp获取mcp工具集合请求json
|
||||||
|
private static final String TOOLS_LIST_REQUEST;
|
||||||
|
// 延迟加载
|
||||||
|
static {
|
||||||
|
INITIALIZE_JSON = JsonUtils.toJsonString(new JsonRpcTwo("initialize",
|
||||||
|
Map.of(
|
||||||
|
"protocolVersion", "2024-11-05",
|
||||||
|
"capabilities", Map.of(
|
||||||
|
"roots", Map.of("listChanged", false),
|
||||||
|
"sampling", Map.of()),
|
||||||
|
"clientInfo", Map.of(
|
||||||
|
"name", "xz-mcp-broker",
|
||||||
|
"version", "0.0.1")),
|
||||||
|
1));
|
||||||
|
NOTIFICATIONS_INITIALIZED_JSON = "{\"jsonrpc\":\"2.0\",\"method\":\"notifications/initialized\"}";
|
||||||
|
TOOLS_LIST_REQUEST = JsonUtils.toJsonString(new JsonRpcTwo("tools/list", null, 2));
|
||||||
|
}
|
||||||
|
public static String getInitializeJson(){
|
||||||
|
return INITIALIZE_JSON;
|
||||||
|
}
|
||||||
|
public static String getNotificationsInitializedJson(){
|
||||||
|
return NOTIFICATIONS_INITIALIZED_JSON;
|
||||||
|
}
|
||||||
|
public static String getToolsListJson(){
|
||||||
|
return TOOLS_LIST_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package xiaozhi.modules.agent.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MCP JSON-RPC 请求 DTO
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class McpJsonRpcRequest {
|
|
||||||
private String jsonrpc = "2.0";
|
|
||||||
private String method;
|
|
||||||
private Object params;
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
public McpJsonRpcRequest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public McpJsonRpcRequest(String method) {
|
|
||||||
this.method = method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public McpJsonRpcRequest(String method, Object params, Integer id) {
|
|
||||||
this.method = method;
|
|
||||||
this.params = params;
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public McpJsonRpcRequest(String method, Object params) {
|
|
||||||
this.method = method;
|
|
||||||
this.params = params;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -103,7 +103,11 @@ public class AgentChatHistoryServiceImpl extends ServiceImpl<AiAgentChatHistoryD
|
|||||||
wrapper.select(AgentChatHistoryEntity::getContent, AgentChatHistoryEntity::getAudioId)
|
wrapper.select(AgentChatHistoryEntity::getContent, AgentChatHistoryEntity::getAudioId)
|
||||||
.eq(AgentChatHistoryEntity::getAgentId, agentId)
|
.eq(AgentChatHistoryEntity::getAgentId, agentId)
|
||||||
.eq(AgentChatHistoryEntity::getChatType, AgentChatHistoryType.USER.getValue())
|
.eq(AgentChatHistoryEntity::getChatType, AgentChatHistoryType.USER.getValue())
|
||||||
.isNotNull(AgentChatHistoryEntity::getAudioId);
|
.isNotNull(AgentChatHistoryEntity::getAudioId)
|
||||||
|
// 添加此行,确保查询结果按照创建时间降序排列
|
||||||
|
// 使用id的原因:数据形式,id越大的创建时间就越晚,所以使用id的结果和创建时间降序排列结果一样
|
||||||
|
// id作为降序排列的优势,性能高,有主键索引,不用在排序的时候重新进行排除扫描比较
|
||||||
|
.orderByDesc(AgentChatHistoryEntity::getId);
|
||||||
|
|
||||||
// 构建分页查询,查询前50页数据
|
// 构建分页查询,查询前50页数据
|
||||||
Page<AgentChatHistoryEntity> pageParam = new Page<>(0, 50);
|
Page<AgentChatHistoryEntity> pageParam = new Page<>(0, 50);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import xiaozhi.common.constant.Constant;
|
|||||||
import xiaozhi.common.utils.AESUtils;
|
import xiaozhi.common.utils.AESUtils;
|
||||||
import xiaozhi.common.utils.HashEncryptionUtil;
|
import xiaozhi.common.utils.HashEncryptionUtil;
|
||||||
import xiaozhi.common.utils.JsonUtils;
|
import xiaozhi.common.utils.JsonUtils;
|
||||||
import xiaozhi.modules.agent.dto.McpJsonRpcRequest;
|
import xiaozhi.modules.agent.Enums.XiaoZhiMcpJsonRpcJson;
|
||||||
import xiaozhi.modules.agent.service.AgentMcpAccessPointService;
|
import xiaozhi.modules.agent.service.AgentMcpAccessPointService;
|
||||||
import xiaozhi.modules.sys.service.SysParamsService;
|
import xiaozhi.modules.sys.service.SysParamsService;
|
||||||
import xiaozhi.modules.sys.utils.WebSocketClientManager;
|
import xiaozhi.modules.sys.utils.WebSocketClientManager;
|
||||||
@@ -65,22 +65,13 @@ public class AgentMcpAccessPointServiceImpl implements AgentMcpAccessPointServic
|
|||||||
try (WebSocketClientManager client = WebSocketClientManager.build(
|
try (WebSocketClientManager client = WebSocketClientManager.build(
|
||||||
new WebSocketClientManager.Builder()
|
new WebSocketClientManager.Builder()
|
||||||
.uri(wsUrl)
|
.uri(wsUrl)
|
||||||
|
.bufferSize(1024 * 1024)
|
||||||
.connectTimeout(8, TimeUnit.SECONDS)
|
.connectTimeout(8, TimeUnit.SECONDS)
|
||||||
.maxSessionDuration(10, TimeUnit.SECONDS))) {
|
.maxSessionDuration(10, TimeUnit.SECONDS))) {
|
||||||
|
|
||||||
// 步骤1: 发送初始化消息并等待响应
|
// 步骤1: 发送初始化消息并等待响应
|
||||||
log.info("发送MCP初始化消息,智能体ID: {}", id);
|
log.info("发送MCP初始化消息,智能体ID: {}", id);
|
||||||
McpJsonRpcRequest initializeRequest = new McpJsonRpcRequest("initialize",
|
client.sendText(XiaoZhiMcpJsonRpcJson.getInitializeJson());
|
||||||
Map.of(
|
|
||||||
"protocolVersion", "2024-11-05",
|
|
||||||
"capabilities", Map.of(
|
|
||||||
"roots", Map.of("listChanged", false),
|
|
||||||
"sampling", Map.of()),
|
|
||||||
"clientInfo", Map.of(
|
|
||||||
"name", "xz-mcp-broker",
|
|
||||||
"version", "0.0.1")),
|
|
||||||
1);
|
|
||||||
client.sendJson(initializeRequest);
|
|
||||||
|
|
||||||
// 等待初始化响应 (id=1) - 移除固定延迟,改为响应驱动
|
// 等待初始化响应 (id=1) - 移除固定延迟,改为响应驱动
|
||||||
List<String> initResponses = client.listenerWithoutClose(response -> {
|
List<String> initResponses = client.listenerWithoutClose(response -> {
|
||||||
@@ -124,13 +115,10 @@ public class AgentMcpAccessPointServiceImpl implements AgentMcpAccessPointServic
|
|||||||
|
|
||||||
// 步骤2: 发送初始化完成通知 - 只有在收到initialize响应后才发送
|
// 步骤2: 发送初始化完成通知 - 只有在收到initialize响应后才发送
|
||||||
log.info("发送MCP初始化完成通知,智能体ID: {}", id);
|
log.info("发送MCP初始化完成通知,智能体ID: {}", id);
|
||||||
String notificationJson = "{\"jsonrpc\":\"2.0\",\"method\":\"notifications/initialized\"}";
|
client.sendText(XiaoZhiMcpJsonRpcJson.getNotificationsInitializedJson());
|
||||||
client.sendText(notificationJson);
|
|
||||||
|
|
||||||
// 步骤3: 发送工具列表请求 - 立即发送,无需额外延迟
|
// 步骤3: 发送工具列表请求 - 立即发送,无需额外延迟
|
||||||
log.info("发送MCP工具列表请求,智能体ID: {}", id);
|
log.info("发送MCP工具列表请求,智能体ID: {}", id);
|
||||||
McpJsonRpcRequest toolsRequest = new McpJsonRpcRequest("tools/list", null, 2);
|
client.sendText(XiaoZhiMcpJsonRpcJson.getToolsListJson());
|
||||||
client.sendJson(toolsRequest);
|
|
||||||
|
|
||||||
// 等待工具列表响应 (id=2)
|
// 等待工具列表响应 (id=2)
|
||||||
List<String> toolsResponses = client.listener(response -> {
|
List<String> toolsResponses = client.listener(response -> {
|
||||||
@@ -178,7 +166,7 @@ public class AgentMcpAccessPointServiceImpl implements AgentMcpAccessPointServic
|
|||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("获取智能体 MCP 工具列表失败,智能体ID: {}", id, e);
|
log.error("获取智能体 MCP 工具列表失败,智能体ID: {},错误原因:{}", id, e.getMessage());
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import xiaozhi.modules.agent.service.AgentTemplateService;
|
|||||||
import xiaozhi.modules.agent.vo.AgentInfoVO;
|
import xiaozhi.modules.agent.vo.AgentInfoVO;
|
||||||
import xiaozhi.modules.device.service.DeviceService;
|
import xiaozhi.modules.device.service.DeviceService;
|
||||||
import xiaozhi.modules.model.dto.ModelProviderDTO;
|
import xiaozhi.modules.model.dto.ModelProviderDTO;
|
||||||
|
import xiaozhi.modules.model.entity.ModelConfigEntity;
|
||||||
import xiaozhi.modules.model.service.ModelConfigService;
|
import xiaozhi.modules.model.service.ModelConfigService;
|
||||||
import xiaozhi.modules.model.service.ModelProviderService;
|
import xiaozhi.modules.model.service.ModelProviderService;
|
||||||
import xiaozhi.modules.security.user.SecurityUser;
|
import xiaozhi.modules.security.user.SecurityUser;
|
||||||
@@ -324,9 +325,35 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
|
|||||||
// 删除音频数据
|
// 删除音频数据
|
||||||
agentChatHistoryService.deleteByAgentId(existingEntity.getId(), true, false);
|
agentChatHistoryService.deleteByAgentId(existingEntity.getId(), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean b = validateLLMIntentParams(dto.getLlmModelId(), dto.getIntentModelId());
|
||||||
|
if (!b) {
|
||||||
|
throw new RenException("LLM大模型和Intent意图识别,选择参数不匹配");
|
||||||
|
}
|
||||||
this.updateById(existingEntity);
|
this.updateById(existingEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证大语言模型和意图识别的参数是否符合匹配
|
||||||
|
*
|
||||||
|
* @param llmModelId 大语言模型id
|
||||||
|
* @param intentModelId 意图识别id
|
||||||
|
* @return T 匹配 : F 不匹配
|
||||||
|
*/
|
||||||
|
private boolean validateLLMIntentParams(String llmModelId, String intentModelId) {
|
||||||
|
if (StringUtils.isBlank(llmModelId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ModelConfigEntity llmModelData = modelConfigService.selectById(llmModelId);
|
||||||
|
String type = llmModelData.getConfigJson().get("type").toString();
|
||||||
|
// 如果查询大语言模型是openai或者ollama,意图识别选参数都可以
|
||||||
|
if ("openai".equals(type) || "ollama".equals(type)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 除了openai和ollama的类型,不可以选择id为Intent_function_call(函数调用)的意图识别
|
||||||
|
return !"Intent_function_call".equals(intentModelId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String createAgent(AgentCreateDTO dto) {
|
public String createAgent(AgentCreateDTO dto) {
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ package xiaozhi.modules.agent.service.impl;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.core.io.ByteArrayResource;
|
import org.springframework.core.io.ByteArrayResource;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
@@ -22,7 +24,6 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import xiaozhi.common.constant.Constant;
|
import xiaozhi.common.constant.Constant;
|
||||||
import xiaozhi.common.exception.RenException;
|
import xiaozhi.common.exception.RenException;
|
||||||
@@ -43,7 +44,6 @@ import xiaozhi.modules.sys.service.SysParamsService;
|
|||||||
* @author zjy
|
* @author zjy
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AgentVoicePrintServiceImpl extends ServiceImpl<AgentVoicePrintDao, AgentVoicePrintEntity>
|
public class AgentVoicePrintServiceImpl extends ServiceImpl<AgentVoicePrintDao, AgentVoicePrintEntity>
|
||||||
implements AgentVoicePrintService {
|
implements AgentVoicePrintService {
|
||||||
@@ -55,6 +55,18 @@ public class AgentVoicePrintServiceImpl extends ServiceImpl<AgentVoicePrintDao,
|
|||||||
private final TransactionTemplate transactionTemplate;
|
private final TransactionTemplate transactionTemplate;
|
||||||
// 识别度
|
// 识别度
|
||||||
private final Double RECOGNITION = 0.5;
|
private final Double RECOGNITION = 0.5;
|
||||||
|
private final Executor taskExecutor;
|
||||||
|
|
||||||
|
public AgentVoicePrintServiceImpl(AgentChatAudioService agentChatAudioService, RestTemplate restTemplate,
|
||||||
|
SysParamsService sysParamsService, AgentChatHistoryService agentChatHistoryService,
|
||||||
|
TransactionTemplate transactionTemplate, @Qualifier("taskExecutor") Executor taskExecutor) {
|
||||||
|
this.agentChatAudioService = agentChatAudioService;
|
||||||
|
this.restTemplate = restTemplate;
|
||||||
|
this.sysParamsService = sysParamsService;
|
||||||
|
this.agentChatHistoryService = agentChatHistoryService;
|
||||||
|
this.transactionTemplate = transactionTemplate;
|
||||||
|
this.taskExecutor = taskExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean insert(AgentVoicePrintSaveDTO dto) {
|
public boolean insert(AgentVoicePrintSaveDTO dto) {
|
||||||
@@ -96,7 +108,7 @@ public class AgentVoicePrintServiceImpl extends ServiceImpl<AgentVoicePrintDao,
|
|||||||
@Override
|
@Override
|
||||||
public boolean delete(Long userId, String voicePrintId) {
|
public boolean delete(Long userId, String voicePrintId) {
|
||||||
// 开启事务
|
// 开启事务
|
||||||
return Boolean.TRUE.equals(transactionTemplate.execute(status -> {
|
boolean b = Boolean.TRUE.equals(transactionTemplate.execute(status -> {
|
||||||
try {
|
try {
|
||||||
// 删除声纹,按照指定当前登录用户和智能体
|
// 删除声纹,按照指定当前登录用户和智能体
|
||||||
int row = baseMapper.delete(new LambdaQueryWrapper<AgentVoicePrintEntity>()
|
int row = baseMapper.delete(new LambdaQueryWrapper<AgentVoicePrintEntity>()
|
||||||
@@ -106,17 +118,25 @@ public class AgentVoicePrintServiceImpl extends ServiceImpl<AgentVoicePrintDao,
|
|||||||
status.setRollbackOnly(); // 标记事务回滚
|
status.setRollbackOnly(); // 标记事务回滚
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cancelVoicePrint(voicePrintId);
|
|
||||||
return true;
|
return true;
|
||||||
} catch (RenException e) {
|
|
||||||
status.setRollbackOnly(); // 标记事务回滚
|
|
||||||
throw e;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
status.setRollbackOnly(); // 标记事务回滚
|
status.setRollbackOnly(); // 标记事务回滚
|
||||||
log.error("删除声纹错误原因:{}", e.getMessage());
|
log.error("删除声纹存在错误原因:{}", e.getMessage());
|
||||||
throw new RenException("删除声纹错误,请联系管理员");
|
throw new RenException("删除声纹出现了错误");
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
// 数据库声纹数据删除成功才继续执行删除声纹服务的数据
|
||||||
|
if(b){
|
||||||
|
taskExecutor.execute(()-> {
|
||||||
|
try {
|
||||||
|
cancelVoicePrint(voicePrintId);
|
||||||
|
}catch (RuntimeException e) {
|
||||||
|
log.error("删除声纹存在运行时错误原因:{},id:{}", e.getMessage(),voicePrintId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -219,7 +239,11 @@ public class AgentVoicePrintServiceImpl extends ServiceImpl<AgentVoicePrintDao,
|
|||||||
String protocol = uri.getScheme();
|
String protocol = uri.getScheme();
|
||||||
String host = uri.getHost();
|
String host = uri.getHost();
|
||||||
int port = uri.getPort();
|
int port = uri.getPort();
|
||||||
return "%s://%s:%s".formatted(protocol, host, port);
|
if (port == -1) {
|
||||||
|
return "%s://%s".formatted(protocol, host);
|
||||||
|
} else {
|
||||||
|
return "%s://%s:%s".formatted(protocol, host, port);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,11 +21,7 @@ import xiaozhi.common.utils.ConvertUtils;
|
|||||||
import xiaozhi.common.utils.Result;
|
import xiaozhi.common.utils.Result;
|
||||||
import xiaozhi.modules.agent.service.AgentTemplateService;
|
import xiaozhi.modules.agent.service.AgentTemplateService;
|
||||||
import xiaozhi.modules.config.service.ConfigService;
|
import xiaozhi.modules.config.service.ConfigService;
|
||||||
import xiaozhi.modules.model.dto.ModelBasicInfoDTO;
|
import xiaozhi.modules.model.dto.*;
|
||||||
import xiaozhi.modules.model.dto.ModelConfigBodyDTO;
|
|
||||||
import xiaozhi.modules.model.dto.ModelConfigDTO;
|
|
||||||
import xiaozhi.modules.model.dto.ModelProviderDTO;
|
|
||||||
import xiaozhi.modules.model.dto.VoiceDTO;
|
|
||||||
import xiaozhi.modules.model.entity.ModelConfigEntity;
|
import xiaozhi.modules.model.entity.ModelConfigEntity;
|
||||||
import xiaozhi.modules.model.service.ModelConfigService;
|
import xiaozhi.modules.model.service.ModelConfigService;
|
||||||
import xiaozhi.modules.model.service.ModelProviderService;
|
import xiaozhi.modules.model.service.ModelProviderService;
|
||||||
@@ -52,6 +48,14 @@ public class ModelController {
|
|||||||
return new Result<List<ModelBasicInfoDTO>>().ok(modelList);
|
return new Result<List<ModelBasicInfoDTO>>().ok(modelList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/llm/names")
|
||||||
|
@Operation(summary = "获取LLM模型信息")
|
||||||
|
@RequiresPermissions("sys:role:normal")
|
||||||
|
public Result<List<LlmModelBasicInfoDTO>> getLlmModelCodeList(@RequestParam(required = false) String modelName) {
|
||||||
|
List<LlmModelBasicInfoDTO> llmModelCodeList = modelConfigService.getLlmModelCodeList(modelName);
|
||||||
|
return new Result<List<LlmModelBasicInfoDTO>>().ok(llmModelCodeList);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/{modelType}/provideTypes")
|
@GetMapping("/{modelType}/provideTypes")
|
||||||
@Operation(summary = "获取模型供应器列表")
|
@Operation(summary = "获取模型供应器列表")
|
||||||
@RequiresPermissions("sys:role:superAdmin")
|
@RequiresPermissions("sys:role:superAdmin")
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package xiaozhi.modules.model.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LLM的模型的基础展示数据
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class LlmModelBasicInfoDTO extends ModelBasicInfoDTO{
|
||||||
|
private String type;
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import xiaozhi.common.page.PageData;
|
import xiaozhi.common.page.PageData;
|
||||||
import xiaozhi.common.service.BaseService;
|
import xiaozhi.common.service.BaseService;
|
||||||
|
import xiaozhi.modules.model.dto.LlmModelBasicInfoDTO;
|
||||||
import xiaozhi.modules.model.dto.ModelBasicInfoDTO;
|
import xiaozhi.modules.model.dto.ModelBasicInfoDTO;
|
||||||
import xiaozhi.modules.model.dto.ModelConfigBodyDTO;
|
import xiaozhi.modules.model.dto.ModelConfigBodyDTO;
|
||||||
import xiaozhi.modules.model.dto.ModelConfigDTO;
|
import xiaozhi.modules.model.dto.ModelConfigDTO;
|
||||||
@@ -13,6 +14,8 @@ public interface ModelConfigService extends BaseService<ModelConfigEntity> {
|
|||||||
|
|
||||||
List<ModelBasicInfoDTO> getModelCodeList(String modelType, String modelName);
|
List<ModelBasicInfoDTO> getModelCodeList(String modelType, String modelName);
|
||||||
|
|
||||||
|
List<LlmModelBasicInfoDTO> getLlmModelCodeList(String modelName);
|
||||||
|
|
||||||
PageData<ModelConfigDTO> getPageList(String modelType, String modelName, String page, String limit);
|
PageData<ModelConfigDTO> getPageList(String modelType, String modelName, String page, String limit);
|
||||||
|
|
||||||
ModelConfigDTO add(String modelType, String provideCode, ModelConfigBodyDTO modelConfigBodyDTO);
|
ModelConfigDTO add(String modelType, String provideCode, ModelConfigBodyDTO modelConfigBodyDTO);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.util.stream.Collectors;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ import xiaozhi.common.utils.ConvertUtils;
|
|||||||
import xiaozhi.modules.agent.dao.AgentDao;
|
import xiaozhi.modules.agent.dao.AgentDao;
|
||||||
import xiaozhi.modules.agent.entity.AgentEntity;
|
import xiaozhi.modules.agent.entity.AgentEntity;
|
||||||
import xiaozhi.modules.model.dao.ModelConfigDao;
|
import xiaozhi.modules.model.dao.ModelConfigDao;
|
||||||
|
import xiaozhi.modules.model.dto.LlmModelBasicInfoDTO;
|
||||||
import xiaozhi.modules.model.dto.ModelBasicInfoDTO;
|
import xiaozhi.modules.model.dto.ModelBasicInfoDTO;
|
||||||
import xiaozhi.modules.model.dto.ModelConfigBodyDTO;
|
import xiaozhi.modules.model.dto.ModelConfigBodyDTO;
|
||||||
import xiaozhi.modules.model.dto.ModelConfigDTO;
|
import xiaozhi.modules.model.dto.ModelConfigDTO;
|
||||||
@@ -52,6 +54,25 @@ public class ModelConfigServiceImpl extends BaseServiceImpl<ModelConfigDao, Mode
|
|||||||
return ConvertUtils.sourceToTarget(entities, ModelBasicInfoDTO.class);
|
return ConvertUtils.sourceToTarget(entities, ModelBasicInfoDTO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LlmModelBasicInfoDTO> getLlmModelCodeList(String modelName) {
|
||||||
|
List<ModelConfigEntity> entities = modelConfigDao.selectList(
|
||||||
|
new QueryWrapper<ModelConfigEntity>()
|
||||||
|
.eq("model_type", "llm")
|
||||||
|
.eq("is_enabled", 1)
|
||||||
|
.like(StringUtils.isNotBlank(modelName), "model_name", "%" + modelName + "%")
|
||||||
|
.select("id", "model_name", "config_json"));
|
||||||
|
// 处理获取到的内容
|
||||||
|
return entities.stream().map(item -> {
|
||||||
|
LlmModelBasicInfoDTO dto = new LlmModelBasicInfoDTO();
|
||||||
|
dto.setId(item.getId());
|
||||||
|
dto.setModelName(item.getModelName());
|
||||||
|
String type = item.getConfigJson().get("type").toString();
|
||||||
|
dto.setType(type);
|
||||||
|
return dto;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageData<ModelConfigDTO> getPageList(String modelType, String modelName, String page, String limit) {
|
public PageData<ModelConfigDTO> getPageList(String modelType, String modelName, String page, String limit) {
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
@@ -94,6 +115,21 @@ public class ModelConfigServiceImpl extends BaseServiceImpl<ModelConfigDao, Mode
|
|||||||
if (CollectionUtil.isEmpty(providerList)) {
|
if (CollectionUtil.isEmpty(providerList)) {
|
||||||
throw new RenException("供应器不存在");
|
throw new RenException("供应器不存在");
|
||||||
}
|
}
|
||||||
|
if (modelConfigBodyDTO.getConfigJson().containsKey("llm")) {
|
||||||
|
String llm = modelConfigBodyDTO.getConfigJson().get("llm").toString();
|
||||||
|
ModelConfigEntity modelConfigEntity = modelConfigDao.selectOne(new LambdaQueryWrapper<ModelConfigEntity>()
|
||||||
|
.eq(ModelConfigEntity::getId, llm));
|
||||||
|
String selectModelType = (modelConfigEntity == null || modelConfigEntity.getModelType() == null) ? null
|
||||||
|
: modelConfigEntity.getModelType().toUpperCase();
|
||||||
|
if (modelConfigEntity == null || !"LLM".equals(selectModelType)) {
|
||||||
|
throw new RenException("设置的LLM不存在");
|
||||||
|
}
|
||||||
|
String type = modelConfigEntity.getConfigJson().get("type").toString();
|
||||||
|
// 如果查询大语言模型是openai或者ollama,意图识别选参数都可以
|
||||||
|
if (!"openai".equals(type) && !"ollama".equals(type)) {
|
||||||
|
throw new RenException("设置的LLM不是openai和ollama");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 再更新供应器提供的模型
|
// 再更新供应器提供的模型
|
||||||
ModelConfigEntity modelConfigEntity = ConvertUtils.sourceToTarget(modelConfigBodyDTO, ModelConfigEntity.class);
|
ModelConfigEntity modelConfigEntity = ConvertUtils.sourceToTarget(modelConfigBodyDTO, ModelConfigEntity.class);
|
||||||
@@ -137,6 +173,8 @@ public class ModelConfigServiceImpl extends BaseServiceImpl<ModelConfigDao, Mode
|
|||||||
.or()
|
.or()
|
||||||
.eq("mem_model_id", modelId)
|
.eq("mem_model_id", modelId)
|
||||||
.or()
|
.or()
|
||||||
|
.eq("vllm_model_id", modelId)
|
||||||
|
.or()
|
||||||
.eq("intent_model_id", modelId));
|
.eq("intent_model_id", modelId));
|
||||||
if (!agents.isEmpty()) {
|
if (!agents.isEmpty()) {
|
||||||
String agentNames = agents.stream()
|
String agentNames = agents.stream()
|
||||||
|
|||||||
@@ -86,10 +86,14 @@ public class WebSocketClientManager implements Closeable {
|
|||||||
if (sess == null || !sess.isOpen()) {
|
if (sess == null || !sess.isOpen()) {
|
||||||
throw new IOException("握手失败或会话未打开");
|
throw new IOException("握手失败或会话未打开");
|
||||||
}
|
}
|
||||||
|
// 设置缓冲区
|
||||||
|
sess.setTextMessageSizeLimit(b.bufferSize);
|
||||||
|
sess.setBinaryMessageSizeLimit(b.bufferSize);
|
||||||
ws.session = sess;
|
ws.session = sess;
|
||||||
return ws;
|
return ws;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送 Text
|
* 发送 Text
|
||||||
*/
|
*/
|
||||||
@@ -308,10 +312,11 @@ public class WebSocketClientManager implements Closeable {
|
|||||||
if (stopWatch.isRunning()) {
|
if (stopWatch.isRunning()) {
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
}
|
}
|
||||||
log.info("ws连接关闭, 目标URI: {}, 关闭时间: {}, 连接总时长: {}s",
|
log.info("ws连接关闭, 目标URI: {}, 关闭时间: {}, 连接总时长: {}s,断开原因:{}",
|
||||||
targetUri, DateUtils.getDateTimeNow(DateUtils.DATE_TIME_MILLIS_PATTERN),
|
targetUri, DateUtils.getDateTimeNow(DateUtils.DATE_TIME_MILLIS_PATTERN),
|
||||||
DateUtils.millsToSecond(stopWatch.getTotalTimeMillis()));
|
DateUtils.millsToSecond(stopWatch.getTotalTimeMillis()),status);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
@@ -321,6 +326,7 @@ public class WebSocketClientManager implements Closeable {
|
|||||||
private long maxSessionDuration = 5; // 最大连线时间,默认5秒
|
private long maxSessionDuration = 5; // 最大连线时间,默认5秒
|
||||||
private TimeUnit maxSessionDurationUnit = TimeUnit.SECONDS; // 最大连线时间单位
|
private TimeUnit maxSessionDurationUnit = TimeUnit.SECONDS; // 最大连线时间单位
|
||||||
private int queueCapacity = 100; // 消息队列容量
|
private int queueCapacity = 100; // 消息队列容量
|
||||||
|
private int bufferSize = 8 * 1024; //默认 8kb
|
||||||
private WebSocketHttpHeaders headers; // 请求头
|
private WebSocketHttpHeaders headers; // 请求头
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -352,6 +358,10 @@ public class WebSocketClientManager implements Closeable {
|
|||||||
this.queueCapacity = c;
|
this.queueCapacity = c;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public Builder bufferSize(int c) {
|
||||||
|
this.bufferSize = c;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public WebSocketClientManager build()
|
public WebSocketClientManager build()
|
||||||
throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
-- 添加阿里云流式ASR供应器
|
||||||
|
delete from `ai_model_provider` where id = 'SYSTEM_ASR_AliyunStreamASR';
|
||||||
|
INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES
|
||||||
|
('SYSTEM_ASR_AliyunStreamASR', 'ASR', 'aliyun_stream', '阿里云语音识别(流式)', '[{"key":"appkey","label":"应用AppKey","type":"string"},{"key":"token","label":"临时Token","type":"string"},{"key":"access_key_id","label":"AccessKey ID","type":"string"},{"key":"access_key_secret","label":"AccessKey Secret","type":"string"},{"key":"host","label":"服务地址","type":"string"},{"key":"max_sentence_silence","label":"断句检测时间","type":"number"},{"key":"output_dir","label":"输出目录","type":"string"}]', 6, 1, NOW(), 1, NOW());
|
||||||
|
|
||||||
|
-- 添加阿里云流式ASR模型配置
|
||||||
|
delete from `ai_model_config` where id = 'ASR_AliyunStreamASR';
|
||||||
|
INSERT INTO `ai_model_config` VALUES ('ASR_AliyunStreamASR', 'ASR', 'AliyunStreamASR', '阿里云语音识别(流式)', 0, 1, '{\"type\": \"aliyun_stream\", \"appkey\": \"\", \"token\": \"\", \"access_key_id\": \"\", \"access_key_secret\": \"\", \"host\": \"nls-gateway-cn-shanghai.aliyuncs.com\", \"max_sentence_silence\": 800, \"output_dir\": \"tmp/\"}', NULL, NULL, 8, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
-- 更新阿里云流式ASR配置说明
|
||||||
|
UPDATE `ai_model_config` SET
|
||||||
|
`doc_link` = 'https://nls-portal.console.aliyun.com/',
|
||||||
|
`remark` = '阿里云流式ASR配置说明:
|
||||||
|
1. 阿里云ASR和阿里云(流式)ASR的区别是:阿里云ASR是一次性识别,阿里云(流式)ASR是实时流式识别
|
||||||
|
2. 流式ASR具有更低的延迟和更好的实时性,适合语音交互场景
|
||||||
|
3. 需要在阿里云智能语音交互控制台创建应用并获取认证信息
|
||||||
|
4. 支持中文实时语音识别,支持标点符号预测和逆文本规范化
|
||||||
|
5. 需要网络连接,输出文件保存在tmp/目录
|
||||||
|
申请步骤:
|
||||||
|
1. 访问 https://nls-portal.console.aliyun.com/ 开通智能语音交互服务
|
||||||
|
2. 访问 https://nls-portal.console.aliyun.com/applist 创建项目并获取appkey
|
||||||
|
3. 访问 https://nls-portal.console.aliyun.com/overview 获取临时token(或配置access_key_id和access_key_secret自动获取)
|
||||||
|
4. 如需动态token管理,建议配置access_key_id和access_key_secret
|
||||||
|
5. max_sentence_silence参数控制断句检测时间(毫秒),默认800ms
|
||||||
|
如需了解更多参数配置,请参考:https://help.aliyun.com/zh/isi/developer-reference/real-time-speech-recognition
|
||||||
|
' WHERE `id` = 'ASR_AliyunStreamASR';
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
-- 添加阿里云流式TTS供应器
|
||||||
|
delete from `ai_model_provider` where id = 'SYSTEM_TTS_AliyunStreamTTS';
|
||||||
|
INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES
|
||||||
|
('SYSTEM_TTS_AliyunStreamTTS', 'TTS', 'aliyun_stream', '阿里云语音合成(流式)', '[{"key":"appkey","label":"应用AppKey","type":"string"},{"key":"token","label":"临时Token","type":"string"},{"key":"access_key_id","label":"AccessKey ID","type":"string"},{"key":"access_key_secret","label":"AccessKey Secret","type":"string"},{"key":"host","label":"服务地址","type":"string"},{"key":"voice","label":"默认音色","type":"string"},{"key":"format","label":"音频格式","type":"string"},{"key":"sample_rate","label":"采样率","type":"number"},{"key":"volume","label":"音量","type":"number"},{"key":"speech_rate","label":"语速","type":"number"},{"key":"pitch_rate","label":"音调","type":"number"},{"key":"output_dir","label":"输出目录","type":"string"}]', 15, 1, NOW(), 1, NOW());
|
||||||
|
|
||||||
|
-- 添加阿里云流式TTS模型配置
|
||||||
|
delete from `ai_model_config` where id = 'TTS_AliyunStreamTTS';
|
||||||
|
INSERT INTO `ai_model_config` VALUES ('TTS_AliyunStreamTTS', 'TTS', 'AliyunStreamTTS', '阿里云语音合成(流式)', 0, 1, '{\"type\": \"aliyun_stream\", \"appkey\": \"\", \"token\": \"\", \"access_key_id\": \"\", \"access_key_secret\": \"\", \"host\": \"nls-gateway-cn-beijing.aliyuncs.com\", \"voice\": \"longxiaochun\", \"format\": \"pcm\", \"sample_rate\": 16000, \"volume\": 50, \"speech_rate\": 0, \"pitch_rate\": 0, \"output_dir\": \"tmp/\"}', NULL, NULL, 18, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
-- 更新阿里云流式TTS配置说明
|
||||||
|
UPDATE `ai_model_config` SET
|
||||||
|
`doc_link` = 'https://nls-portal.console.aliyun.com/',
|
||||||
|
`remark` = '阿里云流式TTS配置说明:
|
||||||
|
1. 阿里云TTS和阿里云(流式)TTS的区别是:阿里云TTS是一次性合成,阿里云(流式)TTS是实时流式合成
|
||||||
|
2. 流式TTS具有更低的延迟和更好的实时性,适合语音交互场景
|
||||||
|
3. 需要在阿里云智能语音交互控制台创建应用并获取认证信息
|
||||||
|
4. 支持CosyVoice大模型音色,音质更加自然
|
||||||
|
5. 支持实时调节音量、语速、音调等参数
|
||||||
|
申请步骤:
|
||||||
|
1. 访问 https://nls-portal.console.aliyun.com/ 开通智能语音交互服务
|
||||||
|
2. 访问 https://nls-portal.console.aliyun.com/applist 创建项目并获取appkey
|
||||||
|
3. 访问 https://nls-portal.console.aliyun.com/overview 获取临时token(或配置access_key_id和access_key_secret自动获取)
|
||||||
|
4. 如需动态token管理,建议配置access_key_id和access_key_secret
|
||||||
|
5. 可选择北京、上海等不同地域的服务器以优化延迟
|
||||||
|
6. voice参数支持CosyVoice大模型音色,如longxiaochun、longyueyue等
|
||||||
|
如需了解更多参数配置,请参考:https://help.aliyun.com/zh/isi/developer-reference/real-time-speech-synthesis
|
||||||
|
' WHERE `id` = 'TTS_AliyunStreamTTS';
|
||||||
|
|
||||||
|
-- 添加阿里云流式TTS音色
|
||||||
|
delete from `ai_tts_voice` where tts_model_id = 'TTS_AliyunStreamTTS';
|
||||||
|
-- 温柔女声系列
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0001', 'TTS_AliyunStreamTTS', '龙小淳-温柔姐姐', 'longxiaochun', '中文及中英文混合', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0002', 'TTS_AliyunStreamTTS', '龙小夏-温柔女声', 'longxiaoxia', '中文及中英文混合', NULL, NULL, NULL, NULL, 2, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0003', 'TTS_AliyunStreamTTS', '龙玫-温柔女声', 'longmei', '中文及中英文混合', NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0004', 'TTS_AliyunStreamTTS', '龙瑰-温柔女声', 'longgui', '中文及中英文混合', NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL);
|
||||||
|
-- 御姐女声系列
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0005', 'TTS_AliyunStreamTTS', '龙玉-御姐女声', 'longyu', '中文及中英文混合', NULL, NULL, NULL, NULL, 5, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0006', 'TTS_AliyunStreamTTS', '龙娇-御姐女声', 'longjiao', '中文及中英文混合', NULL, NULL, NULL, NULL, 6, NULL, NULL, NULL, NULL);
|
||||||
|
-- 男声系列
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0007', 'TTS_AliyunStreamTTS', '龙臣-译制片男声', 'longchen', '中文及中英文混合', NULL, NULL, NULL, NULL, 7, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0008', 'TTS_AliyunStreamTTS', '龙修-青年男声', 'longxiu', '中文及中英文混合', NULL, NULL, NULL, NULL, 8, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0009', 'TTS_AliyunStreamTTS', '龙橙-阳光男声', 'longcheng', '中文及中英文混合', NULL, NULL, NULL, NULL, 9, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0010', 'TTS_AliyunStreamTTS', '龙哲-成熟男声', 'longzhe', '中文及中英文混合', NULL, NULL, NULL, NULL, 10, NULL, NULL, NULL, NULL);
|
||||||
|
-- 专业播报系列
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0011', 'TTS_AliyunStreamTTS', 'Bella2.0-新闻女声', 'loongbella', '中文及中英文混合', NULL, NULL, NULL, NULL, 11, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0012', 'TTS_AliyunStreamTTS', 'Stella2.0-飒爽女声', 'loongstella', '中文及中英文混合', NULL, NULL, NULL, NULL, 12, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0013', 'TTS_AliyunStreamTTS', '龙书-新闻男声', 'longshu', '中文及中英文混合', NULL, NULL, NULL, NULL, 13, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0014', 'TTS_AliyunStreamTTS', '龙婧-严肃女声', 'longjing', '中文及中英文混合', NULL, NULL, NULL, NULL, 14, NULL, NULL, NULL, NULL);
|
||||||
|
-- 特色音色系列
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0015', 'TTS_AliyunStreamTTS', '龙奇-活泼童声', 'longqi', '中文及中英文混合', NULL, NULL, NULL, NULL, 15, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0016', 'TTS_AliyunStreamTTS', '龙华-活泼女童', 'longhua', '中文及中英文混合', NULL, NULL, NULL, NULL, 16, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0017', 'TTS_AliyunStreamTTS', '龙无-无厘头男声', 'longwu', '中文及中英文混合', NULL, NULL, NULL, NULL, 17, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0018', 'TTS_AliyunStreamTTS', '龙大锤-幽默男声', 'longdachui', '中文及中英文混合', NULL, NULL, NULL, NULL, 18, NULL, NULL, NULL, NULL);
|
||||||
|
-- 粤语系列
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0019', 'TTS_AliyunStreamTTS', '龙嘉怡-粤语女声', 'longjiayi', '粤语及粤英混合', NULL, NULL, NULL, NULL, 19, NULL, NULL, NULL, NULL);
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_AliyunStreamTTS_0020', 'TTS_AliyunStreamTTS', '龙桃-粤语女声', 'longtao', '粤语及粤英混合', NULL, NULL, NULL, NULL, 20, NULL, NULL, NULL, NULL);
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
-- OpenAI ASR模型供应器
|
||||||
|
delete from `ai_model_provider` where id = 'SYSTEM_ASR_OpenaiASR';
|
||||||
|
INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES
|
||||||
|
('SYSTEM_ASR_OpenaiASR', 'ASR', 'openai', 'OpenAI语音识别', '[{"key": "base_url", "type": "string", "label": "基础URL"}, {"key": "model_name", "type": "string", "label": "模型名称"}, {"key": "api_key", "type": "string", "label": "API密钥"}, {"key": "output_dir", "type": "string", "label": "输出目录"}]', 9, 1, NOW(), 1, NOW());
|
||||||
|
|
||||||
|
|
||||||
|
-- OpenAI ASR模型配置
|
||||||
|
delete from `ai_model_config` where id = 'ASR_OpenaiASR';
|
||||||
|
INSERT INTO `ai_model_config` VALUES ('ASR_OpenaiASR', 'ASR', 'OpenaiASR', 'OpenAI语音识别', 0, 1, '{\"type\": \"openai\", \"api_key\": \"\", \"base_url\": \"https://api.openai.com/v1/audio/transcriptions\", \"model_name\": \"gpt-4o-mini-transcribe\", \"output_dir\": \"tmp/\"}', NULL, NULL, 9, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
-- groq ASR模型配置
|
||||||
|
delete from `ai_model_config` where id = 'ASR_GroqASR';
|
||||||
|
INSERT INTO `ai_model_config` VALUES ('ASR_GroqASR', 'ASR', 'GroqASR', 'Groq语音识别', 0, 1, '{\"type\": \"openai\", \"api_key\": \"\", \"base_url\": \"https://api.groq.com/openai/v1/audio/transcriptions\", \"model_name\": \"whisper-large-v3-turbo\", \"output_dir\": \"tmp/\"}', NULL, NULL, 10, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
-- 更新OpenAI ASR配置说明
|
||||||
|
UPDATE `ai_model_config` SET
|
||||||
|
`doc_link` = 'https://platform.openai.com/docs/api-reference/audio/createTranscription',
|
||||||
|
`remark` = 'OpenAI ASR配置说明:
|
||||||
|
1. 需要在OpenAI开放平台创建组织并获取api_key
|
||||||
|
2. 支持中、英、日、韩等多种语音识别,具体参考文档https://platform.openai.com/docs/guides/speech-to-text
|
||||||
|
3. 需要网络连接
|
||||||
|
4. 输出文件保存在tmp/目录
|
||||||
|
申请步骤:
|
||||||
|
**OpenAi ASR申请步骤:**
|
||||||
|
1.登录OpenAI Platform。https://auth.openai.com/log-in
|
||||||
|
2.创建api-key https://platform.openai.com/settings/organization/api-keys
|
||||||
|
3.模型可以选择gpt-4o-transcribe或GPT-4o mini Transcribe
|
||||||
|
' WHERE `id` = 'ASR_OpenaiASR';
|
||||||
|
|
||||||
|
-- 更新Groq ASR配置说明
|
||||||
|
UPDATE `ai_model_config` SET
|
||||||
|
`doc_link` = 'https://console.groq.com/docs/speech-to-text',
|
||||||
|
`remark` = 'Groq ASR配置说明:
|
||||||
|
1.登录groq Console。https://console.groq.com/home
|
||||||
|
2.创建api-key https://console.groq.com/keys
|
||||||
|
3.模型可以选择whisper-large-v3-turbo或whisper-large-v3(distil-whisper-large-v3-en仅支持英语转录)
|
||||||
|
' WHERE `id` = 'ASR_GroqASR';
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
-- 添加Index-TTS-vLLM流式TTS供应器
|
||||||
|
delete from `ai_model_provider` where id = 'SYSTEM_TTS_IndexStreamTTS';
|
||||||
|
INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES
|
||||||
|
('SYSTEM_TTS_IndexStreamTTS', 'TTS', 'index_stream', 'Index-TTS-vLLM流式语音合成', '[{"key":"api_url","label":"API服务地址","type":"string"},{"key":"voice","label":"默认音色","type":"string"},{"key":"audio_format","label":"音频格式","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 16, 1, NOW(), 1, NOW());
|
||||||
|
|
||||||
|
-- 添加Index-TTS-vLLM流式TTS模型配置
|
||||||
|
delete from `ai_model_config` where id = 'TTS_IndexStreamTTS';
|
||||||
|
INSERT INTO `ai_model_config` VALUES ('TTS_IndexStreamTTS', 'TTS', 'IndexStreamTTS', 'Index-TTS-vLLM流式语音合成', 0, 1, '{\"type\": \"index_stream\", \"api_url\": \"http://127.0.0.1:11996/tts\", \"voice\": \"jay_klee\", \"audio_format\": \"pcm\", \"output_dir\": \"tmp/\"}', NULL, NULL, 19, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
-- 更新Index-TTS-vLLM流式TTS配置说明
|
||||||
|
UPDATE `ai_model_config` SET
|
||||||
|
`doc_link` = 'https://github.com/Ksuriuri/index-tts-vllm',
|
||||||
|
`remark` = 'Index-TTS-vLLM流式TTS配置说明:
|
||||||
|
1. Index-TTS-vLLM是基于Index-TTS项目的vLLM推理服务,提供流式语音合成功能
|
||||||
|
2. 支持多种音色,音质自然,适合各种语音交互场景
|
||||||
|
3. 需要先部署Index-TTS-vLLM服务,然后配置API地址
|
||||||
|
4. 支持实时流式合成,具有较低的延迟
|
||||||
|
5. 支持自定义音色,可在项目assets文件夹下注册新音色
|
||||||
|
部署步骤:
|
||||||
|
1. 克隆项目:git clone https://github.com/Ksuriuri/index-tts-vllm.git
|
||||||
|
2. 安装依赖:pip install -r requirements.txt
|
||||||
|
3. 启动服务:python app.py
|
||||||
|
4. 服务默认运行在 http://127.0.0.1:11996
|
||||||
|
5. 如需其他音色,可到项目assets文件夹下注册
|
||||||
|
6. 支持多种音频格式:pcm、wav、mp3等
|
||||||
|
如需了解更多配置,请参考:https://github.com/Ksuriuri/index-tts-vllm/blob/master/README.md
|
||||||
|
' WHERE `id` = 'TTS_IndexStreamTTS';
|
||||||
|
|
||||||
|
-- 添加Index-TTS-vLLM流式TTS音色
|
||||||
|
delete from `ai_tts_voice` where tts_model_id = 'TTS_IndexStreamTTS';
|
||||||
|
-- 默认音色
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_IndexStreamTTS_0001', 'TTS_IndexStreamTTS', 'Jay Klee', 'jay_klee', '中文及中英文混合', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL);
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
-- 更新HuoshanDoubleStreamTTS供应器增加语速,音调等配置
|
||||||
|
UPDATE `ai_model_provider`
|
||||||
|
SET fields = '[{"key": "ws_url", "type": "string", "label": "WebSocket地址"}, {"key": "appid", "type": "string", "label": "应用ID"}, {"key": "access_token", "type": "string", "label": "访问令牌"}, {"key": "resource_id", "type": "string", "label": "资源ID"}, {"key": "speaker", "type": "string", "label": "默认音色"}, {"key": "speech_rate", "type": "number", "label": "语速(-50~100)"}, {"key": "loudness_rate", "type": "number", "label": "音量(-50~100)"}, {"key": "pitch", "type": "number", "label": "音高(-12~12)"}]'
|
||||||
|
WHERE id = 'SYSTEM_TTS_HSDSTTS';
|
||||||
|
|
||||||
|
UPDATE `ai_model_config` SET
|
||||||
|
`doc_link` = 'https://console.volcengine.com/speech/service/10007',
|
||||||
|
`remark` = '火山引擎语音合成服务配置说明:
|
||||||
|
1. 访问 https://www.volcengine.com/ 注册并开通火山引擎账号
|
||||||
|
2. 访问 https://console.volcengine.com/speech/service/10007 开通语音合成大模型,购买音色
|
||||||
|
3. 在页面底部获取appid和access_token
|
||||||
|
5. 资源ID固定为:volc.service_type.10029(大模型语音合成及混音)
|
||||||
|
6. 语速:-50~100,可不填,正常默认值0,可填-50~100
|
||||||
|
7. 音量:-50~100,可不填,正常默认值0,可填-50~100
|
||||||
|
8. 音高:-12~12,可不填,正常默认值0,可填-12~12
|
||||||
|
9. 填入配置文件中' WHERE `id` = 'TTS_HuoshanDoubleStreamTTS';
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
-- 添加 paddle_speech 流式 TTS 供应器
|
||||||
|
DELETE FROM `ai_model_provider` WHERE id = 'SYSTEM_TTS_PaddleSpeechTTS';
|
||||||
|
INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`)
|
||||||
|
VALUES ('SYSTEM_TTS_PaddleSpeechTTS', 'TTS', 'paddle_speech', 'PaddleSpeechTTS',
|
||||||
|
'[{"key":"protocol","label":"协议类型","type":"string","options":["websocket","http"]},{"key":"url","label":"服务地址","type":"string"},{"key":"spk_id","label":"音色","type":"int"},{"key":"sample_rate","label":"采样率","type":"float"},{"key":"speed","label":"语速","type":"float"},{"key":"volume","label":"音量","type":"float"},{"key":"save_path","label":"保存路径","type":"string"}]',
|
||||||
|
17, 1, NOW(), 1, NOW());
|
||||||
|
|
||||||
|
-- 添加 paddle_speech 流式 TTS 模型配置
|
||||||
|
DELETE FROM `ai_model_config` WHERE id = 'TTS_PaddleSpeechTTS';
|
||||||
|
INSERT INTO `ai_model_config` VALUES ('TTS_PaddleSpeechTTS', 'TTS', 'PaddleSpeechTTS', 'PaddleSpeechTTS', 0, 1,
|
||||||
|
'{"type": "paddle_speech", "protocol": "websocket", "url": "ws://127.0.0.1:8092/paddlespeech/tts/streaming", "spk_id": "0", "sample_rate": 24000, "speed": 1.0, "volume": 1.0, "save_path": "./streaming_tts.wav"}',
|
||||||
|
NULL, NULL, 20, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
-- 更新 PaddleSpeechTTS 配置说明
|
||||||
|
UPDATE `ai_model_config` SET
|
||||||
|
`doc_link` = 'https://github.com/PaddlePaddle/PaddleSpeech',
|
||||||
|
`remark` = 'PaddleSpeechTTS 配置说明:
|
||||||
|
1. PaddleSpeech 是百度飞桨开源的语音合成工具,支持本地离线部署和模型训练。paddlepaddle百度飞浆框架地址:https://www.paddlepaddle.org.cn/
|
||||||
|
2. 支持 WebSocket 和 HTTP 协议,默认使用 WebSocket 进行流式传输(参考部署文档:https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/paddlespeech-deploy.md)。
|
||||||
|
3. 使用前要在本地部署 paddlespeech 服务,服务默认运行在 ws://127.0.0.1:8092/paddlespeech/tts/streaming
|
||||||
|
4. 支持自定义发音人、语速、音量和采样率。
|
||||||
|
' WHERE `id` = 'TTS_PaddleSpeechTTS';
|
||||||
|
|
||||||
|
-- 删除旧音色并添加默认音色
|
||||||
|
DELETE FROM `ai_tts_voice` WHERE tts_model_id = 'TTS_PaddleSpeechTTS';
|
||||||
|
INSERT INTO `ai_tts_voice` VALUES ('TTS_PaddleSpeechTTS_0000', 'TTS_PaddleSpeechTTS', '默认', '0', '中文', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL);
|
||||||
@@ -240,6 +240,27 @@ databaseChangeLog:
|
|||||||
- sqlFile:
|
- sqlFile:
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
path: classpath:db/changelog/202506261637.sql
|
path: classpath:db/changelog/202506261637.sql
|
||||||
|
- changeSet:
|
||||||
|
id: 202507101203
|
||||||
|
author: luruxian
|
||||||
|
changes:
|
||||||
|
- sqlFile:
|
||||||
|
encoding: utf8
|
||||||
|
path: classpath:db/changelog/202507101203.sql
|
||||||
|
- changeSet:
|
||||||
|
id: 202507071130
|
||||||
|
author: cgd
|
||||||
|
changes:
|
||||||
|
- sqlFile:
|
||||||
|
encoding: utf8
|
||||||
|
path: classpath:db/changelog/202507071130.sql
|
||||||
|
- changeSet:
|
||||||
|
id: 202507071530
|
||||||
|
author: cgd
|
||||||
|
changes:
|
||||||
|
- sqlFile:
|
||||||
|
encoding: utf8
|
||||||
|
path: classpath:db/changelog/202507071530.sql
|
||||||
- changeSet:
|
- changeSet:
|
||||||
id: 202507031602
|
id: 202507031602
|
||||||
author: zjy
|
author: zjy
|
||||||
@@ -261,3 +282,24 @@ databaseChangeLog:
|
|||||||
- sqlFile:
|
- sqlFile:
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
path: classpath:db/changelog/202507081646.sql
|
path: classpath:db/changelog/202507081646.sql
|
||||||
|
- changeSet:
|
||||||
|
id: 202508081701
|
||||||
|
author: hrz
|
||||||
|
changes:
|
||||||
|
- sqlFile:
|
||||||
|
encoding: utf8
|
||||||
|
path: classpath:db/changelog/202508081701.sql
|
||||||
|
- changeSet:
|
||||||
|
id: 202508111734
|
||||||
|
author: RanChen
|
||||||
|
changes:
|
||||||
|
- sqlFile:
|
||||||
|
encoding: utf8
|
||||||
|
path: classpath:db/changelog/202508111734.sql
|
||||||
|
- changeSet:
|
||||||
|
id: 202508131557
|
||||||
|
author: RanChen
|
||||||
|
changes:
|
||||||
|
- sqlFile:
|
||||||
|
encoding: utf8
|
||||||
|
path: classpath:db/changelog/202508131557.sql
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
<mapper namespace="xiaozhi.modules.security.dao.SysUserTokenDao">
|
<mapper namespace="xiaozhi.modules.security.dao.SysUserTokenDao">
|
||||||
|
|
||||||
<select id="getByToken" resultType="xiaozhi.modules.security.entity.SysUserTokenEntity">
|
<select id="getByToken" resultType="xiaozhi.modules.security.entity.SysUserTokenEntity">
|
||||||
select * from sys_user_token where token = #{value}
|
select * from sys_user_token where token = #{token}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getByUserId" resultType="xiaozhi.modules.security.entity.SysUserTokenEntity">
|
<select id="getByUserId" resultType="xiaozhi.modules.security.entity.SysUserTokenEntity">
|
||||||
select * from sys_user_token where user_id = #{value}
|
select * from sys_user_token where user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="logout">
|
<update id="logout">
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<!-- 根据参数编码,查询value -->
|
<!-- 根据参数编码,查询value -->
|
||||||
<select id="getValueByCode" resultType="String">
|
<select id="getValueByCode" resultType="String">
|
||||||
select param_value from sys_params where param_code = #{value}
|
select param_value from sys_params where param_code = #{paramCode}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 获取参数编码列表 -->
|
<!-- 获取参数编码列表 -->
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
extends: ['@commitlint/config-conventional'],
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*] # 表示所有文件适用
|
||||||
|
charset = utf-8 # 设置文件字符集为 utf-8
|
||||||
|
indent_style = space # 缩进风格(tab | space)
|
||||||
|
indent_size = 2 # 缩进大小
|
||||||
|
end_of_line = lf # 控制换行类型(lf | cr | crlf)
|
||||||
|
trim_trailing_whitespace = true # 去除行首的任意空白字符
|
||||||
|
insert_final_newline = true # 始终在文件末尾插入一个新行
|
||||||
|
|
||||||
|
[*.md] # 表示仅 md 文件适用以下规则
|
||||||
|
max_line_length = off # 关闭最大行长度限制
|
||||||
|
trim_trailing_whitespace = false # 关闭末尾空格修剪
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.idea
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
.hbuilderx
|
||||||
|
|
||||||
|
.stylelintcache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
docs/.vitepress/dist
|
||||||
|
docs/.vitepress/cache
|
||||||
|
|
||||||
|
src/types
|
||||||
|
|
||||||
|
# lock 文件还是不要了,我主要的版本写死就好了
|
||||||
|
# pnpm-lock.yaml
|
||||||
|
# package-lock.json
|
||||||
|
|
||||||
|
# TIPS:如果某些文件已经加入了版本管理,现在重新加入 .gitignore 是不生效的,需要执行下面的操作
|
||||||
|
# `git rm -r --cached .` 然后提交 commit 即可。
|
||||||
|
|
||||||
|
# git rm -r --cached file1 file2 ## 针对某些文件
|
||||||
|
# git rm -r --cached dir1 dir2 ## 针对某些文件夹
|
||||||
|
# git rm -r --cached . ## 针对所有文件
|
||||||
|
|
||||||
|
# 更新 uni-app 官方版本
|
||||||
|
# npx @dcloudio/uvm@latest
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# registry = https://registry.npmjs.org
|
||||||
|
registry = https://registry.npmmirror.com
|
||||||
|
|
||||||
|
strict-peer-dependencies=false
|
||||||
|
auto-install-peers=true
|
||||||
|
shamefully-hoist=true
|
||||||
|
ignore-workspace-root-check=true
|
||||||
|
install-workspace-root=true
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 Junsen
|
||||||
|
|
||||||
|
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.
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
## 智控台移动版(manager-mobile)
|
||||||
|
基于 uni-app v3 + Vue 3 + Vite 的跨端移动管理端,支持 App(Android & iOS)和微信小程序。
|
||||||
|
|
||||||
|
### 平台兼容性
|
||||||
|
|
||||||
|
| H5 | iOS | Android | 微信小程序 |
|
||||||
|
| -- | --- | ------- | ---------- |
|
||||||
|
| √ | √ | √ | √ |
|
||||||
|
|
||||||
|
提示:不同 UI 组件在不同平台的适配度略有差异,请以对应组件库文档为准。
|
||||||
|
|
||||||
|
### 开发环境要求
|
||||||
|
- Node >= 18
|
||||||
|
- pnpm >= 7.30(建议使用项目中声明的 `pnpm@10.x`)
|
||||||
|
- 可选:HBuilderX(App 调试/打包)、微信开发者工具(微信小程序)
|
||||||
|
|
||||||
|
### 快速开始
|
||||||
|
1) 配置环境变量
|
||||||
|
- 复制 `env/.env.example` 为 `env/.env.development`
|
||||||
|
- 根据实际情况修改配置项(特别是 `VITE_SERVER_BASEURL`、`VITE_UNI_APPID`、`VITE_WX_APPID`)
|
||||||
|
|
||||||
|
2) 安装依赖
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm i
|
||||||
|
```
|
||||||
|
|
||||||
|
3) 本地开发(热更新)
|
||||||
|
- h5: `pnpm dev:h5`,然后观察启动日志显示的ip端口号
|
||||||
|
- 微信小程序:`pnpm dev:mp` 或 `pnpm dev:mp-weixin`,然后用微信开发者工具导入 `dist/dev/mp-weixin`
|
||||||
|
- App:用 HBuilderX 导入 `manager-mobile`,然后参考下面的教程就能运行了
|
||||||
|
|
||||||
|
### 环境变量与配置
|
||||||
|
项目使用自定义 `env` 目录存放环境文件,按 Vite 规范命名:`.env.development`、`.env.production` 等。
|
||||||
|
|
||||||
|
关键变量(部分):
|
||||||
|
- VITE_APP_TITLE:应用名称(写入 `manifest.config.ts`)
|
||||||
|
- VITE_UNI_APPID:uni-app 应用 appid(App)
|
||||||
|
- VITE_WX_APPID:微信小程序 appid(mp-weixin)
|
||||||
|
- VITE_FALLBACK_LOCALE:默认语言,如 `zh-Hans`
|
||||||
|
- VITE_SERVER_BASEURL:服务端基础地址(HTTP 请求 baseURL)
|
||||||
|
- VITE_DELETE_CONSOLE:构建时是否移除 console(`true`/`false`)
|
||||||
|
- VITE_SHOW_SOURCEMAP:是否生成 sourcemap(默认关闭)
|
||||||
|
- VITE_LOGIN_URL:未登录跳转的登录页路径(路由拦截器使用)
|
||||||
|
|
||||||
|
示例(`env/.env.development`):
|
||||||
|
```env
|
||||||
|
VITE_APP_TITLE=小智
|
||||||
|
VITE_FALLBACK_LOCALE=zh-Hans
|
||||||
|
VITE_UNI_APPID=
|
||||||
|
VITE_WX_APPID=
|
||||||
|
|
||||||
|
VITE_SERVER_BASEURL=http://localhost:8080
|
||||||
|
|
||||||
|
VITE_DELETE_CONSOLE=false
|
||||||
|
VITE_SHOW_SOURCEMAP=false
|
||||||
|
VITE_LOGIN_URL=/pages/login/index
|
||||||
|
```
|
||||||
|
|
||||||
|
说明:
|
||||||
|
- `manifest.config.ts` 会从 `env` 读取标题、appid、语言等配置。
|
||||||
|
|
||||||
|
### 重要注意事项
|
||||||
|
⚠️ **部署前必须修改的配置项:**
|
||||||
|
|
||||||
|
1. **应用 ID 配置**
|
||||||
|
- `VITE_UNI_APPID`:需要在 [DCloud 开发者中心](https://dev.dcloud.net.cn/) 创建应用并获取 AppID
|
||||||
|
- `VITE_WX_APPID`:需要在 [微信公众平台](https://mp.weixin.qq.com/) 注册小程序并获取 AppID
|
||||||
|
|
||||||
|
2. **服务端地址**
|
||||||
|
- `VITE_SERVER_BASEURL`:修改为您的实际服务端地址
|
||||||
|
|
||||||
|
3. **应用信息**
|
||||||
|
- `VITE_APP_TITLE`:修改为您的应用名称
|
||||||
|
- 更新 `src/static/logo.png` 等图标资源
|
||||||
|
|
||||||
|
4. **其他配置**
|
||||||
|
- 检查 `manifest.config.ts` 中的应用配置信息
|
||||||
|
- 根据需要修改 `src/layouts/fg-tabbar/tabbarList.ts` 中的 tabbar 配置
|
||||||
|
|
||||||
|
### 详细操作指南
|
||||||
|
|
||||||
|
#### 1. 获取 uni-app AppID
|
||||||
|

|
||||||
|
- 复制生成的 AppID 到环境变量 `VITE_UNI_APPID` 中
|
||||||
|
|
||||||
|
#### 2. 本地运行步骤
|
||||||
|

|
||||||
|
|
||||||
|
**App 本地调试:**
|
||||||
|
1. 用 HBuilderX 导入 `manager-mobile` 目录
|
||||||
|
2. 重新识别项目
|
||||||
|
3. 连接手机或使用模拟器进行真机调试
|
||||||
|
|
||||||
|
**项目识别问题解决:**
|
||||||
|

|
||||||
|
|
||||||
|
如果 HBuilderX 无法正确识别项目类型:
|
||||||
|
- 在项目根目录右键选择"重新识别项目类型"
|
||||||
|
- 确保项目被识别为 "uni-app" 项目
|
||||||
|
|
||||||
|
### 路由与鉴权
|
||||||
|
- 在 `src/main.ts` 中注册了路由拦截插件 `routeInterceptor`。
|
||||||
|
- 黑名单拦截:仅对配置为需要登录的页面进行校验(来源 `@/utils` 的 `getNeedLoginPages`)。
|
||||||
|
- 登录判断:基于用户信息(`pinia` 的 `useUserStore`),未登录将跳转到 `VITE_LOGIN_URL`,并附带重定向回原页面的参数。
|
||||||
|
|
||||||
|
### 网络请求
|
||||||
|
- 基于 `alova` + `@alova/adapter-uniapp`,统一在 `src/http/request/alova.ts` 创建实例。
|
||||||
|
- `baseURL` 读取环境配置(`getEnvBaseUrl`),可通过 `method.config.meta.domain` 动态切换域名。
|
||||||
|
- 认证:默认从本地 `token`(`uni.getStorageSync('token')`)注入 `Authorization` 头,缺失则重定向登录。
|
||||||
|
- 响应:统一处理 `statusCode !== 200` 的 HTTP 错误与业务 `code !== 0` 的错误;`401` 会清除 token 并跳转登录。
|
||||||
|
|
||||||
|
### 构建与发布
|
||||||
|
|
||||||
|
**微信小程序:**
|
||||||
|
1. 确保已配置正确的 `VITE_WX_APPID`
|
||||||
|
2. 运行 `pnpm build:mp`,产物在 `dist/build/mp-weixin`
|
||||||
|
3. 用微信开发者工具导入项目目录,并上传代码
|
||||||
|
4. 在微信公众平台提交审核
|
||||||
|
|
||||||
|
**Android & iOS App:**
|
||||||
|
|
||||||
|
#### 3. App 打包发行步骤
|
||||||
|
|
||||||
|
**步骤一:准备打包**
|
||||||
|

|
||||||
|
|
||||||
|
1. 确保已配置正确的 `VITE_UNI_APPID`
|
||||||
|
2. 运行 `pnpm build:app`,产物在 `dist/build/app`
|
||||||
|
3. 用 HBuilderX 导入项目目录
|
||||||
|
4. 在 HBuilderX 中点击"发行" → "原生App-云打包"
|
||||||
|
|
||||||
|
**步骤二:配置打包参数**
|
||||||
|

|
||||||
|
|
||||||
|
1. **应用图标和启动图**:上传应用图标和启动页面图片
|
||||||
|
2. **应用版本号**:设置版本号和版本名称
|
||||||
|
3. **签名证书**:
|
||||||
|
- Android:上传 keystore 证书文件
|
||||||
|
- iOS:配置开发者证书和描述文件
|
||||||
|
4. **包名配置**:设置应用的包名(Bundle ID)
|
||||||
|
5. **打包类型**:选择测试包或正式包
|
||||||
|
6. 点击"打包"开始云打包流程
|
||||||
|
|
||||||
|
**发布到应用商店:**
|
||||||
|
- **Android**:将生成的 APK 文件上传到各大 Android 应用市场
|
||||||
|
- **iOS**:将生成的 IPA 文件通过 App Store Connect 上传到 App Store(需要 Apple 开发者账号)
|
||||||
|
|
||||||
|
### 约定与工程化
|
||||||
|
- 页面与分包:由 `@uni-helper/vite-plugin-uni-pages` 与 `pages.config.ts` 统一生成;tabbar 配置在 `src/layouts/fg-tabbar/tabbarList.ts`。
|
||||||
|
- 组件与 hooks 自动导入:见 `vite.config.ts` 中 `unplugin-auto-import` 与 `@uni-helper/vite-plugin-uni-components`。
|
||||||
|
- 样式:使用 UnoCSS 与 `src/style/index.scss`。
|
||||||
|
- 状态管理:`pinia` + `pinia-plugin-persistedstate`。
|
||||||
|
- 代码规范:内置 `eslint`、`husky`、`lint-staged`,提交前自动格式化(`lint-staged`)。
|
||||||
|
|
||||||
|
### 常用脚本
|
||||||
|
```bash
|
||||||
|
# 开发
|
||||||
|
pnpm dev:mp # 等价 dev:mp-weixin
|
||||||
|
|
||||||
|
# 构建
|
||||||
|
pnpm build:mp # 等价 build:mp-weixin
|
||||||
|
|
||||||
|
# 其他
|
||||||
|
pnpm type-check
|
||||||
|
pnpm lint && pnpm lint:fix
|
||||||
|
```
|
||||||
|
|
||||||
|
### License
|
||||||
|
MIT
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
VITE_APP_TITLE = '小智'
|
||||||
|
VITE_APP_PORT = 9000
|
||||||
|
|
||||||
|
VITE_UNI_APPID = '__UNI__36A515E'
|
||||||
|
VITE_WX_APPID = 'wxa2abb91f64032a2b'
|
||||||
|
|
||||||
|
# h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base
|
||||||
|
VITE_APP_PUBLIC_BASE=/
|
||||||
|
|
||||||
|
# 登录页面
|
||||||
|
VITE_LOGIN_URL = '/pages/login/index'
|
||||||
|
# 第一个请求地址
|
||||||
|
VITE_SERVER_BASEURL = 'https://2662r3426b.vicp.fun/xiaozhi'
|
||||||
|
|
||||||
|
VITE_UPLOAD_BASEURL = '/otaMag/upload'
|
||||||
|
|
||||||
|
# h5是否需要配置代理
|
||||||
|
VITE_APP_PROXY=true
|
||||||
|
VITE_APP_PROXY_PREFIX = '/xiaozhi'
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# 变量必须以 VITE_ 为前缀才能暴露给外部读取
|
||||||
|
NODE_ENV = 'development'
|
||||||
|
# 是否去除console 和 debugger
|
||||||
|
VITE_DELETE_CONSOLE = false
|
||||||
|
# 是否开启sourcemap
|
||||||
|
VITE_SHOW_SOURCEMAP = true
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# 变量必须以 VITE_ 为前缀才能暴露给外部读取
|
||||||
|
NODE_ENV = 'development'
|
||||||
|
# 是否去除console 和 debugger
|
||||||
|
VITE_DELETE_CONSOLE = true
|
||||||
|
# 是否开启sourcemap
|
||||||
|
VITE_SHOW_SOURCEMAP = false
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# 变量必须以 VITE_ 为前缀才能暴露给外部读取
|
||||||
|
NODE_ENV = 'development'
|
||||||
|
# 是否去除console 和 debugger
|
||||||
|
VITE_DELETE_CONSOLE = false
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import uniHelper from '@uni-helper/eslint-config'
|
||||||
|
|
||||||
|
export default uniHelper({
|
||||||
|
unocss: true,
|
||||||
|
vue: true,
|
||||||
|
markdown: false,
|
||||||
|
ignores: [
|
||||||
|
'src/uni_modules/',
|
||||||
|
'dist',
|
||||||
|
// unplugin-auto-import 生成的类型文件,每次提交都改变,所以加入这里吧,与 .gitignore 配合使用
|
||||||
|
'auto-import.d.ts',
|
||||||
|
// vite-plugin-uni-pages 生成的类型文件,每次切换分支都一堆不同的,所以直接 .gitignore
|
||||||
|
'uni-pages.d.ts',
|
||||||
|
// 插件生成的文件
|
||||||
|
'src/pages.json',
|
||||||
|
'src/manifest.json',
|
||||||
|
// 忽略自动生成文件
|
||||||
|
'src/service/app/**',
|
||||||
|
],
|
||||||
|
rules: {
|
||||||
|
'no-console': 'off',
|
||||||
|
'no-unused-vars': 'off',
|
||||||
|
'vue/no-unused-refs': 'off',
|
||||||
|
'unused-imports/no-unused-vars': 'off',
|
||||||
|
'eslint-comments/no-unlimited-disable': 'off',
|
||||||
|
'jsdoc/check-param-names': 'off',
|
||||||
|
'jsdoc/require-returns-description': 'off',
|
||||||
|
'ts/no-empty-object-type': 'off',
|
||||||
|
'no-extend-native': 'off',
|
||||||
|
},
|
||||||
|
formatters: {
|
||||||
|
/**
|
||||||
|
* Format CSS, LESS, SCSS files, also the `<style>` blocks in Vue
|
||||||
|
* By default uses Prettier
|
||||||
|
*/
|
||||||
|
css: true,
|
||||||
|
/**
|
||||||
|
* Format HTML files
|
||||||
|
* By default uses Prettier
|
||||||
|
*/
|
||||||
|
html: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
After Width: | Height: | Size: 14 KiB |
@@ -0,0 +1,26 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html build-time="%BUILD_TIME%">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
|
||||||
|
<script>
|
||||||
|
var coverSupport =
|
||||||
|
'CSS' in window &&
|
||||||
|
typeof CSS.supports === 'function' &&
|
||||||
|
(CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
|
||||||
|
document.write(
|
||||||
|
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
|
||||||
|
(coverSupport ? ', viewport-fit=cover' : '') +
|
||||||
|
'" />',
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
<title>unibest</title>
|
||||||
|
<!--preload-links-->
|
||||||
|
<!--app-context-->
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="app"><!--app-html--></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
import path from 'node:path'
|
||||||
|
import process from 'node:process'
|
||||||
|
// manifest.config.ts
|
||||||
|
import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest'
|
||||||
|
import { loadEnv } from 'vite'
|
||||||
|
|
||||||
|
// 手动解析命令行参数获取 mode
|
||||||
|
function getMode() {
|
||||||
|
const args = process.argv.slice(2)
|
||||||
|
const modeFlagIndex = args.findIndex(arg => arg === '--mode')
|
||||||
|
return modeFlagIndex !== -1 ? args[modeFlagIndex + 1] : args[0] === 'build' ? 'production' : 'development' // 默认 development
|
||||||
|
}
|
||||||
|
// 获取环境变量的范例
|
||||||
|
const env = loadEnv(getMode(), path.resolve(process.cwd(), 'env'))
|
||||||
|
const {
|
||||||
|
VITE_APP_TITLE,
|
||||||
|
VITE_UNI_APPID,
|
||||||
|
VITE_WX_APPID,
|
||||||
|
VITE_APP_PUBLIC_BASE,
|
||||||
|
VITE_FALLBACK_LOCALE,
|
||||||
|
} = env
|
||||||
|
|
||||||
|
export default defineManifestConfig({
|
||||||
|
'name': VITE_APP_TITLE,
|
||||||
|
'appid': VITE_UNI_APPID,
|
||||||
|
'description': '',
|
||||||
|
'versionName': '1.0.0',
|
||||||
|
'versionCode': '100',
|
||||||
|
'transformPx': false,
|
||||||
|
'locale': VITE_FALLBACK_LOCALE, // 'zh-Hans'
|
||||||
|
'h5': {
|
||||||
|
router: {
|
||||||
|
// base: VITE_APP_PUBLIC_BASE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
/* 5+App特有相关 */
|
||||||
|
'app-plus': {
|
||||||
|
usingComponents: true,
|
||||||
|
nvueStyleCompiler: 'uni-app',
|
||||||
|
compilerVersion: 3,
|
||||||
|
compatible: {
|
||||||
|
ignoreVersion: true,
|
||||||
|
},
|
||||||
|
splashscreen: {
|
||||||
|
alwaysShowBeforeRender: true,
|
||||||
|
waiting: true,
|
||||||
|
autoclose: true,
|
||||||
|
delay: 0,
|
||||||
|
},
|
||||||
|
/* 模块配置 */
|
||||||
|
modules: {},
|
||||||
|
/* 应用发布信息 */
|
||||||
|
distribute: {
|
||||||
|
/* android打包配置 */
|
||||||
|
android: {
|
||||||
|
minSdkVersion: 30,
|
||||||
|
targetSdkVersion: 30,
|
||||||
|
abiFilters: ['armeabi-v7a', 'arm64-v8a'],
|
||||||
|
permissions: [
|
||||||
|
'<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>',
|
||||||
|
'<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>',
|
||||||
|
'<uses-permission android:name="android.permission.VIBRATE"/>',
|
||||||
|
'<uses-permission android:name="android.permission.READ_LOGS"/>',
|
||||||
|
'<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>',
|
||||||
|
'<uses-feature android:name="android.hardware.camera.autofocus"/>',
|
||||||
|
'<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>',
|
||||||
|
'<uses-permission android:name="android.permission.CAMERA"/>',
|
||||||
|
'<uses-permission android:name="android.permission.GET_ACCOUNTS"/>',
|
||||||
|
'<uses-permission android:name="android.permission.READ_PHONE_STATE"/>',
|
||||||
|
'<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>',
|
||||||
|
'<uses-permission android:name="android.permission.WAKE_LOCK"/>',
|
||||||
|
'<uses-permission android:name="android.permission.FLASHLIGHT"/>',
|
||||||
|
'<uses-feature android:name="android.hardware.camera"/>',
|
||||||
|
'<uses-permission android:name="android.permission.WRITE_SETTINGS"/>',
|
||||||
|
'<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>',
|
||||||
|
'<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
/* ios打包配置 */
|
||||||
|
ios: {},
|
||||||
|
/* SDK配置 */
|
||||||
|
sdkConfigs: {},
|
||||||
|
/* 图标配置 */
|
||||||
|
icons: {
|
||||||
|
android: {
|
||||||
|
hdpi: 'unpackage/res/icons/72x72.png',
|
||||||
|
xhdpi: 'unpackage/res/icons/96x96.png',
|
||||||
|
xxhdpi: 'unpackage/res/icons/144x144.png',
|
||||||
|
xxxhdpi: 'unpackage/res/icons/192x192.png',
|
||||||
|
},
|
||||||
|
ios: {
|
||||||
|
appstore: 'unpackage/res/icons/1024x1024.png',
|
||||||
|
ipad: {
|
||||||
|
'app': 'unpackage/res/icons/76x76.png',
|
||||||
|
'app@2x': 'unpackage/res/icons/152x152.png',
|
||||||
|
'notification': 'unpackage/res/icons/20x20.png',
|
||||||
|
'notification@2x': 'unpackage/res/icons/40x40.png',
|
||||||
|
'proapp@2x': 'unpackage/res/icons/167x167.png',
|
||||||
|
'settings': 'unpackage/res/icons/29x29.png',
|
||||||
|
'settings@2x': 'unpackage/res/icons/58x58.png',
|
||||||
|
'spotlight': 'unpackage/res/icons/40x40.png',
|
||||||
|
'spotlight@2x': 'unpackage/res/icons/80x80.png',
|
||||||
|
},
|
||||||
|
iphone: {
|
||||||
|
'app@2x': 'unpackage/res/icons/120x120.png',
|
||||||
|
'app@3x': 'unpackage/res/icons/180x180.png',
|
||||||
|
'notification@2x': 'unpackage/res/icons/40x40.png',
|
||||||
|
'notification@3x': 'unpackage/res/icons/60x60.png',
|
||||||
|
'settings@2x': 'unpackage/res/icons/58x58.png',
|
||||||
|
'settings@3x': 'unpackage/res/icons/87x87.png',
|
||||||
|
'spotlight@2x': 'unpackage/res/icons/80x80.png',
|
||||||
|
'spotlight@3x': 'unpackage/res/icons/120x120.png',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
/* 快应用特有相关 */
|
||||||
|
'quickapp': {},
|
||||||
|
/* 小程序特有相关 */
|
||||||
|
'mp-weixin': {
|
||||||
|
appid: VITE_WX_APPID,
|
||||||
|
setting: {
|
||||||
|
urlCheck: false,
|
||||||
|
// 是否启用 ES6 转 ES5
|
||||||
|
es6: true,
|
||||||
|
minified: true,
|
||||||
|
},
|
||||||
|
optimization: {
|
||||||
|
subPackages: true,
|
||||||
|
},
|
||||||
|
usingComponents: true,
|
||||||
|
// __usePrivacyCheck__: true,
|
||||||
|
permission: {
|
||||||
|
'scope.userLocation': {
|
||||||
|
desc: 'WiFi配网功能需要获取位置权限',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
requiredPrivateInfos: ['getLocation'],
|
||||||
|
},
|
||||||
|
'mp-alipay': {
|
||||||
|
usingComponents: true,
|
||||||
|
styleIsolation: 'shared',
|
||||||
|
},
|
||||||
|
'mp-baidu': {
|
||||||
|
usingComponents: true,
|
||||||
|
},
|
||||||
|
'mp-toutiao': {
|
||||||
|
usingComponents: true,
|
||||||
|
},
|
||||||
|
'uniStatistics': {
|
||||||
|
enable: false,
|
||||||
|
},
|
||||||
|
'vueVersion': '3',
|
||||||
|
})
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
{
|
||||||
|
"name": "xiaozhi-mobile-admin",
|
||||||
|
"type": "commonjs",
|
||||||
|
"version": "3.4.0",
|
||||||
|
"unibest-version": "3.4.0",
|
||||||
|
"packageManager": "pnpm@10.10.0",
|
||||||
|
"description": "xiaozhi-esp32-server的移动端管理后台",
|
||||||
|
"generate-time": "2025-08-04",
|
||||||
|
"author": {
|
||||||
|
"name": "huangjunsen",
|
||||||
|
"zhName": "黄俊森",
|
||||||
|
"email": "huangjunsen@xiaozhi.com",
|
||||||
|
"github": "https://github.com/huangjunsen0406",
|
||||||
|
"gitee": "https://gitee.com/huang-jun-sen"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"homepage": "https://github.com/xinnan-tech/xiaozhi-esp32-server",
|
||||||
|
"repository": "https://github.com/xinnan-tech/xiaozhi-esp32-server",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/xinnan-tech/xiaozhi-esp32-server/issues"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18",
|
||||||
|
"pnpm": ">=7.30"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"preinstall": "npx only-allow pnpm",
|
||||||
|
"uvm": "npx @dcloudio/uvm@latest",
|
||||||
|
"uvm-rm": "node ./scripts/postupgrade.js",
|
||||||
|
"postuvm": "echo upgrade uni-app success!",
|
||||||
|
"dev:app": "uni -p app",
|
||||||
|
"dev:app-android": "uni -p app-android",
|
||||||
|
"dev:app-ios": "uni -p app-ios",
|
||||||
|
"dev:custom": "uni -p",
|
||||||
|
"dev": "uni",
|
||||||
|
"dev:h5": "uni",
|
||||||
|
"dev:h5:ssr": "uni --ssr",
|
||||||
|
"dev:mp": "uni -p mp-weixin",
|
||||||
|
"dev:mp-alipay": "uni -p mp-alipay",
|
||||||
|
"dev:mp-baidu": "uni -p mp-baidu",
|
||||||
|
"dev:mp-jd": "uni -p mp-jd",
|
||||||
|
"dev:mp-kuaishou": "uni -p mp-kuaishou",
|
||||||
|
"dev:mp-lark": "uni -p mp-lark",
|
||||||
|
"dev:mp-qq": "uni -p mp-qq",
|
||||||
|
"dev:mp-toutiao": "uni -p mp-toutiao",
|
||||||
|
"dev:mp-weixin": "uni -p mp-weixin",
|
||||||
|
"dev:mp-xhs": "uni -p mp-xhs",
|
||||||
|
"dev:quickapp-webview": "uni -p quickapp-webview",
|
||||||
|
"dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei",
|
||||||
|
"dev:quickapp-webview-union": "uni -p quickapp-webview-union",
|
||||||
|
"build:app": "uni build -p app",
|
||||||
|
"build:app-android": "uni build -p app-android",
|
||||||
|
"build:app-ios": "uni build -p app-ios",
|
||||||
|
"build:custom": "uni build -p",
|
||||||
|
"build:h5": "uni build",
|
||||||
|
"build": "uni build",
|
||||||
|
"build:h5:ssr": "uni build --ssr",
|
||||||
|
"build:mp-alipay": "uni build -p mp-alipay",
|
||||||
|
"build:mp": "uni build -p mp-weixin",
|
||||||
|
"build:mp-baidu": "uni build -p mp-baidu",
|
||||||
|
"build:mp-jd": "uni build -p mp-jd",
|
||||||
|
"build:mp-kuaishou": "uni build -p mp-kuaishou",
|
||||||
|
"build:mp-lark": "uni build -p mp-lark",
|
||||||
|
"build:mp-qq": "uni build -p mp-qq",
|
||||||
|
"build:mp-toutiao": "uni build -p mp-toutiao",
|
||||||
|
"build:mp-weixin": "uni build -p mp-weixin",
|
||||||
|
"build:mp-xhs": "uni build -p mp-xhs",
|
||||||
|
"build:quickapp-webview": "uni build -p quickapp-webview",
|
||||||
|
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
|
||||||
|
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
|
||||||
|
"type-check": "vue-tsc --noEmit",
|
||||||
|
"openapi-ts-request": "openapi-ts",
|
||||||
|
"prepare": "git init && husky",
|
||||||
|
"lint": "eslint",
|
||||||
|
"lint:fix": "eslint --fix"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@alova/adapter-uniapp": "^2.0.14",
|
||||||
|
"@alova/shared": "^1.3.1",
|
||||||
|
"@dcloudio/uni-app": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-app-harmony": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-app-plus": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-components": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-h5": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-mp-alipay": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-mp-baidu": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-mp-harmony": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-mp-jd": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-mp-kuaishou": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-mp-lark": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-mp-qq": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-mp-toutiao": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-mp-weixin": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-mp-xhs": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-quickapp-webview": "3.0.0-4060620250520001",
|
||||||
|
"@tanstack/vue-query": "^5.62.16",
|
||||||
|
"abortcontroller-polyfill": "^1.7.8",
|
||||||
|
"alova": "^3.3.3",
|
||||||
|
"dayjs": "1.11.10",
|
||||||
|
"js-cookie": "^3.0.5",
|
||||||
|
"pinia": "2.0.36",
|
||||||
|
"pinia-plugin-persistedstate": "3.2.1",
|
||||||
|
"vue": "^3.4.21",
|
||||||
|
"wot-design-uni": "^1.9.1",
|
||||||
|
"z-paging": "2.8.7"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@alova/wormhole": "^1.0.8",
|
||||||
|
"@antfu/eslint-config": "^4.15.0",
|
||||||
|
"@commitlint/cli": "^19.8.1",
|
||||||
|
"@commitlint/config-conventional": "^19.8.1",
|
||||||
|
"@dcloudio/types": "^3.4.8",
|
||||||
|
"@dcloudio/uni-automator": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-cli-shared": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-stacktracey": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/uni-uts-v1": "3.0.0-4060620250520001",
|
||||||
|
"@dcloudio/vite-plugin-uni": "3.0.0-4060620250520001",
|
||||||
|
"@esbuild/darwin-arm64": "0.20.2",
|
||||||
|
"@esbuild/darwin-x64": "0.20.2",
|
||||||
|
"@iconify-json/carbon": "^1.2.4",
|
||||||
|
"@rollup/rollup-darwin-x64": "^4.28.0",
|
||||||
|
"@types/node": "^20.17.9",
|
||||||
|
"@types/wechat-miniprogram": "^3.4.8",
|
||||||
|
"@uni-helper/eslint-config": "^0.4.0",
|
||||||
|
"@uni-helper/uni-types": "1.0.0-alpha.3",
|
||||||
|
"@uni-helper/unocss-preset-uni": "^0.2.11",
|
||||||
|
"@uni-helper/vite-plugin-uni-components": "0.2.0",
|
||||||
|
"@uni-helper/vite-plugin-uni-layouts": "0.1.10",
|
||||||
|
"@uni-helper/vite-plugin-uni-manifest": "0.2.8",
|
||||||
|
"@uni-helper/vite-plugin-uni-pages": "0.2.28",
|
||||||
|
"@uni-helper/vite-plugin-uni-platform": "0.0.4",
|
||||||
|
"@uni-ku/bundle-optimizer": "^1.3.3",
|
||||||
|
"@unocss/eslint-plugin": "^66.2.3",
|
||||||
|
"@unocss/preset-legacy-compat": "^0.59.4",
|
||||||
|
"@vue/runtime-core": "^3.4.21",
|
||||||
|
"@vue/tsconfig": "^0.1.3",
|
||||||
|
"autoprefixer": "^10.4.20",
|
||||||
|
"eslint": "^9.29.0",
|
||||||
|
"eslint-plugin-format": "^1.0.1",
|
||||||
|
"husky": "^9.1.7",
|
||||||
|
"lint-staged": "^15.2.10",
|
||||||
|
"openapi-ts-request": "^1.1.2",
|
||||||
|
"postcss": "^8.4.49",
|
||||||
|
"postcss-html": "^1.7.0",
|
||||||
|
"postcss-scss": "^4.0.9",
|
||||||
|
"rollup-plugin-visualizer": "^5.12.0",
|
||||||
|
"sass": "1.77.8",
|
||||||
|
"typescript": "^5.7.2",
|
||||||
|
"unocss": "65.4.2",
|
||||||
|
"unplugin-auto-import": "^0.17.8",
|
||||||
|
"vite": "5.2.8",
|
||||||
|
"vite-plugin-restart": "^0.4.2",
|
||||||
|
"vue-tsc": "^2.2.10"
|
||||||
|
},
|
||||||
|
"resolutions": {
|
||||||
|
"bin-wrapper": "npm:bin-wrapper-china"
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"*": "eslint --fix"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
|
||||||
|
import { tabBar } from './src/layouts/fg-tabbar/tabbarList'
|
||||||
|
|
||||||
|
export default defineUniPages({
|
||||||
|
globalStyle: {
|
||||||
|
navigationStyle: 'default',
|
||||||
|
navigationBarTitleText: '小智',
|
||||||
|
navigationBarBackgroundColor: '#f8f8f8',
|
||||||
|
navigationBarTextStyle: 'black',
|
||||||
|
backgroundColor: '#FFFFFF',
|
||||||
|
},
|
||||||
|
easycom: {
|
||||||
|
autoscan: true,
|
||||||
|
custom: {
|
||||||
|
'^fg-(.*)': '@/components/fg-$1/fg-$1.vue',
|
||||||
|
'^wd-(.*)': 'wot-design-uni/components/wd-$1/wd-$1.vue',
|
||||||
|
'^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)':
|
||||||
|
'z-paging/components/z-paging$1/z-paging$1.vue',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// tabbar 的配置统一在 "./src/layouts/fg-tabbar/tabbarList.ts" 文件中
|
||||||
|
tabBar: tabBar as any,
|
||||||
|
})
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/dist/uni-h5.es.js b/dist/uni-h5.es.js
|
||||||
|
index 7421bad97d94ad34a3d4d94292a9ee9071430662..19c6071ee4036ceb8d1cfa09030e471c002d2cda 100644
|
||||||
|
--- a/dist/uni-h5.es.js
|
||||||
|
+++ b/dist/uni-h5.es.js
|
||||||
|
@@ -23410,7 +23410,7 @@ function useShowTabBar(emit2) {
|
||||||
|
const tabBar2 = useTabBar();
|
||||||
|
const showTabBar2 = computed(() => route.meta.isTabBar && tabBar2.shown);
|
||||||
|
updateCssVar({
|
||||||
|
- "--tab-bar-height": tabBar2.height
|
||||||
|
+ "--tab-bar-height": tabBar2?.height || 0
|
||||||
|
});
|
||||||
|
return showTabBar2;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
packages:
|
||||||
|
- '**'
|
||||||
|
- '!node_modules'
|
||||||
|
|
||||||
|
patchedDependencies:
|
||||||
|
'@dcloudio/uni-h5': patches/@dcloudio__uni-h5.patch
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// # 执行 `pnpm upgrade` 后会升级 `uniapp` 相关依赖
|
||||||
|
// # 在升级完后,会自动添加很多无用依赖,这需要删除以减小依赖包体积
|
||||||
|
// # 只需要执行下面的命令即可
|
||||||
|
|
||||||
|
const { exec } = require('node:child_process')
|
||||||
|
|
||||||
|
// 定义要执行的命令
|
||||||
|
const dependencies = [
|
||||||
|
'@dcloudio/uni-app-harmony',
|
||||||
|
// TODO: 如果不需要某个平台的小程序,请手动删除或注释掉
|
||||||
|
'@dcloudio/uni-mp-alipay',
|
||||||
|
'@dcloudio/uni-mp-baidu',
|
||||||
|
'@dcloudio/uni-mp-jd',
|
||||||
|
'@dcloudio/uni-mp-kuaishou',
|
||||||
|
'@dcloudio/uni-mp-lark',
|
||||||
|
'@dcloudio/uni-mp-qq',
|
||||||
|
'@dcloudio/uni-mp-toutiao',
|
||||||
|
'@dcloudio/uni-mp-xhs',
|
||||||
|
'@dcloudio/uni-quickapp-webview',
|
||||||
|
// i18n模板要注释掉下面的
|
||||||
|
'vue-i18n',
|
||||||
|
]
|
||||||
|
|
||||||
|
// 使用exec执行命令
|
||||||
|
exec(`pnpm un ${dependencies.join(' ')}`, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
// 如果有错误,打印错误信息
|
||||||
|
console.error(`执行出错: ${error}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 打印正常输出
|
||||||
|
console.log(`stdout: ${stdout}`)
|
||||||
|
// 如果有错误输出,也打印出来
|
||||||
|
console.error(`stderr: ${stderr}`)
|
||||||
|
})
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
|
||||||
|
import { usePageAuth } from '@/hooks/usePageAuth'
|
||||||
|
import { useConfigStore } from '@/store'
|
||||||
|
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
|
||||||
|
|
||||||
|
usePageAuth()
|
||||||
|
|
||||||
|
const configStore = useConfigStore()
|
||||||
|
|
||||||
|
onLaunch(() => {
|
||||||
|
console.log('App Launch')
|
||||||
|
// 获取公共配置
|
||||||
|
configStore.fetchPublicConfig().catch((error) => {
|
||||||
|
console.error('获取公共配置失败:', error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
onShow(() => {
|
||||||
|
console.log('App Show')
|
||||||
|
})
|
||||||
|
onHide(() => {
|
||||||
|
console.log('App Hide')
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
swiper,
|
||||||
|
scroll-view {
|
||||||
|
flex: 1;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
import type {
|
||||||
|
Agent,
|
||||||
|
AgentCreateData,
|
||||||
|
AgentDetail,
|
||||||
|
ModelOption,
|
||||||
|
RoleTemplate,
|
||||||
|
} from './types'
|
||||||
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
|
// 获取智能体详情
|
||||||
|
export function getAgentDetail(id: string) {
|
||||||
|
return http.Get<AgentDetail>(`/agent/${id}`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取角色模板列表
|
||||||
|
export function getRoleTemplates() {
|
||||||
|
return http.Get<RoleTemplate[]>('/agent/template', {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取模型选项
|
||||||
|
export function getModelOptions(modelType: string, modelName: string = '') {
|
||||||
|
return http.Get<ModelOption[]>('/models/names', {
|
||||||
|
params: {
|
||||||
|
modelType,
|
||||||
|
modelName,
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取智能体列表
|
||||||
|
export function getAgentList() {
|
||||||
|
return http.Get<Agent[]>('/agent/list', {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建智能体
|
||||||
|
export function createAgent(data: AgentCreateData) {
|
||||||
|
return http.Post<string>('/agent', data, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除智能体
|
||||||
|
export function deleteAgent(id: string) {
|
||||||
|
return http.Delete(`/agent/${id}`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取TTS音色列表
|
||||||
|
export function getTTSVoices(ttsModelId: string, voiceName: string = '') {
|
||||||
|
return http.Get<{ id: string, name: string }[]>(`/models/${ttsModelId}/voices`, {
|
||||||
|
params: {
|
||||||
|
voiceName,
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新智能体
|
||||||
|
export function updateAgent(id: string, data: Partial<AgentDetail>) {
|
||||||
|
return http.Put(`/agent/${id}`, data, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: true,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取插件列表
|
||||||
|
export function getPluginFunctions() {
|
||||||
|
return http.Get<any[]>(`/models/provider/plugin/names`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取mcp接入点
|
||||||
|
export function getMcpAddress(agentId: string) {
|
||||||
|
return http.Get<string>(`/agent/mcp/address/${agentId}`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取mcp工具
|
||||||
|
export function getMcpTools(agentId: string) {
|
||||||
|
return http.Get<string[]>(`/agent/mcp/tools/${agentId}`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取声纹列表
|
||||||
|
export function getVoicePrintList(agentId: string) {
|
||||||
|
return http.Get<any[]>(`/agent/voice-print/list/${agentId}`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取语音对话记录
|
||||||
|
export function getChatHistoryUser(agentId: string) {
|
||||||
|
return http.Get<any[]>(`/agent/${agentId}/chat-history/user`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增声纹说话人
|
||||||
|
export function createVoicePrint(data: { agentId: string, audioId: string, sourceName: string, introduce: string }) {
|
||||||
|
return http.Post('/agent/voice-print', data, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
// 智能体列表数据类型
|
||||||
|
export interface Agent {
|
||||||
|
id: string
|
||||||
|
agentName: string
|
||||||
|
ttsModelName: string
|
||||||
|
ttsVoiceName: string
|
||||||
|
llmModelName: string
|
||||||
|
vllmModelName: string
|
||||||
|
memModelId: string
|
||||||
|
systemPrompt: string
|
||||||
|
summaryMemory: string | null
|
||||||
|
lastConnectedAt: string | null
|
||||||
|
deviceCount: number
|
||||||
|
}
|
||||||
|
|
||||||
|
// 智能体创建数据类型
|
||||||
|
export interface AgentCreateData {
|
||||||
|
agentName: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 智能体详情数据类型
|
||||||
|
export interface AgentDetail {
|
||||||
|
id: string
|
||||||
|
userId: string
|
||||||
|
agentCode: string
|
||||||
|
agentName: string
|
||||||
|
asrModelId: string
|
||||||
|
vadModelId: string
|
||||||
|
llmModelId: string
|
||||||
|
vllmModelId: string
|
||||||
|
ttsModelId: string
|
||||||
|
ttsVoiceId: string
|
||||||
|
memModelId: string
|
||||||
|
intentModelId: string
|
||||||
|
chatHistoryConf: number
|
||||||
|
systemPrompt: string
|
||||||
|
summaryMemory: string
|
||||||
|
langCode: string
|
||||||
|
language: string
|
||||||
|
sort: number
|
||||||
|
creator: string
|
||||||
|
createdAt: string
|
||||||
|
updater: string
|
||||||
|
updatedAt: string
|
||||||
|
functions: AgentFunction[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AgentFunction {
|
||||||
|
id?: string
|
||||||
|
agentId?: string
|
||||||
|
pluginId: string
|
||||||
|
paramInfo: Record<string, string | number | boolean> | null
|
||||||
|
}
|
||||||
|
|
||||||
|
// 角色模板数据类型
|
||||||
|
export interface RoleTemplate {
|
||||||
|
id: string
|
||||||
|
agentCode: string
|
||||||
|
agentName: string
|
||||||
|
asrModelId: string
|
||||||
|
vadModelId: string
|
||||||
|
llmModelId: string
|
||||||
|
vllmModelId: string
|
||||||
|
ttsModelId: string
|
||||||
|
ttsVoiceId: string
|
||||||
|
memModelId: string
|
||||||
|
intentModelId: string
|
||||||
|
chatHistoryConf: number
|
||||||
|
systemPrompt: string
|
||||||
|
summaryMemory: string
|
||||||
|
langCode: string
|
||||||
|
language: string
|
||||||
|
sort: number
|
||||||
|
creator: string
|
||||||
|
createdAt: string
|
||||||
|
updater: string
|
||||||
|
updatedAt: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模型选项数据类型
|
||||||
|
export interface ModelOption {
|
||||||
|
id: string
|
||||||
|
modelName: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PluginField {
|
||||||
|
key: string
|
||||||
|
type: string
|
||||||
|
label: string
|
||||||
|
default: string
|
||||||
|
selected?: boolean
|
||||||
|
editing?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PluginDefinition {
|
||||||
|
id: string
|
||||||
|
modelType: string
|
||||||
|
providerCode: string
|
||||||
|
name: string
|
||||||
|
fields: PluginField[] // 注意:原始是字符串,需要先 JSON.parse
|
||||||
|
sort: number
|
||||||
|
updater: string
|
||||||
|
updateDate: string
|
||||||
|
creator: string
|
||||||
|
createDate: string
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
|
// 登录接口数据类型
|
||||||
|
export interface LoginData {
|
||||||
|
username: string
|
||||||
|
password: string
|
||||||
|
captcha: string
|
||||||
|
captchaId: string
|
||||||
|
areaCode?: string
|
||||||
|
mobile?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 登录响应数据类型
|
||||||
|
export interface LoginResponse {
|
||||||
|
token: string
|
||||||
|
expire: number
|
||||||
|
clientHash: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证码响应数据类型
|
||||||
|
export interface CaptchaResponse {
|
||||||
|
captchaId: string
|
||||||
|
captchaImage: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取验证码
|
||||||
|
export function getCaptcha(uuid: string) {
|
||||||
|
return http.Get<string>('/user/captcha', {
|
||||||
|
params: { uuid },
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: true,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户登录
|
||||||
|
export function login(data: LoginData) {
|
||||||
|
return http.Post<LoginResponse>('/user/login', data, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: true,
|
||||||
|
toast: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户信息响应数据类型
|
||||||
|
export interface UserInfo {
|
||||||
|
id: number
|
||||||
|
username: string
|
||||||
|
realName: string
|
||||||
|
email: string
|
||||||
|
mobile: string
|
||||||
|
status: number
|
||||||
|
superAdmin: number
|
||||||
|
}
|
||||||
|
|
||||||
|
// 公共配置响应数据类型
|
||||||
|
export interface PublicConfig {
|
||||||
|
enableMobileRegister: boolean
|
||||||
|
version: string
|
||||||
|
year: string
|
||||||
|
allowUserRegister: boolean
|
||||||
|
mobileAreaList: Array<{
|
||||||
|
name: string
|
||||||
|
key: string
|
||||||
|
}>
|
||||||
|
beianIcpNum: string
|
||||||
|
beianGaNum: string
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户信息
|
||||||
|
export function getUserInfo() {
|
||||||
|
return http.Get<UserInfo>('/user/info', {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取公共配置
|
||||||
|
export function getPublicConfig() {
|
||||||
|
return http.Get<PublicConfig>('/user/pub-config', {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: true,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注册数据类型
|
||||||
|
export interface RegisterData {
|
||||||
|
username: string
|
||||||
|
password: string
|
||||||
|
confirmPassword: string
|
||||||
|
captcha: string
|
||||||
|
captchaId: string
|
||||||
|
areaCode: string
|
||||||
|
mobile: string
|
||||||
|
mobileCaptcha: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送短信验证码
|
||||||
|
export function sendSmsCode(data: {
|
||||||
|
phone: string
|
||||||
|
captcha: string
|
||||||
|
captchaId: string
|
||||||
|
}) {
|
||||||
|
return http.Post('/user/smsVerification', data, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: true,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户注册
|
||||||
|
export function register(data: RegisterData) {
|
||||||
|
return http.Post('/user/register', data, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: true,
|
||||||
|
toast: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import type {
|
||||||
|
ChatMessage,
|
||||||
|
ChatSessionsResponse,
|
||||||
|
GetSessionsParams,
|
||||||
|
} from './types'
|
||||||
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取聊天会话列表
|
||||||
|
* @param agentId 智能体ID
|
||||||
|
* @param params 分页参数
|
||||||
|
*/
|
||||||
|
export function getChatSessions(agentId: string, params: GetSessionsParams) {
|
||||||
|
return http.Get<ChatSessionsResponse>(`/agent/${agentId}/sessions`, {
|
||||||
|
params,
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取聊天记录详情
|
||||||
|
* @param agentId 智能体ID
|
||||||
|
* @param sessionId 会话ID
|
||||||
|
*/
|
||||||
|
export function getChatHistory(agentId: string, sessionId: string) {
|
||||||
|
return http.Get<ChatMessage[]>(`/agent/${agentId}/chat-history/${sessionId}`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取音频下载ID
|
||||||
|
* @param audioId 音频ID
|
||||||
|
*/
|
||||||
|
export function getAudioId(audioId: string) {
|
||||||
|
return http.Post<string>(`/agent/audio/${audioId}`, {}, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取音频播放地址
|
||||||
|
* @param downloadId 下载ID
|
||||||
|
*/
|
||||||
|
export function getAudioPlayUrl(downloadId: string) {
|
||||||
|
// 根据需求文档,这个是直接返回二进制的,所以我们直接构造URL
|
||||||
|
return `/agent/play/${downloadId}`
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './chat-history'
|
||||||
|
export * from './types'
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// 聊天会话列表项
|
||||||
|
export interface ChatSession {
|
||||||
|
sessionId: string
|
||||||
|
createdAt: string
|
||||||
|
chatCount: number
|
||||||
|
}
|
||||||
|
|
||||||
|
// 聊天会话列表响应
|
||||||
|
export interface ChatSessionsResponse {
|
||||||
|
total: number
|
||||||
|
list: ChatSession[]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 聊天消息
|
||||||
|
export interface ChatMessage {
|
||||||
|
createdAt: string
|
||||||
|
chatType: 1 | 2 // 1是用户,2是AI
|
||||||
|
content: string
|
||||||
|
audioId: string | null
|
||||||
|
macAddress: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户消息内容(需要解析JSON)
|
||||||
|
export interface UserMessageContent {
|
||||||
|
speaker: string
|
||||||
|
content: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取聊天会话列表参数
|
||||||
|
export interface GetSessionsParams {
|
||||||
|
page: number
|
||||||
|
limit: number
|
||||||
|
}
|
||||||
|
|
||||||
|
// 音频播放相关
|
||||||
|
export interface AudioResponse {
|
||||||
|
data: string // 音频下载ID
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import type { Device, FirmwareType } from './types'
|
||||||
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备类型列表
|
||||||
|
*/
|
||||||
|
export function getFirmwareTypes() {
|
||||||
|
return http.Get<FirmwareType[]>('/admin/dict/data/type/FIRMWARE_TYPE')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取绑定设备列表
|
||||||
|
* @param agentId 智能体ID
|
||||||
|
*/
|
||||||
|
export function getBindDevices(agentId: string) {
|
||||||
|
return http.Get<Device[]>(`/device/bind/${agentId}`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加设备
|
||||||
|
* @param agentId 智能体ID
|
||||||
|
* @param code 验证码
|
||||||
|
*/
|
||||||
|
export function bindDevice(agentId: string, code: string) {
|
||||||
|
return http.Post(`/device/bind/${agentId}/${code}`, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置设备OTA升级开关
|
||||||
|
* @param deviceId 设备ID (MAC地址)
|
||||||
|
* @param autoUpdate 是否自动升级 0|1
|
||||||
|
*/
|
||||||
|
export function updateDeviceAutoUpdate(deviceId: string, autoUpdate: number) {
|
||||||
|
return http.Put(`/device/update/${deviceId}`, {
|
||||||
|
autoUpdate,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解绑设备
|
||||||
|
* @param deviceId 设备ID (MAC地址)
|
||||||
|
*/
|
||||||
|
export function unbindDevice(deviceId: string) {
|
||||||
|
return http.Post('/device/unbind', {
|
||||||
|
deviceId,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './device'
|
||||||
|
export * from './types'
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
export interface FirmwareType {
|
||||||
|
name: string
|
||||||
|
key: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Device {
|
||||||
|
id: string
|
||||||
|
userId: string
|
||||||
|
macAddress: string
|
||||||
|
lastConnectedAt: string
|
||||||
|
autoUpdate: number
|
||||||
|
board: string
|
||||||
|
alias?: string
|
||||||
|
agentId: string
|
||||||
|
appVersion: string
|
||||||
|
sort: number
|
||||||
|
updater?: string
|
||||||
|
updateDate: string
|
||||||
|
creator: string
|
||||||
|
createDate: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './types'
|
||||||
|
export * from './voiceprint'
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// 声纹信息响应类型
|
||||||
|
export interface VoicePrint {
|
||||||
|
id: string
|
||||||
|
audioId: string
|
||||||
|
sourceName: string
|
||||||
|
introduce: string
|
||||||
|
createDate: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 语音对话记录类型
|
||||||
|
export interface ChatHistory {
|
||||||
|
content: string
|
||||||
|
audioId: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建说话人数据类型
|
||||||
|
export interface CreateSpeakerData {
|
||||||
|
agentId: string
|
||||||
|
audioId: string
|
||||||
|
sourceName: string
|
||||||
|
introduce: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通用响应类型
|
||||||
|
export interface ApiResponse<T = any> {
|
||||||
|
code: number
|
||||||
|
msg: string
|
||||||
|
data: T
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import type {
|
||||||
|
ChatHistory,
|
||||||
|
CreateSpeakerData,
|
||||||
|
VoicePrint,
|
||||||
|
} from './types'
|
||||||
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
|
// 获取声纹列表
|
||||||
|
export function getVoicePrintList(agentId: string) {
|
||||||
|
return http.Get<VoicePrint[]>(`/agent/voice-print/list/${agentId}`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取语音对话记录(用于选择声纹向量)
|
||||||
|
export function getChatHistory(agentId: string) {
|
||||||
|
return http.Get<ChatHistory[]>(`/agent/${agentId}/chat-history/user`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: false,
|
||||||
|
},
|
||||||
|
cacheFor: {
|
||||||
|
expire: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增说话人
|
||||||
|
export function createVoicePrint(data: CreateSpeakerData) {
|
||||||
|
return http.Post<null>('/agent/voice-print', data, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除声纹
|
||||||
|
export function deleteVoicePrint(id: string) {
|
||||||
|
return http.Delete<null>(`/agent/voice-print/${id}`, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新声纹信息
|
||||||
|
export function updateVoicePrint(data: VoicePrint) {
|
||||||
|
return http.Put<null>('/agent/voice-print', data, {
|
||||||
|
meta: {
|
||||||
|
ignoreAuth: false,
|
||||||
|
toast: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
interface TabItem {
|
||||||
|
label: string
|
||||||
|
value: string | number
|
||||||
|
icon: string
|
||||||
|
activeIcon: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
tabList: TabItem[]
|
||||||
|
modelValue?: string | number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Emits {
|
||||||
|
(e: 'update:modelValue', value: string | number): void
|
||||||
|
(e: 'change', item: TabItem, index: number): void
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
modelValue: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits<Emits>()
|
||||||
|
|
||||||
|
const activeValue = computed(() => {
|
||||||
|
return props.modelValue || (props.tabList[0]?.value ?? '')
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleTabClick(item: TabItem, index: number) {
|
||||||
|
emit('update:modelValue', item.value)
|
||||||
|
emit('change', item, index)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="custom-tabs">
|
||||||
|
<view
|
||||||
|
v-for="(item, index) in tabList"
|
||||||
|
:key="item.value"
|
||||||
|
class="tab-item"
|
||||||
|
:class="{ active: activeValue === item.value }"
|
||||||
|
@click="handleTabClick(item, index)"
|
||||||
|
>
|
||||||
|
<view class="tab-icon">
|
||||||
|
<image
|
||||||
|
:src="activeValue === item.value ? item.activeIcon : item.icon"
|
||||||
|
class="icon-img"
|
||||||
|
mode="aspectFit"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="tab-text">
|
||||||
|
{{ item.label }}
|
||||||
|
</view>
|
||||||
|
<view v-if="activeValue === item.value" class="tab-indicator" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.custom-tabs {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-around;
|
||||||
|
background-color: #ffffff;
|
||||||
|
padding: 0 16rpx;
|
||||||
|
border-top: 1rpx solid #eeeeee;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-item {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 16rpx 12rpx 12rpx;
|
||||||
|
flex: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-icon {
|
||||||
|
width: 48rpx;
|
||||||
|
height: 48rpx;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-text {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #9d9ea3;
|
||||||
|
line-height: 1.2;
|
||||||
|
text-align: center;
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-item.active .tab-text {
|
||||||
|
color: #336cff;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-indicator {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 48rpx;
|
||||||
|
height: 4rpx;
|
||||||
|
background-color: #336cff;
|
||||||
|
border-radius: 2rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 适配不同尺寸屏幕 */
|
||||||
|
@media (max-width: 375px) {
|
||||||
|
.tab-text {
|
||||||
|
font-size: 22rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-icon {
|
||||||
|
width: 44rpx;
|
||||||
|
height: 44rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
/// <reference types="vite-svg-loader" />
|
||||||
|
|
||||||
|
declare module '*.vue' {
|
||||||
|
import type { DefineComponent } from 'vue'
|
||||||
|
|
||||||
|
const component: DefineComponent<{}, {}, any>
|
||||||
|
export default component
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
/** 网站标题,应用名称 */
|
||||||
|
readonly VITE_APP_TITLE: string
|
||||||
|
/** 服务端口号 */
|
||||||
|
readonly VITE_SERVER_PORT: string
|
||||||
|
/** 后台接口地址 */
|
||||||
|
readonly VITE_SERVER_BASEURL: string
|
||||||
|
/** H5是否需要代理 */
|
||||||
|
readonly VITE_APP_PROXY: 'true' | 'false'
|
||||||
|
/** H5是否需要代理,需要的话有个前缀 */
|
||||||
|
readonly VITE_APP_PROXY_PREFIX: string // 一般是/api
|
||||||
|
/** 上传图片地址 */
|
||||||
|
readonly VITE_UPLOAD_BASEURL: string
|
||||||
|
/** 是否清除console */
|
||||||
|
readonly VITE_DELETE_CONSOLE: string
|
||||||
|
// 更多环境变量...
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv
|
||||||
|
}
|
||||||
|
|
||||||
|
declare const __VITE_APP_PROXY__: 'true' | 'false'
|
||||||
|
declare const __UNI_PLATFORM__: 'app' | 'h5' | 'mp-alipay' | 'mp-baidu' | 'mp-kuaishou' | 'mp-lark' | 'mp-qq' | 'mp-tiktok' | 'mp-weixin' | 'mp-xiaochengxu'
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
|
import { useUserStore } from '@/store'
|
||||||
|
import { needLoginPages as _needLoginPages, getNeedLoginPages } from '@/utils'
|
||||||
|
|
||||||
|
const loginRoute = import.meta.env.VITE_LOGIN_URL
|
||||||
|
const isDev = import.meta.env.DEV
|
||||||
|
function isLogined() {
|
||||||
|
const userStore = useUserStore()
|
||||||
|
return !!userStore.userInfo.username
|
||||||
|
}
|
||||||
|
// 检查当前页面是否需要登录
|
||||||
|
export function usePageAuth() {
|
||||||
|
onLoad((options) => {
|
||||||
|
// 获取当前页面路径
|
||||||
|
const pages = getCurrentPages()
|
||||||
|
const currentPage = pages[pages.length - 1]
|
||||||
|
const currentPath = `/${currentPage.route}`
|
||||||
|
|
||||||
|
// 获取需要登录的页面列表
|
||||||
|
let needLoginPages: string[] = []
|
||||||
|
if (isDev) {
|
||||||
|
needLoginPages = getNeedLoginPages()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
needLoginPages = _needLoginPages
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查当前页面是否需要登录
|
||||||
|
const isNeedLogin = needLoginPages.includes(currentPath)
|
||||||
|
if (!isNeedLogin) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasLogin = isLogined()
|
||||||
|
if (hasLogin) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建重定向URL
|
||||||
|
const queryString = Object.entries(options || {})
|
||||||
|
.map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
|
||||||
|
.join('&')
|
||||||
|
|
||||||
|
const currentFullPath = queryString ? `${currentPath}?${queryString}` : currentPath
|
||||||
|
const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(currentFullPath)}`
|
||||||
|
|
||||||
|
// 重定向到登录页
|
||||||
|
uni.redirectTo({ url: redirectRoute })
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import type { Ref } from 'vue'
|
||||||
|
|
||||||
|
interface IUseRequestOptions<T> {
|
||||||
|
/** 是否立即执行 */
|
||||||
|
immediate?: boolean
|
||||||
|
/** 初始化数据 */
|
||||||
|
initialData?: T
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IUseRequestReturn<T> {
|
||||||
|
loading: Ref<boolean>
|
||||||
|
error: Ref<boolean | Error>
|
||||||
|
data: Ref<T | undefined>
|
||||||
|
run: () => Promise<T | undefined>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* useRequest是一个定制化的请求钩子,用于处理异步请求和响应。
|
||||||
|
* @param func 一个执行异步请求的函数,返回一个包含响应数据的Promise。
|
||||||
|
* @param options 包含请求选项的对象 {immediate, initialData}。
|
||||||
|
* @param options.immediate 是否立即执行请求,默认为false。
|
||||||
|
* @param options.initialData 初始化数据,默认为undefined。
|
||||||
|
* @returns 返回一个对象{loading, error, data, run},包含请求的加载状态、错误信息、响应数据和手动触发请求的函数。
|
||||||
|
*/
|
||||||
|
export default function useRequest<T>(
|
||||||
|
func: () => Promise<IResData<T>>,
|
||||||
|
options: IUseRequestOptions<T> = { immediate: false },
|
||||||
|
): IUseRequestReturn<T> {
|
||||||
|
const loading = ref(false)
|
||||||
|
const error = ref(false)
|
||||||
|
const data = ref<T | undefined>(options.initialData) as Ref<T | undefined>
|
||||||
|
const run = async () => {
|
||||||
|
loading.value = true
|
||||||
|
return func()
|
||||||
|
.then((res) => {
|
||||||
|
data.value = res.data
|
||||||
|
error.value = false
|
||||||
|
return data.value
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
error.value = err
|
||||||
|
throw err
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
options.immediate && run()
|
||||||
|
return { loading, error, data, run }
|
||||||
|
}
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { getEnvBaseUploadUrl } from '@/utils'
|
||||||
|
|
||||||
|
const VITE_UPLOAD_BASEURL = `${getEnvBaseUploadUrl()}`
|
||||||
|
|
||||||
|
type TfileType = 'image' | 'file'
|
||||||
|
type TImage = 'png' | 'jpg' | 'jpeg' | 'webp' | '*'
|
||||||
|
type TFile = 'doc' | 'docx' | 'ppt' | 'zip' | 'xls' | 'xlsx' | 'txt' | TImage
|
||||||
|
|
||||||
|
interface TOptions<T extends TfileType> {
|
||||||
|
formData?: Record<string, any>
|
||||||
|
maxSize?: number
|
||||||
|
accept?: T extends 'image' ? TImage[] : TFile[]
|
||||||
|
fileType?: T
|
||||||
|
success?: (params: any) => void
|
||||||
|
error?: (err: any) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function useUpload<T extends TfileType>(options: TOptions<T> = {} as TOptions<T>) {
|
||||||
|
const {
|
||||||
|
formData = {},
|
||||||
|
maxSize = 5 * 1024 * 1024,
|
||||||
|
accept = ['*'],
|
||||||
|
fileType = 'image',
|
||||||
|
success,
|
||||||
|
error: onError,
|
||||||
|
} = options
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const error = ref<Error | null>(null)
|
||||||
|
const data = ref<any>(null)
|
||||||
|
|
||||||
|
const handleFileChoose = ({ tempFilePath, size }: { tempFilePath: string, size: number }) => {
|
||||||
|
if (size > maxSize) {
|
||||||
|
uni.showToast({
|
||||||
|
title: `文件大小不能超过 ${maxSize / 1024 / 1024}MB`,
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// const fileExtension = file?.tempFiles?.name?.split('.').pop()?.toLowerCase()
|
||||||
|
// const isTypeValid = accept.some((type) => type === '*' || type.toLowerCase() === fileExtension)
|
||||||
|
|
||||||
|
// if (!isTypeValid) {
|
||||||
|
// uni.showToast({
|
||||||
|
// title: `仅支持 ${accept.join(', ')} 格式的文件`,
|
||||||
|
// icon: 'none',
|
||||||
|
// })
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
uploadFile({
|
||||||
|
tempFilePath,
|
||||||
|
formData,
|
||||||
|
onSuccess: (res) => {
|
||||||
|
const { data: _data } = JSON.parse(res)
|
||||||
|
data.value = _data
|
||||||
|
// console.log('上传成功', res)
|
||||||
|
success?.(_data)
|
||||||
|
},
|
||||||
|
onError: (err) => {
|
||||||
|
error.value = err
|
||||||
|
onError?.(err)
|
||||||
|
},
|
||||||
|
onComplete: () => {
|
||||||
|
loading.value = false
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const run = () => {
|
||||||
|
// 微信小程序从基础库 2.21.0 开始, wx.chooseImage 停止维护,请使用 uni.chooseMedia 代替。
|
||||||
|
// 微信小程序在2023年10月17日之后,使用本API需要配置隐私协议
|
||||||
|
const chooseFileOptions = {
|
||||||
|
count: 1,
|
||||||
|
success: (res: any) => {
|
||||||
|
console.log('File selected successfully:', res)
|
||||||
|
// 小程序中res:{errMsg: "chooseImage:ok", tempFiles: [{fileType: "image", size: 48976, tempFilePath: "http://tmp/5iG1WpIxTaJf3ece38692a337dc06df7eb69ecb49c6b.jpeg"}]}
|
||||||
|
// h5中res:{errMsg: "chooseImage:ok", tempFilePaths: "blob:http://localhost:9000/f74ab6b8-a14d-4cb6-a10d-fcf4511a0de5", tempFiles: [File]}
|
||||||
|
// h5的File有以下字段:{name: "girl.jpeg", size: 48976, type: "image/jpeg"}
|
||||||
|
// App中res:{errMsg: "chooseImage:ok", tempFilePaths: "file:///Users/feige/xxx/gallery/1522437259-compressed-IMG_0006.jpg", tempFiles: [File]}
|
||||||
|
// App的File有以下字段:{path: "file:///Users/feige/xxx/gallery/1522437259-compressed-IMG_0006.jpg", size: 48976}
|
||||||
|
let tempFilePath = ''
|
||||||
|
let size = 0
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
tempFilePath = res.tempFiles[0].tempFilePath
|
||||||
|
size = res.tempFiles[0].size
|
||||||
|
// #endif
|
||||||
|
// #ifndef MP-WEIXIN
|
||||||
|
tempFilePath = res.tempFilePaths[0]
|
||||||
|
size = res.tempFiles[0].size
|
||||||
|
// #endif
|
||||||
|
handleFileChoose({ tempFilePath, size })
|
||||||
|
},
|
||||||
|
fail: (err: any) => {
|
||||||
|
console.error('File selection failed:', err)
|
||||||
|
error.value = err
|
||||||
|
onError?.(err)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileType === 'image') {
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
uni.chooseMedia({
|
||||||
|
...chooseFileOptions,
|
||||||
|
mediaType: ['image'],
|
||||||
|
})
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifndef MP-WEIXIN
|
||||||
|
uni.chooseImage(chooseFileOptions)
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uni.chooseFile({
|
||||||
|
...chooseFileOptions,
|
||||||
|
type: 'all',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { loading, error, data, run }
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uploadFile({
|
||||||
|
tempFilePath,
|
||||||
|
formData,
|
||||||
|
onSuccess,
|
||||||
|
onError,
|
||||||
|
onComplete,
|
||||||
|
}: {
|
||||||
|
tempFilePath: string
|
||||||
|
formData: Record<string, any>
|
||||||
|
onSuccess: (data: any) => void
|
||||||
|
onError: (err: any) => void
|
||||||
|
onComplete: () => void
|
||||||
|
}) {
|
||||||
|
uni.uploadFile({
|
||||||
|
url: VITE_UPLOAD_BASEURL,
|
||||||
|
filePath: tempFilePath,
|
||||||
|
name: 'file',
|
||||||
|
formData,
|
||||||
|
success: (uploadFileRes) => {
|
||||||
|
try {
|
||||||
|
const data = uploadFileRes.data
|
||||||
|
onSuccess(data)
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
onError(err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('Upload failed:', err)
|
||||||
|
onError(err)
|
||||||
|
},
|
||||||
|
complete: onComplete,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# 请求库
|
||||||
|
|
||||||
|
当前项目使用 Alova 作为唯一的 HTTP 请求库:
|
||||||
|
|
||||||
|
## 使用方式
|
||||||
|
|
||||||
|
- **Alova HTTP**:路径(src/http/request/alova.ts)
|
||||||
|
- **示例代码**:src/api/foo-alova.ts 和 src/api/foo.ts
|
||||||
|
- **API文档**:https://alova.js.org/
|
||||||
|
|
||||||
|
## 配置说明
|
||||||
|
|
||||||
|
Alova 实例已配置:
|
||||||
|
- 自动 Token 认证和刷新
|
||||||
|
- 统一错误处理和提示
|
||||||
|
- 支持动态域名切换
|
||||||
|
- 内置请求/响应拦截器
|
||||||
|
|
||||||
|
## 使用示例
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
|
// GET 请求
|
||||||
|
http.Get<ResponseType>('/api/path', {
|
||||||
|
params: { id: 1 },
|
||||||
|
headers: { 'Custom-Header': 'value' },
|
||||||
|
meta: { toast: false } // 关闭错误提示
|
||||||
|
})
|
||||||
|
|
||||||
|
// POST 请求
|
||||||
|
http.Post<ResponseType>('/api/path', data, {
|
||||||
|
params: { query: 'param' },
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
})
|
||||||
|
```
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
import type { uniappRequestAdapter } from '@alova/adapter-uniapp'
|
||||||
|
import type { IResponse } from './types'
|
||||||
|
import AdapterUniapp from '@alova/adapter-uniapp'
|
||||||
|
import { createAlova } from 'alova'
|
||||||
|
import { createServerTokenAuthentication } from 'alova/client'
|
||||||
|
import VueHook from 'alova/vue'
|
||||||
|
import { getEnvBaseUrl } from '@/utils'
|
||||||
|
import { toast } from '@/utils/toast'
|
||||||
|
import { ContentTypeEnum, ResultEnum, ShowMessage } from './enum'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建请求实例
|
||||||
|
*/
|
||||||
|
const { onAuthRequired, onResponseRefreshToken } = createServerTokenAuthentication<
|
||||||
|
typeof VueHook,
|
||||||
|
typeof uniappRequestAdapter
|
||||||
|
>({
|
||||||
|
refreshTokenOnError: {
|
||||||
|
isExpired: (error) => {
|
||||||
|
return error.response?.status === ResultEnum.Unauthorized
|
||||||
|
},
|
||||||
|
handler: async () => {
|
||||||
|
try {
|
||||||
|
// await authLogin();
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
// 切换到登录页
|
||||||
|
await uni.reLaunch({ url: '/pages/login/index' })
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* alova 请求实例
|
||||||
|
*/
|
||||||
|
const alovaInstance = createAlova({
|
||||||
|
baseURL: getEnvBaseUrl(),
|
||||||
|
...AdapterUniapp(),
|
||||||
|
timeout: 5000,
|
||||||
|
statesHook: VueHook,
|
||||||
|
|
||||||
|
beforeRequest: onAuthRequired((method) => {
|
||||||
|
// 设置默认 Content-Type
|
||||||
|
method.config.headers = {
|
||||||
|
'Content-Type': ContentTypeEnum.JSON,
|
||||||
|
'Accept': 'application/json, text/plain, */*',
|
||||||
|
...method.config.headers,
|
||||||
|
}
|
||||||
|
|
||||||
|
const { config } = method
|
||||||
|
const ignoreAuth = config.meta?.ignoreAuth
|
||||||
|
console.log('ignoreAuth===>', ignoreAuth)
|
||||||
|
|
||||||
|
// 处理认证信息
|
||||||
|
if (!ignoreAuth) {
|
||||||
|
const token = uni.getStorageSync('token')
|
||||||
|
if (!token) {
|
||||||
|
// 跳转到登录页
|
||||||
|
uni.reLaunch({ url: '/pages/login/index' })
|
||||||
|
throw new Error('[请求错误]:未登录')
|
||||||
|
}
|
||||||
|
// 添加 Authorization 头
|
||||||
|
method.config.headers.Authorization = `Bearer ${token}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理动态域名
|
||||||
|
if (config.meta?.domain) {
|
||||||
|
method.baseURL = config.meta.domain
|
||||||
|
console.log('当前域名', method.baseURL)
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
responded: onResponseRefreshToken((response, method) => {
|
||||||
|
const { config } = method
|
||||||
|
const { requestType } = config
|
||||||
|
const {
|
||||||
|
statusCode,
|
||||||
|
data: rawData,
|
||||||
|
errMsg,
|
||||||
|
} = response as UniNamespace.RequestSuccessCallbackResult
|
||||||
|
|
||||||
|
console.log(response)
|
||||||
|
|
||||||
|
// 处理特殊请求类型(上传/下载)
|
||||||
|
if (requestType === 'upload' || requestType === 'download') {
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理 HTTP 状态码错误
|
||||||
|
if (statusCode !== 200) {
|
||||||
|
const errorMessage = ShowMessage(statusCode) || `HTTP请求错误[${statusCode}]`
|
||||||
|
console.error('errorMessage===>', errorMessage)
|
||||||
|
toast.error(errorMessage)
|
||||||
|
throw new Error(`${errorMessage}:${errMsg}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理业务逻辑错误
|
||||||
|
const { code, msg, data } = rawData as IResponse
|
||||||
|
if (code !== ResultEnum.Success) {
|
||||||
|
// 检查是否为token失效
|
||||||
|
if (code === ResultEnum.Unauthorized) {
|
||||||
|
// 清除token并跳转到登录页
|
||||||
|
uni.removeStorageSync('token')
|
||||||
|
uni.reLaunch({ url: '/pages/login/index' })
|
||||||
|
throw new Error(`请求错误[${code}]:${msg}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.meta?.toast !== false) {
|
||||||
|
toast.warning(msg)
|
||||||
|
}
|
||||||
|
throw new Error(`请求错误[${code}]:${msg}`)
|
||||||
|
}
|
||||||
|
// 处理成功响应,返回业务数据
|
||||||
|
return data
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const http = alovaInstance
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
export enum ResultEnum {
|
||||||
|
Success = 0, // 成功
|
||||||
|
Error = 400, // 错误
|
||||||
|
Unauthorized = 401, // 未授权
|
||||||
|
Forbidden = 403, // 禁止访问(原为forbidden)
|
||||||
|
NotFound = 404, // 未找到(原为notFound)
|
||||||
|
MethodNotAllowed = 405, // 方法不允许(原为methodNotAllowed)
|
||||||
|
RequestTimeout = 408, // 请求超时(原为requestTimeout)
|
||||||
|
InternalServerError = 500, // 服务器错误(原为internalServerError)
|
||||||
|
NotImplemented = 501, // 未实现(原为notImplemented)
|
||||||
|
BadGateway = 502, // 网关错误(原为badGateway)
|
||||||
|
ServiceUnavailable = 503, // 服务不可用(原为serviceUnavailable)
|
||||||
|
GatewayTimeout = 504, // 网关超时(原为gatewayTimeout)
|
||||||
|
HttpVersionNotSupported = 505, // HTTP版本不支持(原为httpVersionNotSupported)
|
||||||
|
}
|
||||||
|
export enum ContentTypeEnum {
|
||||||
|
JSON = 'application/json;charset=UTF-8',
|
||||||
|
FORM_URLENCODED = 'application/x-www-form-urlencoded;charset=UTF-8',
|
||||||
|
FORM_DATA = 'multipart/form-data;charset=UTF-8',
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 根据状态码,生成对应的错误信息
|
||||||
|
* @param {number|string} status 状态码
|
||||||
|
* @returns {string} 错误信息
|
||||||
|
*/
|
||||||
|
export function ShowMessage(status: number | string): string {
|
||||||
|
let message: string
|
||||||
|
switch (status) {
|
||||||
|
case 400:
|
||||||
|
message = '请求错误(400)'
|
||||||
|
break
|
||||||
|
case 401:
|
||||||
|
message = '未授权,请重新登录(401)'
|
||||||
|
break
|
||||||
|
case 403:
|
||||||
|
message = '拒绝访问(403)'
|
||||||
|
break
|
||||||
|
case 404:
|
||||||
|
message = '请求出错(404)'
|
||||||
|
break
|
||||||
|
case 408:
|
||||||
|
message = '请求超时(408)'
|
||||||
|
break
|
||||||
|
case 500:
|
||||||
|
message = '服务器错误(500)'
|
||||||
|
break
|
||||||
|
case 501:
|
||||||
|
message = '服务未实现(501)'
|
||||||
|
break
|
||||||
|
case 502:
|
||||||
|
message = '网络错误(502)'
|
||||||
|
break
|
||||||
|
case 503:
|
||||||
|
message = '服务不可用(503)'
|
||||||
|
break
|
||||||
|
case 504:
|
||||||
|
message = '网络超时(504)'
|
||||||
|
break
|
||||||
|
case 505:
|
||||||
|
message = 'HTTP版本不受支持(505)'
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
message = `连接出错(${status})!`
|
||||||
|
}
|
||||||
|
return `${message},请检查网络或联系管理员!`
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// 通用响应格式
|
||||||
|
export interface IResponse<T = any> {
|
||||||
|
code: number | string
|
||||||
|
data: T
|
||||||
|
msg: string
|
||||||
|
status: string | number
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页请求参数
|
||||||
|
export interface PageParams {
|
||||||
|
page: number
|
||||||
|
pageSize: number
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页响应数据
|
||||||
|
export interface PageResult<T> {
|
||||||
|
list: T[]
|
||||||
|
total: number
|
||||||
|
page: number
|
||||||
|
pageSize: number
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ConfigProviderThemeVars } from 'wot-design-uni'
|
||||||
|
|
||||||
|
const themeVars: ConfigProviderThemeVars = {
|
||||||
|
// colorTheme: 'red',
|
||||||
|
// buttonPrimaryBgColor: '#07c160',
|
||||||
|
// buttonPrimaryColor: '#07c160',
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<wd-config-provider :theme-vars="themeVars">
|
||||||
|
<slot />
|
||||||
|
<wd-toast />
|
||||||
|
<wd-message-box />
|
||||||
|
</wd-config-provider>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { tabbarStore } from './tabbar'
|
||||||
|
// 'i-carbon-code',
|
||||||
|
import { tabbarList as _tabBarList, cacheTabbarEnable, selectedTabbarStrategy, TABBAR_MAP } from './tabbarList'
|
||||||
|
|
||||||
|
const customTabbarEnable
|
||||||
|
= selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE
|
||||||
|
|| selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITHOUT_CACHE
|
||||||
|
|
||||||
|
/** tabbarList 里面的 path 从 pages.config.ts 得到 */
|
||||||
|
const tabbarList = _tabBarList.map(item => ({ ...item, path: `/${item.pagePath}` }))
|
||||||
|
function selectTabBar({ value: index }: { value: number }) {
|
||||||
|
const url = tabbarList[index].path
|
||||||
|
tabbarStore.setCurIdx(index)
|
||||||
|
if (cacheTabbarEnable) {
|
||||||
|
uni.switchTab({ url })
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uni.navigateTo({ url })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onLoad(() => {
|
||||||
|
// 解决原生 tabBar 未隐藏导致有2个 tabBar 的问题
|
||||||
|
const hideRedundantTabbarEnable = selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE
|
||||||
|
hideRedundantTabbarEnable
|
||||||
|
&& uni.hideTabBar({
|
||||||
|
fail(err) {
|
||||||
|
console.log('hideTabBar fail: ', err)
|
||||||
|
},
|
||||||
|
success(res) {
|
||||||
|
console.log('hideTabBar success: ', res)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<wd-tabbar
|
||||||
|
v-if="customTabbarEnable"
|
||||||
|
v-model="tabbarStore.curIdx"
|
||||||
|
bordered
|
||||||
|
safe-area-inset-bottom
|
||||||
|
placeholder
|
||||||
|
fixed
|
||||||
|
@change="selectTabBar"
|
||||||
|
>
|
||||||
|
<block v-for="(item, idx) in tabbarList" :key="item.path">
|
||||||
|
<wd-tabbar-item v-if="item.iconType === 'uiLib'" :title="item.text" :icon="item.icon" />
|
||||||
|
<wd-tabbar-item
|
||||||
|
v-else-if="item.iconType === 'unocss' || item.iconType === 'iconfont'"
|
||||||
|
:title="item.text"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<view
|
||||||
|
h-40rpx
|
||||||
|
w-40rpx
|
||||||
|
:class="[item.icon, idx === tabbarStore.curIdx ? 'is-active' : 'is-inactive']"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</wd-tabbar-item>
|
||||||
|
<wd-tabbar-item v-else-if="item.iconType === 'local'" :title="item.text">
|
||||||
|
<template #icon>
|
||||||
|
<image :src="item.icon" h-40rpx w-40rpx />
|
||||||
|
</template>
|
||||||
|
</wd-tabbar-item>
|
||||||
|
</block>
|
||||||
|
</wd-tabbar>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# tabbar 说明
|
||||||
|
|
||||||
|
`tabbar` 分为 `4 种` 情况:
|
||||||
|
|
||||||
|
- 0 `无 tabbar`,只有一个页面入口,底部无 `tabbar` 显示;常用语临时活动页。
|
||||||
|
- 1 `原生 tabbar`,使用 `switchTab` 切换 tabbar,`tabbar` 页面有缓存。
|
||||||
|
- 优势:原生自带的 tabbar,最先渲染,有缓存。
|
||||||
|
- 劣势:只能使用 2 组图片来切换选中和非选中状态,修改颜色只能重新换图片(或者用 iconfont)。
|
||||||
|
- 2 `有缓存自定义 tabbar`,使用 `switchTab` 切换 tabbar,`tabbar` 页面有缓存。使用了第三方 UI 库的 `tabbar` 组件,并隐藏了原生 `tabbar` 的显示。
|
||||||
|
- 优势:可以随意配置自己想要的 `svg icon`,切换字体颜色方便。有缓存。可以实现各种花里胡哨的动效等。
|
||||||
|
- 劣势:首次点击 tababr 会闪烁。
|
||||||
|
- 3 `无缓存自定义 tabbar`,使用 `navigateTo` 切换 `tabbar`,`tabbar` 页面无缓存。使用了第三方 UI 库的 `tabbar` 组件。
|
||||||
|
- 优势:可以随意配置自己想要的 svg icon,切换字体颜色方便。可以实现各种花里胡哨的动效等。
|
||||||
|
- 劣势:首次点击 `tababr` 会闪烁,无缓存。
|
||||||
|
|
||||||
|
|
||||||
|
> 注意:花里胡哨的效果需要自己实现,本模版不提供。
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* tabbar 状态,增加 storageSync 保证刷新浏览器时在正确的 tabbar 页面
|
||||||
|
* 使用reactive简单状态,而不是 pinia 全局状态
|
||||||
|
*/
|
||||||
|
export const tabbarStore = reactive({
|
||||||
|
curIdx: uni.getStorageSync('app-tabbar-index') || 0,
|
||||||
|
setCurIdx(idx: number) {
|
||||||
|
this.curIdx = idx
|
||||||
|
uni.setStorageSync('app-tabbar-index', idx)
|
||||||
|
},
|
||||||
|
})
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import type { TabBar } from '@uni-helper/vite-plugin-uni-pages'
|
||||||
|
|
||||||
|
type FgTabBarItem = TabBar['list'][0] & {
|
||||||
|
icon: string
|
||||||
|
iconType: 'uiLib' | 'unocss' | 'iconfont'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tabbar 选择的策略,更详细的介绍见 tabbar.md 文件
|
||||||
|
* 0: 'NO_TABBAR' `无 tabbar`
|
||||||
|
* 1: 'NATIVE_TABBAR' `完全原生 tabbar`
|
||||||
|
* 2: 'CUSTOM_TABBAR_WITH_CACHE' `有缓存自定义 tabbar`
|
||||||
|
* 3: 'CUSTOM_TABBAR_WITHOUT_CACHE' `无缓存自定义 tabbar`
|
||||||
|
*
|
||||||
|
* 温馨提示:本文件的任何代码更改了之后,都需要重新运行,否则 pages.json 不会更新导致错误
|
||||||
|
*/
|
||||||
|
export const TABBAR_MAP = {
|
||||||
|
NO_TABBAR: 0,
|
||||||
|
NATIVE_TABBAR: 1,
|
||||||
|
CUSTOM_TABBAR_WITH_CACHE: 2,
|
||||||
|
CUSTOM_TABBAR_WITHOUT_CACHE: 3,
|
||||||
|
}
|
||||||
|
// TODO:通过这里切换使用tabbar的策略
|
||||||
|
export const selectedTabbarStrategy = TABBAR_MAP.NATIVE_TABBAR
|
||||||
|
|
||||||
|
// selectedTabbarStrategy==NATIVE_TABBAR(1) 时,需要填 iconPath 和 selectedIconPath
|
||||||
|
// selectedTabbarStrategy==CUSTOM_TABBAR(2,3) 时,需要填 icon 和 iconType
|
||||||
|
// selectedTabbarStrategy==NO_TABBAR(0) 时,tabbarList 不生效
|
||||||
|
export const tabbarList: FgTabBarItem[] = [
|
||||||
|
{
|
||||||
|
iconPath: 'static/tabbar/robot.png',
|
||||||
|
selectedIconPath: 'static/tabbar/robot_activate.png',
|
||||||
|
pagePath: 'pages/index/index',
|
||||||
|
text: '首页',
|
||||||
|
icon: 'home',
|
||||||
|
// 选用 UI 框架自带的 icon 时,iconType 为 uiLib
|
||||||
|
iconType: 'uiLib',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
iconPath: 'static/tabbar/network.png',
|
||||||
|
selectedIconPath: 'static/tabbar/network_activate.png',
|
||||||
|
pagePath: 'pages/device-config/index',
|
||||||
|
text: '配网',
|
||||||
|
icon: 'i-carbon-network-3',
|
||||||
|
iconType: 'uiLib',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
iconPath: 'static/tabbar/system.png',
|
||||||
|
selectedIconPath: 'static/tabbar/system_activate.png',
|
||||||
|
pagePath: 'pages/settings/index',
|
||||||
|
text: '系统',
|
||||||
|
icon: 'i-carbon-settings',
|
||||||
|
iconType: 'uiLib',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
// NATIVE_TABBAR(1) 和 CUSTOM_TABBAR_WITH_CACHE(2) 时,需要tabbar缓存
|
||||||
|
export const cacheTabbarEnable = selectedTabbarStrategy === TABBAR_MAP.NATIVE_TABBAR
|
||||||
|
|| selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE
|
||||||
|
|
||||||
|
const _tabbar: TabBar = {
|
||||||
|
// 只有微信小程序支持 custom。App 和 H5 不生效
|
||||||
|
custom: selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE,
|
||||||
|
color: '#e6e6e6',
|
||||||
|
selectedColor: '#667dea',
|
||||||
|
backgroundColor: '#fff',
|
||||||
|
borderStyle: 'black',
|
||||||
|
height: '50px',
|
||||||
|
fontSize: '10px',
|
||||||
|
iconWidth: '24px',
|
||||||
|
spacing: '3px',
|
||||||
|
list: tabbarList as unknown as TabBar['list'],
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0和1 需要显示底部的tabbar的各种配置,以利用缓存
|
||||||
|
export const tabBar = cacheTabbarEnable ? _tabbar : undefined
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ConfigProviderThemeVars } from 'wot-design-uni'
|
||||||
|
import FgTabbar from './fg-tabbar/fg-tabbar.vue'
|
||||||
|
|
||||||
|
const themeVars: ConfigProviderThemeVars = {
|
||||||
|
// colorTheme: 'red',
|
||||||
|
// buttonPrimaryBgColor: '#07c160',
|
||||||
|
// buttonPrimaryColor: '#07c160',
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<wd-config-provider :theme-vars="themeVars">
|
||||||
|
<slot />
|
||||||
|
<FgTabbar />
|
||||||
|
<wd-toast />
|
||||||
|
<wd-message-box />
|
||||||
|
</wd-config-provider>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { VueQueryPlugin } from '@tanstack/vue-query'
|
||||||
|
import { createSSRApp } from 'vue'
|
||||||
|
import App from './App.vue'
|
||||||
|
import { routeInterceptor } from './router/interceptor'
|
||||||
|
|
||||||
|
import store from './store'
|
||||||
|
import '@/style/index.scss'
|
||||||
|
import 'virtual:uno.css'
|
||||||
|
|
||||||
|
export function createApp() {
|
||||||
|
const app = createSSRApp(App)
|
||||||
|
app.use(store)
|
||||||
|
app.use(routeInterceptor)
|
||||||
|
app.use(VueQueryPlugin)
|
||||||
|
|
||||||
|
return {
|
||||||
|
app,
|
||||||
|
}
|
||||||
|
}
|
||||||