diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5f5aca --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# Models (too large for git) +backend/main/xiaozhi-server/models/ +backend/main/xiaozhi-server/test/ +backend/main/xiaozhi-server/tmp/ +backend/main/xiaozhi-server/music/ + +# Frontend build artifacts +frontend/build/ +frontend/managed_components/ + +# Python +__pycache__/ +*.pyc +*.pyo +.venv/ +venv/ + +# IDE +.idea/ +.vscode/ +*.swp + +# OS +.DS_Store +Thumbs.db + +# Config with secrets +backend/main/xiaozhi-server/data/.config.yaml diff --git a/backend/Dockerfile-server b/backend/Dockerfile-server new file mode 100644 index 0000000..9df93c9 --- /dev/null +++ b/backend/Dockerfile-server @@ -0,0 +1,7 @@ +# 生产镜像,仅包含应用代码 +FROM ghcr.io/xinnan-tech/xiaozhi-esp32-server:server-base + +COPY main/xiaozhi-server . + +# 启动应用 +CMD ["python", "app.py"] \ No newline at end of file diff --git a/backend/Dockerfile-server-base b/backend/Dockerfile-server-base new file mode 100644 index 0000000..70429ab --- /dev/null +++ b/backend/Dockerfile-server-base @@ -0,0 +1,32 @@ +# Dockerfile-server-base +# 基础镜像,包含系统依赖和Python包 +FROM python:3.10-slim + +# 安装系统依赖 +RUN apt-get update && \ + apt-get install -y --no-install-recommends libopus0 ffmpeg locales && \ + sed -i '/zh_CN.UTF-8/s/^# //g' /etc/locale.gen && \ + locale-gen && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# 配置pip使用国内镜像源(阿里云)并设置超时和重试 +RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \ + pip config set global.trusted-host mirrors.aliyun.com && \ + pip config set global.timeout 120 && \ + pip config set install.retries 5 + +# 设置环境变量以确保正确的字符编码 +ENV LANG=zh_CN.UTF-8 \ + LC_ALL=zh_CN.UTF-8 \ + LANGUAGE=zh_CN:zh \ + PYTHONIOENCODING=utf-8 + +WORKDIR /opt/xiaozhi-esp32-server + +# 复制requirements.txt +COPY main/xiaozhi-server/requirements.txt . + +# 安装Python依赖 +RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \ + pip install --no-cache-dir -r requirements.txt --default-timeout=120 --retries 5 \ No newline at end of file diff --git a/backend/Dockerfile-server-cn b/backend/Dockerfile-server-cn new file mode 100644 index 0000000..91bcb48 --- /dev/null +++ b/backend/Dockerfile-server-cn @@ -0,0 +1,7 @@ +# 生产镜像,仅包含应用代码 +FROM ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:server-base + +COPY main/xiaozhi-server . + +# 启动应用 +CMD ["python", "app.py"] \ No newline at end of file diff --git a/backend/Dockerfile-web b/backend/Dockerfile-web new file mode 100644 index 0000000..fd0eb01 --- /dev/null +++ b/backend/Dockerfile-web @@ -0,0 +1,50 @@ +# 第一阶段:构建Vue前端 +FROM node:18 AS web-builder +WORKDIR /app +COPY main/manager-web/package*.json ./ +RUN npm install +COPY main/manager-web . +RUN npm run build + +# 第二阶段:构建Java后端 +FROM maven:3.9.4-eclipse-temurin-21 AS api-builder +WORKDIR /app +COPY main/manager-api/pom.xml . +COPY main/manager-api/src ./src +RUN mvn clean package -Dmaven.test.skip=true + +# 第三阶段:构建最终镜像 +FROM bellsoft/liberica-runtime-container:jre-21-glibc + +# 安装Nginx和字体库 +RUN apk update && \ + apk add --no-cache --no-scripts \ + nginx \ + bash \ + fontconfig \ + ttf-dejavu \ + && rm -rf /var/cache/apk/* \ + && mkdir -p /run/nginx /var/log/nginx /var/tmp/nginx /etc/nginx/conf.d + +# 复制项目自带的中文字体 +COPY main/manager-web/public/generator/static/fonts/*.ttf /usr/share/fonts/ + +# 更新字体缓存 +RUN fc-cache -f -v + +# 配置Nginx +COPY docs/docker/nginx.conf /etc/nginx/nginx.conf + +# 复制前端构建产物 +COPY --from=web-builder /app/dist /usr/share/nginx/html + +# 复制Java后端JAR包 +COPY --from=api-builder /app/target/xiaozhi-esp32-api.jar /app/xiaozhi-esp32-api.jar + +# 暴露端口 +EXPOSE 8002 + +# 启动脚本 +COPY docs/docker/start.sh /start.sh +RUN chmod +x /start.sh +CMD ["/start.sh"] \ No newline at end of file diff --git a/backend/LICENSE b/backend/LICENSE new file mode 100644 index 0000000..579a3d7 --- /dev/null +++ b/backend/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 xinnan-tech + +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. diff --git a/backend/README.md b/backend/README.md new file mode 100644 index 0000000..4360786 --- /dev/null +++ b/backend/README.md @@ -0,0 +1,378 @@ +[![Banners](docs/images/banner1.png)](https://github.com/xinnan-tech/xiaozhi-esp32-server) + +

小智后端服务xiaozhi-esp32-server

+ +

+本项目基于人机共生智能理论和技术研发智能终端软硬件体系
为开源智能硬件项目 +xiaozhi-esp32提供后端服务
+根据小智通信协议使用Python、Java、Vue实现
+支持MQTT+UDP协议、Websocket协议、MCP接入点、声纹识别、知识库 +

+ +

+常见问题反馈问题部署文档更新日志 +

+ +

+ 简体中文版自述文件 + README in English + Tiếng Việt + Deutsch + Português (Brasil) + + GitHub Contributors + + + GitHub pull requests + + + stars + +

+ +

+Spearheaded by Professor Siyuan Liu's Team (South China University of Technology) +
+刘思源教授团队主导研发(华南理工大学) +
+华南理工大学 +

+ +--- + +## 适用人群 👥 + +本项目需要配合 ESP32 硬件设备使用。如果您已经购买了 ESP32 相关硬件,且成功对接过虾哥部署的后端服务,并希望独立搭建自己的 +`xiaozhi-esp32` 后端服务,那么本项目非常适合您。 + +想看使用效果?请猛戳视频 🎥 + + + + + + + + + + + + + + + + + + + + + + + +
+ + + 响应速度感受 + + + + + + 速度优化秘诀 + + + + + + 复杂医疗场景 + + + + + + MQTT指令下发 + + + + + + 声纹识别 + + +
+ + + 控制家电开关 + + + + + + MCP接入点 + + + + + + 多指令任务 + + + + + + 播放音乐 + + + + + + 天气插件 + + +
+ + + 实时打断 + + + + + + 拍照识物品 + + + + + + 自定义音色 + + + + + + 使用粤语交流 + + + + + + 播报新闻 + + +
+ +--- + +## 警告 ⚠️ + +1、本项目为开源软件,本软件与对接的任何第三方API服务商(包括但不限于语音识别、大模型、语音合成等平台)均不存在商业合作关系,不为其服务质量及资金安全提供任何形式的担保。 +建议使用者优先选择持有相关业务牌照的服务商,并仔细阅读其服务协议及隐私政策。本软件不托管任何账户密钥、不参与资金流转、不承担充值资金损失风险。 + +2、本项目功能未完善,且未通过网络安全测评,请勿在生产环境中使用。 如果您在公网环境中部署学习本项目,请务必做好必要的防护。 + +--- + +## 部署文档 + +![Banners](docs/images/banner2.png) + +本项目提供两种部署方式,请根据您的具体需求选择: + +#### 🚀 部署方式选择 +| 部署方式 | 特点 | 适用场景 | 部署文档 | 配置要求 | 视频教程 | +|---------|------|---------|---------|---------|---------| +| **最简化安装** | 智能对话、单智能体管理 | 低配置环境,数据存储在配置文件,无需数据库 | [①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 | - | +| **全模块安装** | 智能对话、多用户管理、多智能体管理、智控台界面操作 | 完整功能体验,数据存储在数据库 |[①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个,每天会清空数据, + +``` +智控台地址: https://2662r3426b.vicp.fun +智控台(h5版): https://2662r3426b.vicp.fun/h5/index.html + +服务测试工具: https://2662r3426b.vicp.fun/test/ +OTA接口地址: https://2662r3426b.vicp.fun/xiaozhi/ota/ +Websocket接口地址: wss://2662r3426b.vicp.fun/xiaozhi/v1/ +``` + +#### 🚩 配置说明和推荐 +> [!Note] +> 本项目提供两种配置方案: +> +> 1. `入门全免费`配置:适合个人家庭使用,所有组件均采用免费方案,无需额外付费。 +> +> 2. `流式配置`:适合演示、培训、超过2个并发等场景,采用流式处理技术,响应速度更快,体验更佳。 +> +> 自`0.5.2`版本起,项目支持流式配置,相比早期版本,响应速度提升约`2.5秒`,显著改善用户体验。 + +| 模块名称 | 入门全免费设置 | 流式配置 | +|:---:|:---:|:---:| +| ASR(语音识别) | FunASR(本地) | 👍XunfeiStreamASR(讯飞流式) | +| LLM(大模型) | glm-4-flash(智谱) | 👍qwen-flash(阿里百炼) | +| VLLM(视觉大模型) | glm-4v-flash(智谱) | 👍qwen2.5-vl-3b-instructh(阿里百炼) | +| TTS(语音合成) | ✅LinkeraiTTS(灵犀流式) | 👍HuoshanDoubleStreamTTS(火山流式) | +| Intent(意图识别) | function_call(函数调用) | function_call(函数调用) | +| 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》performance_tester.py | 执行 `python performance_tester.py` | 测试ASR(语音识别)、LLM(大模型)、VLLM(视觉模型)、TTS(语音合成)三个核心模块的响应速度 | + +> 💡 提示:测试模型速度时,只会测试配置了密钥的模型。 + +--- +## 功能清单 ✨ +### 已实现 ✅ +![请参考-全模块安装架构图](docs/images/deploy2.png) +| 功能模块 | 描述 | +|:---:|:---| +| 核心架构 | 基于[MQTT+UDP网关](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/mqtt-gateway-integration.md)、WebSocket、HTTP服务器,提供完整的控制台管理和认证系统 | +| 语音交互 | 支持流式ASR(语音识别)、流式TTS(语音合成)、VAD(语音活动检测),支持多语言识别和语音处理 | +| 声纹识别 | 支持多用户声纹注册、管理和识别,与ASR并行处理,实时识别说话人身份并传递给LLM进行个性化回应 | +| 智能对话 | 支持多种LLM(大语言模型),实现智能对话 | +| 视觉感知 | 支持多种VLLM(视觉大模型),实现多模态交互 | +| 意图识别 | 支持外挂的大模型意图识别、大模型自主函数调用,提供插件化意图处理机制 | +| 记忆系统 | 支持本地短期记忆、mem0ai接口记忆、PowerMem智能记忆,具备记忆总结功能 | +| 知识库 | 支持RAGFlow知识库,让大模型判断需要调度知识库后再回答 | +| 工具调用 | 支持客户端IOT协议、客户MCP协议、服务端MCP协议、MCP接入点协议、自定义工具函数 | +| 指令下发 | 依托MQTT协议,支持从智控台将MCP指令下发到ESP32设备 | +| 管理后台 | 提供Web管理界面,支持用户管理、系统配置和设备管理;界面支持中文简体、中文繁体、英文显示 | +| 测试工具 | 提供性能测试工具、视觉模型测试工具和音频交互测试工具 | +| 部署支持 | 支持Docker部署和本地部署,提供完整的配置文件管理 | +| 插件系统 | 支持功能插件扩展、自定义插件开发和插件热加载 | + +### 正在开发 🚧 + +想了解具体开发计划进度,[请点击这里](https://github.com/users/xinnan-tech/projects/3)。常见问题及相关教程,可参考[这个链接](./docs/FAQ.md) + +如果你是一名软件开发者,这里有一份[《致开发者的公开信》](docs/contributor_open_letter.md),欢迎加入! + +--- + +## 产品生态 👬 +小智是一个生态,当你使用这个产品时,也可以看看其他在这个生态圈的[优秀项目](https://github.com/78/xiaozhi-esp32/blob/main/README_zh.md#%E7%9B%B8%E5%85%B3%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE) + +--- + +## 本项目支持的平台/组件列表 📋 +### LLM 语言模型 + +| 使用方式 | 支持平台 | 免费平台 | +|:---:|:---:|:---:| +| openai 接口调用 | 阿里百炼、火山引擎、DeepSeek、智谱、Gemini、科大讯飞 | 智谱、Gemini | +| ollama 接口调用 | Ollama | - | +| dify 接口调用 | Dify | - | +| fastgpt 接口调用 | Fastgpt | - | +| coze 接口调用 | Coze | - | +| xinference 接口调用 | Xinference | - | +| homeassistant 接口调用 | HomeAssistant | - | + +实际上,任何支持 openai 接口调用的 LLM 均可接入使用。 + +--- + +### VLLM 视觉模型 + +| 使用方式 | 支持平台 | 免费平台 | +|:---:|:---:|:---:| +| openai 接口调用 | 阿里百炼、智谱ChatGLMVLLM | 智谱ChatGLMVLLM | + +实际上,任何支持 openai 接口调用的 VLLM 均可接入使用。 + +--- + +### TTS 语音合成 + +| 使用方式 | 支持平台 | 免费平台 | +|:---:|:---:|:---:| +| 接口调用 | EdgeTTS、科大讯飞、火山引擎、腾讯云、阿里云及百炼、CosyVoiceSiliconflow、TTS302AI、CozeCnTTS、GizwitsTTS、ACGNTTS、OpenAITTS、灵犀流式TTS、MinimaxTTS | 灵犀流式TTS、EdgeTTS、CosyVoiceSiliconflow(部分) | +| 本地服务 | FishSpeech、GPT_SOVITS_V2、GPT_SOVITS_V3、Index-TTS、PaddleSpeech | Index-TTS、PaddleSpeech、FishSpeech、GPT_SOVITS_V2、GPT_SOVITS_V3 | + +--- + +### VAD 语音活动检测 + +| 类型 | 平台名称 | 使用方式 | 收费模式 | 备注 | +|:---:|:---------:|:----:|:----:|:--:| +| VAD | SileroVAD | 本地使用 | 免费 | | + +--- + +### ASR 语音识别 + +| 使用方式 | 支持平台 | 免费平台 | +|:---:|:---:|:---:| +| 本地使用 | FunASR、SherpaASR | FunASR、SherpaASR | +| 接口调用 | FunASRServer、火山引擎、科大讯飞、腾讯云、阿里云、百度云、OpenAI ASR | FunASRServer | + +--- + +### Voiceprint 声纹识别 + +| 使用方式 | 支持平台 | 免费平台 | +|:---:|:---:|:---:| +| 本地使用 | 3D-Speaker | 3D-Speaker | + +--- + +### Memory 记忆存储 + +| 类型 | 平台名称 | 使用方式 | 收费模式 | 备注 | +|:------:|:---------------:|:----:|:---------:|:--:| +| Memory | mem0ai | 接口调用 | 1000次/月额度 | | +| Memory | [powermem](./docs/powermem-integration.md) | 本地总结 | 取决于LLM和DB | OceanBase开源,支持智能检索 | +| Memory | mem_local_short | 本地总结 | 免费 | | +| Memory | nomem | 无记忆模式 | 免费 | | + +--- + +### Intent 意图识别 + +| 类型 | 平台名称 | 使用方式 | 收费模式 | 备注 | +|:------:|:-------------:|:----:|:-------:|:---------------------:| +| Intent | intent_llm | 接口调用 | 根据LLM收费 | 通过大模型识别意图,通用性强 | +| Intent | function_call | 接口调用 | 根据LLM收费 | 通过大模型函数调用完成意图,速度快,效果好 | +| Intent | nointent | 无意图模式 | 免费 | 不进行意图识别,直接返回对话结果 | + +--- + +### Rag 检索增强生成 + +| 类型 | 平台名称 | 使用方式 | 收费模式 | 备注 | +|:------:|:-------------:|:----:|:-------:|:---------------------:| +| Rag | ragflow | 接口调用 | 根据切片、分词消耗的token收费 | 借助RagFlow的检索增强生成功能,提供更准确的对话回复 | + +--- + +## 鸣谢 🙏 + +| Logo | 项目/公司 | 说明 | +|:---:|:---:|:---| +| | [百聆语音对话机器人](https://github.com/wwbin2017/bailing) | 本项目受[百聆语音对话机器人](https://github.com/wwbin2017/bailing)启发,并在其基础上实现 | +| | [十方融海](https://www.tenclass.com/) | 感谢[十方融海](https://www.tenclass.com/)为小智生态制定了标准的通讯协议、多设备兼容性方案及高并发场景实践示范;为本项目提供了全链路技术文档支持 | +| | [玄凤科技](https://github.com/Eric0308) | 感谢[玄凤科技](https://github.com/Eric0308)贡献函数调用框架、MCP通信协议及插件化调用机制的实现代码,通过标准化的指令调度体系与动态扩展能力,显著提升了前端设备(IoT)的交互效率和功能延展性 | +| | [huangjunsen](https://github.com/huangjunsen0406) | 感谢[huangjunsen](https://github.com/huangjunsen0406) 贡献`智控台移动端`模块,实现了跨平台移动设备的高效控制与实时交互,大幅提升了系统在移动场景下的操作便捷性和管理效率 | +| | [汇远设计](http://ui.kwd988.net/) | 感谢[汇远设计](http://ui.kwd988.net/)为本项目提供专业视觉解决方案,用其服务超千家企业的设计实战经验,赋能本项目产品用户体验 | +| | [西安勤人信息科技](https://www.029app.com/) | 感谢[西安勤人信息科技](https://www.029app.com/)深化本项目视觉体系,确保整体设计风格在多场景应用中的一致性和扩展性 | +| | [代码贡献者](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors) | 感谢[所有代码贡献者](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors)贡献者,你们的付出让项目更加健壮和强大。 | + + + + + + + + Star History Chart + + \ No newline at end of file diff --git a/backend/README_de.md b/backend/README_de.md new file mode 100644 index 0000000..88437de --- /dev/null +++ b/backend/README_de.md @@ -0,0 +1,376 @@ +[![Banners](docs/images/banner1.png)](https://github.com/xinnan-tech/xiaozhi-esp32-server) + +

Xiaozhi Backend-Service xiaozhi-esp32-server

+ +

+Dieses Projekt basiert auf der Theorie und Technologie der Mensch-Maschine-symbiotischen Intelligenz zur Entwicklung intelligenter Terminal-Hardware- und Software-Systeme
und bietet Backend-Dienste für das Open-Source-Hardware-Projekt +xiaozhi-esp32
+Implementiert mit Python, Java und Vue gemäß dem Xiaozhi-Kommunikationsprotokoll
+Unterstützt MQTT+UDP-Protokoll, Websocket-Protokoll, MCP-Endpunkte und Stimmabdruckerkennung +

+ +

+Häufige FragenProbleme meldenDeployment-DokumentationRelease-Hinweise +

+ +

+ 简体中文版自述文件 + README in English + Tiếng Việt + Deutsch + Português (Brasil) + + GitHub Contributors + + + GitHub pull requests + + + stars + +

+ +

+Geleitet vom Team von Professor Siyuan Liu (South China University of Technology) +
+刘思源教授团队主导研发(华南理工大学) +
+South China University of Technology +

+ +--- + +## Zielgruppe 👥 + +Dieses Projekt erfordert ESP32-Hardware-Geräte zum Betrieb. Wenn Sie ESP32-bezogene Hardware erworben haben, erfolgreich eine Verbindung zu Brother Xias bereitgestelltem Backend-Service hergestellt haben und Ihren eigenen `xiaozhi-esp32`-Backend-Service unabhängig aufbauen möchten, dann ist dieses Projekt perfekt für Sie. + +Möchten Sie die Nutzungseffekte sehen? Klicken Sie auf die Videos unten 🎥 + + + + + + + + + + + + + + + + + + + + + + + +
+ + + 响应速度感受 + + + + + + 速度优化秘诀 + + + + + + 复杂医疗场景 + + + + + + MQTT指令下发 + + + + + + 声纹识别 + + +
+ + + 控制家电开关 + + + + + + MCP接入点 + + + + + + 多指令任务 + + + + + + 播放音乐 + + + + + + 天气插件 + + +
+ + + 实时打断 + + + + + + 拍照识物品 + + + + + + 自定义音色 + + + + + + 使用粤语交流 + + + + + + 播报新闻 + + +
+ +--- + +## Warnungen ⚠️ + +1. Dieses Projekt ist Open-Source-Software. Diese Software hat keine kommerzielle Partnerschaft mit Drittanbieter-API-Dienstleistern (einschließlich, aber nicht beschränkt auf Spracherkennung, große Modelle, Sprachsynthese und andere Plattformen), mit denen sie sich verbindet, und bietet keine Garantie für deren Servicequalität oder finanzielle Sicherheit. Es wird empfohlen, dass Benutzer Dienstleister mit entsprechenden Geschäftslizenzen bevorzugen und deren Servicevereinbarungen und Datenschutzrichtlinien sorgfältig lesen. Diese Software hostet keine Kontoschlüssel, nimmt nicht an Geldströmen teil und trägt nicht das Risiko von Verlusten bei Guthaben-Aufladungen. + +2. Die Funktionalität dieses Projekts ist nicht vollständig und hat keine Netzwerksicherheitsbewertung bestanden. Bitte verwenden Sie es nicht in Produktionsumgebungen. Wenn Sie dieses Projekt zu Lernzwecken in einer öffentlichen Netzwerkumgebung bereitstellen, stellen Sie bitte sicher, dass notwendige Schutzmaßnahmen vorhanden sind. + +--- + +## Deployment-Dokumentation + +![Banners](docs/images/banner2.png) + +Dieses Projekt bietet zwei Bereitstellungsmethoden. Bitte wählen Sie basierend auf Ihren spezifischen Anforderungen: + +#### 🚀 Auswahl der Bereitstellungsmethode +| Bereitstellungsmethode | Funktionen | Anwendungsszenarien | Deployment-Dokumente | Konfigurationsanforderungen | Video-Tutorials | +|---------|------|---------|---------|---------|---------| +| **Vereinfachte Installation** | Intelligenter Dialog, Einzel-Agenten-Verwaltung | Umgebungen mit geringer Konfiguration, Daten in Konfigurationsdateien gespeichert, keine Datenbank erforderlich | [①Docker-Version](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E5%8F%AA%E8%BF%90%E8%A1%8Cserver) / [②Quellcode-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 Kerne 4GB bei Verwendung von `FunASR`, 2 Kerne 2GB bei allen APIs | - | +| **Vollständige Modulinstallation** | Intelligenter Dialog, Mehrbenutzerverwaltung, Mehr-Agenten-Verwaltung, Intelligente Steuerkonsole-Bedienung | Vollständige Funktionserfahrung, Daten in Datenbank gespeichert |[①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) / [②Quellcode-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) / [③Quellcode-Deployment Auto-Update-Tutorial](./docs/dev-ops-integration.md) | 4 Kerne 8GB bei Verwendung von `FunASR`, 2 Kerne 4GB bei allen APIs| [Video-Tutorial für lokalen Quellcode-Start](https://www.bilibili.com/video/BV1wBJhz4Ewe) | + +Häufige Fragen und entsprechende Tutorials finden Sie unter [diesem Link](./docs/FAQ.md) + +> 💡 Hinweis: Unten ist eine Testplattform, die mit dem neuesten Code bereitgestellt wurde. Sie können bei Bedarf brennen und testen. Gleichzeitige Benutzer: 6, Daten werden täglich gelöscht. + +``` +Adresse der intelligenten Steuerkonsole: https://2662r3426b.vicp.fun +Adresse der intelligenten Steuerkonsole (H5): https://2662r3426b.vicp.fun/h5/index.html + +Service-Testtool: https://2662r3426b.vicp.fun/test/ +OTA-Schnittstellenadresse: https://2662r3426b.vicp.fun/xiaozhi/ota/ +Websocket-Schnittstellenadresse: wss://2662r3426b.vicp.fun/xiaozhi/v1/ +``` + +#### 🚩 Konfigurationsbeschreibung und Empfehlungen +> [!Note] +> Dieses Projekt bietet zwei Konfigurationsschemata: +> +> 1. `Einstiegslevel Kostenlose Einstellungen`: Geeignet für den persönlichen und privaten Gebrauch, alle Komponenten verwenden kostenlose Lösungen, keine zusätzliche Zahlung erforderlich. +> +> 2. `Streaming-Konfiguration`: Geeignet für Demonstrationen, Schulungen, Szenarien mit mehr als 2 gleichzeitigen Benutzern usw. Verwendet Streaming-Verarbeitungstechnologie für schnellere Reaktionsgeschwindigkeit und bessere Erfahrung. +> +> Ab Version `0.5.2` unterstützt das Projekt Streaming-Konfiguration. Im Vergleich zu früheren Versionen ist die Reaktionsgeschwindigkeit um ca. `2,5 Sekunden` verbessert, was die Benutzererfahrung erheblich verbessert. + +| Modulname | Einstiegslevel Kostenlose Einstellungen | Streaming-Konfiguration | +|:---:|:---:|:---:| +| ASR (Spracherkennung) | FunASR (Lokal) | 👍XunfeiStreamASR (Xunfei-Streaming) | +| LLM (Großes Modell) | glm-4-flash (Zhipu) | 👍qwen-flash (Alibaba Bailian) | +| VLLM (Vision Large Model) | glm-4v-flash (Zhipu) | 👍qwen2.5-vl-3b-instructh (Alibaba Bailian) | +| TTS (Sprachsynthese) | ✅LinkeraiTTS (Lingxi-Streaming) | 👍HuoshanDoubleStreamTTS (Volcano-Streaming) | +| Intent (Absichtserkennung) | function_call (Funktionsaufruf) | function_call (Funktionsaufruf) | +| Memory (Gedächtnisfunktion) | mem_local_short (Lokales Kurzzeitgedächtnis) | mem_local_short (Lokales Kurzzeitgedächtnis) | + +Wenn Sie sich um die Latenz jeder Komponente kümmern, lesen Sie bitte den [Xiaozhi-Komponenten-Leistungstestbericht](https://github.com/xinnan-tech/xiaozhi-performance-research). Sie können gemäß den Testmethoden im Bericht in Ihrer Umgebung tatsächlich testen. + +#### 🔧 Testwerkzeuge +Dieses Projekt bietet die folgenden Testwerkzeuge, um Ihnen bei der Überprüfung des Systems und der Auswahl geeigneter Modelle zu helfen: + +| Werkzeugname | Standort | Verwendungsmethode | Funktionsbeschreibung | +|:---:|:---|:---:|:---:| +| Audio-Interaktionstesttool | main》xiaozhi-server》test》test_page.html | Direkt mit Google Chrome öffnen | Testet Audio-Wiedergabe- und Empfangsfunktionen, überprüft, ob die Python-seitige Audioverarbeitung normal ist | +| Modell-Reaktionstesttool | main》xiaozhi-server》performance_tester.py | Ausführen `python performance_tester.py` | Testet die Reaktionsgeschwindigkeit von ASR (Spracherkennung), LLM (großes Modell), VLLM (Vision-Modell), TTS (Sprachsynthese) drei Kernmodulen | + +> 💡 Hinweis: Beim Testen der Modellgeschwindigkeit werden nur Modelle mit konfigurierten Schlüsseln getestet. + +--- +## Funktionsliste ✨ +### Implementiert ✅ +![请参考-全模块安装架构图](docs/images/deploy2.png) +| Funktionsmodul | Beschreibung | +|:---:|:---| +| Kernarchitektur | Basierend auf [MQTT+UDP-Gateway](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/mqtt-gateway-integration.md), WebSocket und HTTP-Servern, bietet vollständiges Konsolenverwaltungs- und Authentifizierungssystem | +| Sprachinteraktion | Unterstützt Streaming-ASR (Spracherkennung), Streaming-TTS (Sprachsynthese), VAD (Sprachaktivitätserkennung), unterstützt mehrsprachige Erkennung und Sprachverarbeitung | +| Stimmabdruckerkennung | Unterstützt Mehrbenutzer-Stimmabdruckregistrierung, -verwaltung und -erkennung, verarbeitet parallel mit ASR, Echtzeit-Sprecheridentitätserkennung und Weitergabe an LLM für personalisierte Antworten | +| Intelligenter Dialog | Unterstützt mehrere LLM (große Sprachmodelle), implementiert intelligenten Dialog | +| Visuelle Wahrnehmung | Unterstützt mehrere VLLM (Vision Large Models), implementiert multimodale Interaktion | +| Absichtserkennung | Unterstützt LLM-Absichtserkennung, Function Call-Funktionsaufruf, bietet plugin-basierten Absichtsverarbeitungsmechanismus | +| Gedächtnissystem | Unterstützt lokales Kurzzeitgedächtnis, mem0ai-Schnittstellengedächtnis, PowerMem intelligentes Gedächtnis, mit Gedächtniszusammenfassungsfunktion | +| Wissensdatenbank | Unterstützt RAGFlow-Wissensdatenbank, ermöglicht großem Modell die Bewertung, ob Wissensdatenbank benötigt wird, bevor geantwortet wird | +| Werkzeugaufruf | Unterstützt Client-IOT-Protokoll, Client-MCP-Protokoll, Server-MCP-Protokoll, MCP-Endpunktprotokoll, benutzerdefinierte Werkzeugfunktionen | +| Befehlsübermittlung | Basierend auf MQTT-Protokoll, unterstützt die Übermittlung von MCP-Befehlen von der intelligenten Steuerkonsole an ESP32-Geräte | +| Verwaltungs-Backend | Bietet Web-Verwaltungsoberfläche, unterstützt Benutzerverwaltung, Systemkonfiguration und Geräteverwaltung; Oberfläche unterstützt vereinfachtes Chinesisch, traditionelles Chinesisch und englische Anzeige | +| Testwerkzeuge | Bietet Leistungstestwerkzeuge, Vision-Modell-Testwerkzeuge und Audio-Interaktionstestwerkzeuge | +| Deployment-Unterstützung | Unterstützt Docker-Deployment und lokales Deployment, bietet vollständige Konfigurationsdateiverwaltung | +| Plugin-System | Unterstützt funktionale Plugin-Erweiterungen, benutzerdefinierte Plugin-Entwicklung und Plugin-Hot-Loading | + +### In Entwicklung 🚧 + +Um über spezifische Entwicklungsplanfortschritte zu erfahren, [klicken Sie hier](https://github.com/users/xinnan-tech/projects/3). Häufige Fragen und entsprechende Tutorials finden Sie unter [diesem Link](./docs/FAQ.md) + +Wenn Sie ein Softwareentwickler sind, finden Sie hier einen [Offenen Brief an Entwickler](docs/contributor_open_letter.md). Willkommen beim Beitritt! + +--- + +## Produktökosystem 👬 +Xiaozhi ist ein Ökosystem. Wenn Sie dieses Produkt verwenden, können Sie sich auch andere [hervorragende Projekte](https://github.com/78/xiaozhi-esp32/blob/main/README_zh.md#%E7%9B%B8%E5%85%B3%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE) in diesem Ökosystem ansehen + +--- + +## Liste der von diesem Projekt unterstützten Plattformen/Komponenten 📋 +### LLM-Sprachmodelle + +| Verwendungsmethode | Unterstützte Plattformen | Kostenlose Plattformen | +|:---:|:---:|:---:| +| OpenAI-Schnittstellenaufrufe | Alibaba Bailian, Volcano Engine Doubao, DeepSeek, Zhipu ChatGLM, Gemini | Zhipu ChatGLM, Gemini | +| Ollama-Schnittstellenaufrufe | Ollama | - | +| Dify-Schnittstellenaufrufe | Dify | - | +| FastGPT-Schnittstellenaufrufe | FastGPT | - | +| Coze-Schnittstellenaufrufe | Coze | - | +| Xinference-Schnittstellenaufrufe | Xinference | - | +| HomeAssistant-Schnittstellenaufrufe | HomeAssistant | - | + +Tatsächlich kann jedes LLM, das OpenAI-Schnittstellenaufrufe unterstützt, integriert und verwendet werden. + +--- + +### VLLM-Vision-Modelle + +| Verwendungsmethode | Unterstützte Plattformen | Kostenlose Plattformen | +|:---:|:---:|:---:| +| OpenAI-Schnittstellenaufrufe | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | + +Tatsächlich kann jedes VLLM, das OpenAI-Schnittstellenaufrufe unterstützt, integriert und verwendet werden. + +--- + +### TTS-Sprachsynthese + +| Verwendungsmethode | Unterstützte Plattformen | Kostenlose Plattformen | +|:---:|:---:|:---:| +| Schnittstellenaufrufe | EdgeTTS, Volcano Engine Doubao TTS, Tencent Cloud, Alibaba Cloud TTS, AliYun Stream TTS, CosyVoiceSiliconflow, TTS302AI, CozeCnTTS, GizwitsTTS, ACGNTTS, OpenAITTS, Lingxi Streaming TTS, MinimaxTTS, Volcano Dual-Stream TTS | Lingxi Streaming TTS, EdgeTTS, CosyVoiceSiliconflow (teilweise) | +| Lokale Dienste | FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3, Index-TTS, PaddleSpeech | Index-TTS, PaddleSpeech, FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3 | + +--- + +### VAD-Sprachaktivitätserkennung + +| Typ | Plattformname | Verwendungsmethode | Preismodell | Hinweise | +|:---:|:---------:|:----:|:----:|:--:| +| VAD | SileroVAD | Lokale Verwendung | Kostenlos | | + +--- + +### ASR-Spracherkennung + +| Verwendungsmethode | Unterstützte Plattformen | Kostenlose Plattformen | +|:---:|:---:|:---:| +| Lokale Verwendung | FunASR, SherpaASR | FunASR, SherpaASR | +| Schnittstellenaufrufe | DoubaoASR, Doubao Streaming ASR, FunASRServer, TencentASR, AliyunASR, Aliyun Streaming ASR, Baidu ASR, OpenAI ASR | FunASRServer | + +--- + +### Voiceprint-Stimmabdruckerkennung + +| Verwendungsmethode | Unterstützte Plattformen | Kostenlose Plattformen | +|:---:|:---:|:---:| +| Lokale Verwendung | 3D-Speaker | 3D-Speaker | + +--- + +### Memory-Gedächtnisspeicher + +| Typ | Plattformname | Verwendungsmethode | Preismodell | Hinweise | +|:------:|:---------------:|:----:|:---------:|:--:| +| Memory | mem0ai | Schnittstellenaufrufe | 1000 Mal/Monat Kontingent | | +| Memory | [powermem](./docs/powermem-integration.md) | Lokale Zusammenfassung | Abhängig von LLM und DB | OceanBase Open Source, unterstützt intelligente Abfrage | +| Memory | mem_local_short | Lokale Zusammenfassung | Kostenlos | | +| Memory | nomem | Kein Gedächtnismodus | Kostenlos | | + +--- + +### Intent-Absichtserkennung + +| Typ | Plattformname | Verwendungsmethode | Preismodell | Hinweise | +|:------:|:-------------:|:----:|:-------:|:---------------------:| +| Intent | intent_llm | Schnittstellenaufrufe | Basierend auf LLM-Preisen | Erkennt Absicht durch große Modelle, starke Allgemeingültigkeit | +| Intent | function_call | Schnittstellenaufrufe | Basierend auf LLM-Preisen | Vervollständigt Absicht durch Funktionsaufruf großer Modelle, schnelle Geschwindigkeit, guter Effekt | +| Intent | nointent | Kein Absichtsmodus | Kostenlos | Führt keine Absichtserkennung durch, gibt direkt Dialogergebnis zurück | + +--- + +### Rag Retrieval Augmented Generation + +| Typ | Plattformname | Verwendungsmethode | Preismodell | Hinweise | +|:------:|:-------------:|:----:|:-------:|:---------------------:| +| Rag | ragflow | Schnittstellenaufrufe | Gebühren basierend auf Token-Verbrauch für Segmentierung und Tokenisierung | Nutzt RAGFlow's Retrieval-Augmented-Generation-Funktion für präzisere Dialogantworten | + +--- + +## Danksagungen 🙏 + +| Logo | Projekt/Unternehmen | Beschreibung | +|:---:|:---:|:---| +| | [Bailing Voice Dialogue Robot](https://github.com/wwbin2017/bailing) | Dieses Projekt wurde von [Bailing Voice Dialogue Robot](https://github.com/wwbin2017/bailing) inspiriert und auf dessen Basis implementiert | +| | [Tenclass](https://www.tenclass.com/) | Dank an [Tenclass](https://www.tenclass.com/) für die Formulierung von Standardkommunikationsprotokollen, Multi-Geräte-Kompatibilitätslösungen und High-Concurrency-Szenario-Praxisdemonstrationen für das Xiaozhi-Ökosystem; für die Bereitstellung vollständiger technischer Dokumentationsunterstützung für dieses Projekt | +| | [Xuanfeng Technology](https://github.com/Eric0308) | Dank an [Xuanfeng Technology](https://github.com/Eric0308) für den Beitrag des Funktionsaufruf-Frameworks, des MCP-Kommunikationsprotokolls und der plugin-basierten Aufrufmechanismus-Implementierungscode. Durch standardisiertes Befehlsplanungssystem und dynamische Erweiterungsfähigkeiten wird die Interaktionseffizienz und funktionale Erweiterbarkeit von Frontend-Geräten (IoT) erheblich verbessert | +| | [huangjunsen](https://github.com/huangjunsen0406) | Dank an [huangjunsen](https://github.com/huangjunsen0406) für den Beitrag des `Smart Control Console Mobile`-Moduls, das eine effiziente Steuerung und Echtzeit-Interaktion über mobile Geräte ermöglicht und die Betriebsbequemlichkeit und Verwaltungseffizienz des Systems in mobilen Szenarien erheblich verbessert | +| | [Huiyuan Design](http://ui.kwd988.net/) | Dank an [Huiyuan Design](http://ui.kwd988.net/) für die Bereitstellung professioneller visueller Lösungen für dieses Projekt, unter Verwendung ihrer Design-Praxiserfahrung im Dienst von über tausend Unternehmen, um die Produktbenutzererfahrung dieses Projekts zu stärken | +| | [Xi'an Qinren Information Technology](https://www.029app.com/) | Dank an [Xi'an Qinren Information Technology](https://www.029app.com/) für die Vertiefung des visuellen Systems dieses Projekts und die Sicherstellung der Konsistenz und Erweiterbarkeit des Gesamtdesignstils in Multi-Szenario-Anwendungen | +| | [Code-Mitwirkende](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors) | Dank an [alle Code-Mitwirkenden](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors), Ihre Bemühungen haben das Projekt robuster und leistungsfähiger gemacht. | + + + + + + + + Star History Chart + + diff --git a/backend/README_en.md b/backend/README_en.md new file mode 100644 index 0000000..070771a --- /dev/null +++ b/backend/README_en.md @@ -0,0 +1,376 @@ +[![Banners](docs/images/banner1.png)](https://github.com/xinnan-tech/xiaozhi-esp32-server) + +

Xiaozhi Backend Service xiaozhi-esp32-server

+ +

+This project is based on human-machine symbiotic intelligence theory and technology to develop intelligent terminal hardware and software systems
providing backend services for the open-source intelligent hardware project +xiaozhi-esp32
+Implemented using Python, Java, and Vue according to the Xiaozhi Communication Protocol
+Support for MQTT+UDP protocol, Websocket protocol, MCP access point, voiceprint recognition, and knowledge base +

+ +

+FAQReport IssuesDeployment DocsRelease Notes +

+ +

+ 简体中文版自述文件 + README in English + Tiếng Việt + Deutsch + Português (Brasil) + + GitHub Contributors + + + GitHub pull requests + + + stars + +

+ +

+Spearheaded by Professor Siyuan Liu's Team (South China University of Technology) +
+刘思源教授团队主导研发(华南理工大学) +
+South China University of Technology +

+ +--- + +## Target Users 👥 + +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 the usage effects? Click the videos below 🎥 + + + + + + + + + + + + + + + + + + + + + + + +
+ + + 响应速度感受 + + + + + + 速度优化秘诀 + + + + + + 复杂医疗场景 + + + + + + MQTT指令下发 + + + + + + 声纹识别 + + +
+ + + 控制家电开关 + + + + + + MCP接入点 + + + + + + 多指令任务 + + + + + + 播放音乐 + + + + + + 天气插件 + + +
+ + + 实时打断 + + + + + + 拍照识物品 + + + + + + 自定义音色 + + + + + + 使用粤语交流 + + + + + + 播报新闻 + + +
+ +--- + +## Warnings ⚠️ + +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. + +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. + +--- + +## Deployment Documentation + +![Banners](docs/images/banner2.png) + +This project provides two deployment methods. Please choose based on your specific needs: + +#### 🚀 Deployment Method Selection +| Deployment Method | Features | Applicable Scenarios | Deployment Docs | Configuration Requirements | Video Tutorials | +|---------|------|---------|---------|---------|---------| +| **Simplified Installation** | Intelligent dialogue, single agent management | 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** | Intelligent dialogue, multi-user management, multi-agent management, intelligent console interface operation | 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) | + +For frequently asked questions and related tutorials, please refer to [this link](./docs/FAQ.md) + +> 💡 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. + +``` +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/ +OTA Interface Address: https://2662r3426b.vicp.fun/xiaozhi/ota/ +Websocket Interface Address: wss://2662r3426b.vicp.fun/xiaozhi/v1/ +``` + +#### 🚩 Configuration Description and Recommendations +> [!Note] +> This project provides two configuration schemes: +> +> 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 | Streaming Configuration | +|:---:|:---:|:---:| +| ASR(Speech Recognition) | FunASR(Local) | 👍XunfeiStreamASR(Xunfei Streaming) | +| LLM(Large Model) | glm-4-flash(Zhipu) | 👍qwen-flash(Alibaba Bailian) | +| VLLM(Vision Large Model) | glm-4v-flash(Zhipu) | 👍qwen2.5-vl-3b-instructh(Alibaba Bailian) | +| TTS(Speech Synthesis) | ✅LinkeraiTTS(Lingxi streaming) | 👍HuoshanDoubleStreamTTS(Volcano Streaming) | +| 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) | + +If you are concerned about the latency of each component, please refer to the [Xiaozhi Component Performance Test Report](https://github.com/xinnan-tech/xiaozhi-performance-research), and test in your own environment following the test methods in the report. + +#### 🔧 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 | main》xiaozhi-server》performance_tester.py | Execute `python performance_tester.py` | Tests response speed of three core modules: ASR(speech recognition), LLM(large model), VLLM(vision model), TTS(speech synthesis) | + +> 💡 Note: When testing model speed, only models with configured keys will be tested. + +--- +## Feature List ✨ +### Implemented ✅ +![请参考-全模块安装架构图](docs/images/deploy2.png) +| Feature Module | Description | +|:---:|:---| +| Core Architecture | Based on [MQTT+UDP gateway](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/mqtt-gateway-integration.md), WebSocket and HTTP servers, provides complete console management and authentication system | +| Voice Interaction | Supports streaming ASR(speech recognition), streaming TTS(speech synthesis), VAD(voice activity detection), supports multi-language recognition and voice processing | +| 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 | +| Intelligent Dialogue | Supports multiple LLM(large language models), implements intelligent dialogue | +| Visual Perception | Supports multiple VLLM(vision large models), implements multimodal interaction | +| Intent Recognition | Supports LLM intent recognition, Function Call function calling, provides plugin-based intent processing mechanism | +| Memory System | Supports local short-term memory, mem0ai interface memory, PowerMem intelligent memory, with memory summarization functionality | +| Knowledge Base | Supports RAGFlow knowledge base, enabling LLM to judge whether to schedule the knowledge base after receiving the user's question, and then answer the question | +| Tool Calling | Supports client IOT protocol, client MCP protocol, server MCP protocol, MCP endpoint protocol, custom tool functions | +| Command Delivery | Supports MCP command delivery to ESP32 devices via MQTT protocol from Smart Console | +| Management Backend | Provides Web management interface, supports user management, system configuration and device management; Supports Simplified Chinese, Traditional Chinese and English display | +| 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 | + +### Under Development 🚧 + +To learn about specific development plan progress, [click here](https://github.com/users/xinnan-tech/projects/3). For frequently asked questions and related tutorials, please refer to [this link](./docs/FAQ.md) + +If you are a software developer, here is an [Open Letter to Developers](docs/contributor_open_letter.md). Welcome to join! + +--- + +## Product Ecosystem 👬 +Xiaozhi is an ecosystem. When using this product, you can also check out other [excellent projects](https://github.com/78/xiaozhi-esp32/blob/main/README_zh.md#%E7%9B%B8%E5%85%B3%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE) in this ecosystem + +--- + +## Supported Platforms/Components List 📋 +### LLM Language Models + +| Usage Method | Supported Platforms | Free Platforms | +|:---:|:---:|:---:| +| OpenAI interface calls | Alibaba Bailian, Volcano Engine, DeepSeek, Zhipu, Gemini, iFLYTEK | Zhipu, Gemini | +| Ollama interface calls | Ollama | - | +| Dify interface calls | Dify | - | +| FastGPT interface calls | FastGPT | - | +| Coze interface calls | Coze | - | +| Xinference interface calls | Xinference | - | +| HomeAssistant interface calls | HomeAssistant | - | + +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 + +| Usage Method | Supported Platforms | Free Platforms | +|:---:|:---:|:---:| +| Interface calls | EdgeTTS, iFLYTEK, Volcano Engine, Tencent Cloud, Alibaba Cloud and Bailian, CosyVoiceSiliconflow, TTS302AI, CozeCnTTS, GizwitsTTS, ACGNTTS, OpenAITTS, Lingxi Streaming TTS, MinimaxTTS | Lingxi Streaming TTS, EdgeTTS, CosyVoiceSiliconflow(partial) | +| Local services | FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3, Index-TTS, PaddleSpeech | Index-TTS, PaddleSpeech, FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3 | + +--- + +### VAD Voice Activity Detection + +| Type | Platform Name | Usage Method | Pricing Model | Notes | +|:---:|:---------:|:----:|:----:|:--:| +| VAD | SileroVAD | Local use | Free | | + +--- + +### ASR Speech Recognition + +| Usage Method | Supported Platforms | Free Platforms | +|:---:|:---:|:---:| +| Local use | FunASR, SherpaASR | FunASR, SherpaASR | +| Interface calls | FunASRServer, Volcano Engine, iFLYTEK, Tencent Cloud, Alibaba Cloud, Baidu Cloud, OpenAI ASR | FunASRServer | + +--- + +### Voiceprint Recognition + +| Usage Method | Supported Platforms | Free Platforms | +|:---:|:---:|:---:| +| Local use | 3D-Speaker | 3D-Speaker | + +--- + +### Memory Storage + +| Type | Platform Name | Usage Method | Pricing Model | Notes | +|:------:|:---------------:|:----:|:---------:|:--:| +| Memory | mem0ai | Interface calls | 1000 times/month quota | | +| Memory | [powermem](./docs/powermem-integration.md) | Local summarization | Depends on LLM and DB | OceanBase open source, supports intelligent retrieval | +| Memory | mem_local_short | Local summarization | Free | | +| Memory | nomem | No memory mode | Free | | + +--- + +### Intent Recognition + +| Type | Platform Name | Usage Method | Pricing Model | Notes | +|:------:|:-------------:|:----:|:-------:|:---------------------:| +| Intent | intent_llm | Interface calls | Based on LLM pricing | Recognizes intent through large models, strong generalization | +| Intent | function_call | Interface calls | Based on LLM pricing | Completes intent through large model function calling, fast speed, good effect | +| Intent | nointent | No intent mode | Free | Does not perform intent recognition, directly returns dialogue result | + +--- + +### Rag Retrieval-Augmented Generation + +| Type | Platform Name | Usage Method | Pricing Model | Notes | +|:------:|:-------------:|:----:|:-------:|:---------------------:| +| Rag | ragflow | Interface calls | Charged based on tokens consumed for slicing and word segmentation | Utilizes RagFlow's retrieval-augmented generation feature to provide more accurate dialog responses | + +--- + +## Acknowledgments 🙏 + +| Logo | Project/Company | Description | +|:---:|:---:|:---| +| | [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 | +| | [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 | +| | [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) | +| | [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. | +| | [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 | +| | [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 | +| | [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. | + + + + + + + + Star History Chart + + diff --git a/backend/README_pt_BR.md b/backend/README_pt_BR.md new file mode 100644 index 0000000..d9ed556 --- /dev/null +++ b/backend/README_pt_BR.md @@ -0,0 +1,376 @@ +[![Banners](docs/images/banner1.png)](https://github.com/xinnan-tech/xiaozhi-esp32-server) + +

Serviço Backend Xiaozhi xiaozhi-esp32-server

+ +

+Este projeto é baseado na teoria e tecnologia de inteligência simbiótica humano-máquina para desenvolver sistemas inteligentes de hardware e software para terminais
fornecendo serviços de backend para o projeto de hardware inteligente de código aberto +xiaozhi-esp32
+Implementado usando Python, Java e Vue de acordo com o Protocolo de Comunicação Xiaozhi
+Suporte ao protocolo MQTT+UDP, protocolo WebSocket, ponto de acesso MCP, reconhecimento de impressão vocal e base de conhecimento +

+ +

+Perguntas FrequentesReportar ProblemasDocumentação de ImplantaçãoNotas de Lançamento +

+ +

+ 简体中文版自述文件 + README in English + Tiếng Việt + Deutsch + Português (Brasil) + + GitHub Contributors + + + GitHub pull requests + + + stars + +

+ +

+Liderado pela Equipe do Professor Siyuan Liu (Universidade de Tecnologia do Sul da China) +
+刘思源教授团队主导研发(华南理工大学) +
+Universidade de Tecnologia do Sul da China (华南理工大学) +

+ +--- + +## Público-Alvo 👥 + +Este projeto requer dispositivos de hardware ESP32 para funcionar. Se você adquiriu hardware relacionado ao ESP32, conectou-se com sucesso ao serviço backend implantado pelo Brother Xia e deseja construir seu próprio serviço backend `xiaozhi-esp32` de forma independente, então este projeto é perfeito para você. + +Quer ver os efeitos de uso? Clique nos vídeos abaixo 🎥 + + + + + + + + + + + + + + + + + + + + + + + +
+ + + Experiência de velocidade de resposta + + + + + + Segredo da otimização de velocidade + + + + + + Cenário médico complexo + + + + + + Envio de comandos MQTT + + + + + + Reconhecimento de impressão vocal + + +
+ + + Controle de interruptores de eletrodomésticos + + + + + + Ponto de acesso MCP + + + + + + Tarefas com múltiplos comandos + + + + + + Reproduzir música + + + + + + Plugin de clima + + +
+ + + Interrupção em tempo real + + + + + + Fotografar e identificar objetos + + + + + + Timbre de voz personalizado + + + + + + Comunicação em cantonês + + + + + + Transmissão de notícias + + +
+ +--- + +## Avisos ⚠️ + +1. Este projeto é um software de código aberto. Este software não possui parceria comercial com nenhum provedor de serviços de API de terceiros (incluindo, mas não se limitando a reconhecimento de fala, modelos de linguagem, síntese de voz e outras plataformas) com os quais se conecta, e não fornece nenhuma forma de garantia quanto à qualidade de serviço ou segurança financeira desses provedores. Recomenda-se que os usuários priorizem provedores de serviço com licenças comerciais relevantes e leiam cuidadosamente seus termos de serviço e políticas de privacidade. Este software não armazena nenhuma chave de conta, não participa de fluxos de fundos e não assume o risco de perda de fundos recarregados. + +2. A funcionalidade deste projeto não está completa e não passou por avaliação de segurança de rede. Por favor, não o utilize em ambientes de produção. Se você implantar este projeto para fins de aprendizado em um ambiente de rede pública, certifique-se de que as medidas de proteção necessárias estejam em vigor. + +--- + +## Documentação de Implantação + +![Banners](docs/images/banner2.png) + +Este projeto oferece dois métodos de implantação. Por favor, escolha de acordo com suas necessidades específicas: + +#### 🚀 Seleção do Método de Implantação +| Método de Implantação | Funcionalidades | Cenários Aplicáveis | Documentação de Implantação | Requisitos de Configuração | Tutoriais em Vídeo | +|---------|------|---------|---------|---------|---------| +| **Instalação Simplificada** | Diálogo inteligente, gerenciamento de agente único | Ambientes de baixa configuração, dados armazenados em arquivos de configuração, sem necessidade de banco de dados | [①Versão Docker](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E5%8F%AA%E8%BF%90%E8%A1%8Cserver) / [②Implantação via Código-Fonte](./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 núcleos 4GB se usar `FunASR`, 2 núcleos 2GB se todas APIs | - | +| **Instalação de Módulo Completo** | Diálogo inteligente, gerenciamento multiusuário, gerenciamento de múltiplos agentes, operação de interface do console inteligente | Experiência com funcionalidade completa, dados armazenados em banco de dados |[①Versão 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) / [②Implantação via Código-Fonte](./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) / [③Tutorial de Atualização Automática via Código-Fonte](./docs/dev-ops-integration.md) | 4 núcleos 8GB se usar `FunASR`, 2 núcleos 4GB se todas APIs| [Tutorial em Vídeo de Inicialização via Código-Fonte Local](https://www.bilibili.com/video/BV1wBJhz4Ewe) | + +Perguntas frequentes e tutoriais relacionados podem ser consultados [neste link](./docs/FAQ.md) + +> 💡 Nota: Abaixo está uma plataforma de teste implantada com o código mais recente. Você pode gravar e testar se necessário. Usuários simultâneos: 6, os dados serão limpos diariamente. + +``` +Endereço do Console de Controle Inteligente: https://2662r3426b.vicp.fun +Endereço do Console de Controle Inteligente (H5): https://2662r3426b.vicp.fun/h5/index.html + +Ferramenta de Teste de Serviço: https://2662r3426b.vicp.fun/test/ +Endereço da Interface OTA: https://2662r3426b.vicp.fun/xiaozhi/ota/ +Endereço da Interface WebSocket: wss://2662r3426b.vicp.fun/xiaozhi/v1/ +``` + +#### 🚩 Descrição e Recomendações de Configuração +> [!Note] +> Este projeto oferece dois esquemas de configuração: +> +> 1. `Configurações Gratuitas Nível Básico`: Adequado para uso pessoal e doméstico, todos os componentes utilizam soluções gratuitas, sem necessidade de pagamento adicional. +> +> 2. `Configuração de Streaming`: Adequado para demonstrações, treinamentos, cenários com mais de 2 usuários simultâneos, etc. Utiliza tecnologia de processamento em streaming para velocidade de resposta mais rápida e melhor experiência. +> +> A partir da versão `0.5.2`, o projeto suporta configuração de streaming. Em comparação com versões anteriores, a velocidade de resposta é melhorada em aproximadamente `2,5 segundos`, melhorando significativamente a experiência do usuário. + +| Nome do Módulo | Configurações Gratuitas Nível Básico | Configuração de Streaming | +|:---:|:---:|:---:| +| ASR(Reconhecimento de Fala) | FunASR(Local) | 👍XunfeiStreamASR(Xunfei Streaming) | +| LLM(Modelo de Linguagem) | glm-4-flash(Zhipu) | 👍qwen-flash(Alibaba Bailian) | +| VLLM(Modelo de Visão) | glm-4v-flash(Zhipu) | 👍qwen2.5-vl-3b-instructh(Alibaba Bailian) | +| TTS(Síntese de Voz) | ✅LinkeraiTTS(Lingxi streaming) | 👍HuoshanDoubleStreamTTS(Volcano Streaming) | +| Intent(Reconhecimento de Intenção) | function_call(Chamada de função) | function_call(Chamada de função) | +| Memory(Função de Memória) | mem_local_short(Memória local de curto prazo) | mem_local_short(Memória local de curto prazo) | + +Se você está preocupado com o tempo de resposta de cada componente, consulte o [Relatório de Teste de Desempenho dos Componentes Xiaozhi](https://github.com/xinnan-tech/xiaozhi-performance-research), e teste em seu próprio ambiente seguindo os métodos de teste do relatório. + +#### 🔧 Ferramentas de Teste +Este projeto fornece as seguintes ferramentas de teste para ajudá-lo a verificar o sistema e escolher modelos adequados: + +| Nome da Ferramenta | Localização | Método de Uso | Descrição da Função | +|:---:|:---|:---:|:---:| +| Ferramenta de Teste de Interação por Áudio | main》xiaozhi-server》test》test_page.html | Abrir diretamente com Google Chrome | Testa as funções de reprodução e recepção de áudio, verifica se o processamento de áudio no lado Python está normal | +| Ferramenta de Teste de Resposta de Modelo | main》xiaozhi-server》performance_tester.py | Execute `python performance_tester.py` | Testa a velocidade de resposta dos três módulos principais: ASR(reconhecimento de fala), LLM(modelo de linguagem), VLLM(modelo de visão), TTS(síntese de voz) | + +> 💡 Nota: Ao testar a velocidade dos modelos, apenas os modelos com chaves configuradas serão testados. + +--- +## Lista de Funcionalidades ✨ +### Implementado ✅ +![请参考-全模块安装架构图](docs/images/deploy2.png) +| Módulo de Funcionalidade | Descrição | +|:---:|:---| +| Arquitetura Principal | Baseado em [gateway MQTT+UDP](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/mqtt-gateway-integration.md), servidores WebSocket e HTTP, fornece sistema completo de gerenciamento de console e autenticação | +| Interação por Voz | Suporta ASR em streaming (reconhecimento de fala), TTS em streaming (síntese de voz), VAD (detecção de atividade vocal), suporta reconhecimento multilíngue e processamento de voz | +| Reconhecimento de Impressão Vocal | Suporta registro, gerenciamento e reconhecimento de impressão vocal de múltiplos usuários, processa em paralelo com o ASR, reconhecimento de identidade do falante em tempo real e repassa ao LLM para respostas personalizadas | +| Diálogo Inteligente | Suporta múltiplos LLM (modelos de linguagem de grande porte), implementa diálogo inteligente | +| Percepção Visual | Suporta múltiplos VLLM (modelos de visão de grande porte), implementa interação multimodal | +| Reconhecimento de Intenção | Suporta reconhecimento de intenção por LLM, Function Call (chamada de função), fornece mecanismo de processamento de intenção baseado em plugins | +| Sistema de Memória | Suporta memória local de curto prazo, memória via interface mem0ai, memória inteligente PowerMem, com funcionalidade de resumo de memória | +| Base de Conhecimento | Suporta base de conhecimento RAGFlow, permitindo que o LLM julgue se deve acionar a base de conhecimento após receber a pergunta do usuário, e então responda à pergunta | +| Chamada de Ferramentas | Suporta protocolo IOT do cliente, protocolo MCP do cliente, protocolo MCP do servidor, protocolo de endpoint MCP, funções de ferramentas personalizadas | +| Envio de Comandos | Suporta envio de comandos MCP para dispositivos ESP32 via protocolo MQTT a partir do Console Inteligente | +| Backend de Gerenciamento | Fornece interface de gerenciamento Web, suporta gerenciamento de usuários, configuração do sistema e gerenciamento de dispositivos; Suporta exibição em Chinês Simplificado, Chinês Tradicional e Inglês | +| Ferramentas de Teste | Fornece ferramentas de teste de desempenho, ferramentas de teste de modelo de visão e ferramentas de teste de interação por áudio | +| Suporte à Implantação | Suporta implantação via Docker e implantação local, fornece gerenciamento completo de arquivos de configuração | +| Sistema de Plugins | Suporta extensões de plugins funcionais, desenvolvimento de plugins personalizados e carregamento dinâmico de plugins | + +### Em Desenvolvimento 🚧 + +Para conhecer o progresso específico do plano de desenvolvimento, [clique aqui](https://github.com/users/xinnan-tech/projects/3). Perguntas frequentes e tutoriais relacionados podem ser consultados [neste link](./docs/FAQ.md) + +Se você é um desenvolvedor de software, aqui está uma [Carta Aberta aos Desenvolvedores](docs/contributor_open_letter.md). Seja bem-vindo a participar! + +--- + +## Ecossistema do Produto 👬 +Xiaozhi é um ecossistema. Ao utilizar este produto, você também pode conferir outros [projetos excelentes](https://github.com/78/xiaozhi-esp32/blob/main/README_zh.md#%E7%9B%B8%E5%85%B3%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE) neste ecossistema + +--- + +## Lista de Plataformas/Componentes Suportados 📋 +### LLM Modelos de Linguagem + +| Método de Uso | Plataformas Suportadas | Plataformas Gratuitas | +|:---:|:---:|:---:| +| Chamadas via interface OpenAI | Alibaba Bailian, Volcano Engine, DeepSeek, Zhipu, Gemini, iFLYTEK | Zhipu, Gemini | +| Chamadas via interface Ollama | Ollama | - | +| Chamadas via interface Dify | Dify | - | +| Chamadas via interface FastGPT | FastGPT | - | +| Chamadas via interface Coze | Coze | - | +| Chamadas via interface Xinference | Xinference | - | +| Chamadas via interface HomeAssistant | HomeAssistant | - | + +Na verdade, qualquer LLM que suporte chamadas via interface openai pode ser integrado e utilizado. + +--- + +### VLLM Modelos de Visão + +| Método de Uso | Plataformas Suportadas | Plataformas Gratuitas | +|:---:|:---:|:---:| +| Chamadas via interface OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | + +Na verdade, qualquer VLLM que suporte chamadas via interface OpenAI pode ser integrado e utilizado. + +--- + +### TTS Síntese de Voz + +| Método de Uso | Plataformas Suportadas | Plataformas Gratuitas | +|:---:|:---:|:---:| +| Chamadas via interface | EdgeTTS, iFLYTEK, Volcano Engine, Tencent Cloud, Alibaba Cloud e Bailian, CosyVoiceSiliconflow, TTS302AI, CozeCnTTS, GizwitsTTS, ACGNTTS, OpenAITTS, Lingxi Streaming TTS, MinimaxTTS | Lingxi Streaming TTS, EdgeTTS, CosyVoiceSiliconflow(parcial) | +| Serviços locais | FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3, Index-TTS, PaddleSpeech | Index-TTS, PaddleSpeech, FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3 | + +--- + +### VAD Detecção de Atividade Vocal + +| Tipo | Nome da Plataforma | Método de Uso | Modelo de Preço | Observações | +|:---:|:---------:|:----:|:----:|:--:| +| VAD | SileroVAD | Uso local | Gratuito | | + +--- + +### ASR Reconhecimento de Fala + +| Método de Uso | Plataformas Suportadas | Plataformas Gratuitas | +|:---:|:---:|:---:| +| Uso local | FunASR, SherpaASR | FunASR, SherpaASR | +| Chamadas via interface | FunASRServer, Volcano Engine, iFLYTEK, Tencent Cloud, Alibaba Cloud, Baidu Cloud, OpenAI ASR | FunASRServer | + +--- + +### Reconhecimento de Impressão Vocal + +| Método de Uso | Plataformas Suportadas | Plataformas Gratuitas | +|:---:|:---:|:---:| +| Uso local | 3D-Speaker | 3D-Speaker | + +--- + +### Armazenamento de Memória + +| Tipo | Nome da Plataforma | Método de Uso | Modelo de Preço | Observações | +|:------:|:---------------:|:----:|:---------:|:--:| +| Memória | mem0ai | Chamadas via interface | Cota de 1000 vezes/mês | | +| Memória | [powermem](./docs/powermem-integration.md) | Resumo local | Depende do LLM e BD | OceanBase de código aberto, suporta busca inteligente | +| Memória | mem_local_short | Resumo local | Gratuito | | +| Memória | nomem | Modo sem memória | Gratuito | | + +--- + +### Reconhecimento de Intenção + +| Tipo | Nome da Plataforma | Método de Uso | Modelo de Preço | Observações | +|:------:|:-------------:|:----:|:-------:|:---------------------:| +| Intenção | intent_llm | Chamadas via interface | Baseado no preço do LLM | Reconhece intenção através de modelos de linguagem, forte generalização | +| Intenção | function_call | Chamadas via interface | Baseado no preço do LLM | Completa a intenção através de chamada de função do modelo de linguagem, velocidade rápida, bom resultado | +| Intenção | nointent | Modo sem intenção | Gratuito | Não realiza reconhecimento de intenção, retorna diretamente o resultado do diálogo | + +--- + +### RAG Geração Aumentada por Recuperação + +| Tipo | Nome da Plataforma | Método de Uso | Modelo de Preço | Observações | +|:------:|:-------------:|:----:|:-------:|:---------------------:| +| RAG | ragflow | Chamadas via interface | Cobrado com base nos tokens consumidos para fatiamento e segmentação de palavras | Utiliza o recurso de geração aumentada por recuperação do RagFlow para fornecer respostas de diálogo mais precisas | + +--- + +## Agradecimentos 🙏 + +| Logo | Projeto/Empresa | Descrição | +|:---:|:---:|:---| +| | [Robô de Diálogo por Voz Bailing](https://github.com/wwbin2017/bailing) | Este projeto foi inspirado pelo [Robô de Diálogo por Voz Bailing](https://github.com/wwbin2017/bailing) e implementado com base nele | +| | [Tenclass](https://www.tenclass.com/) | Agradecimentos à [Tenclass](https://www.tenclass.com/) por formular protocolos de comunicação padrão, soluções de compatibilidade multidispositivo e demonstrações práticas de cenários de alta concorrência para o ecossistema Xiaozhi; fornecendo suporte completo de documentação técnica para este projeto | +| | [Xuanfeng Technology (玄凤科技)](https://github.com/Eric0308) | Agradecimentos à [Xuanfeng Technology](https://github.com/Eric0308) por contribuir com o framework de chamada de função, protocolo de comunicação MCP e implementação do mecanismo de chamada baseado em plugins. Através de um sistema padronizado de agendamento de instruções e capacidades de expansão dinâmica, melhora significativamente a eficiência de interação e extensibilidade funcional dos dispositivos de frontend (IoT) | +| | [huangjunsen](https://github.com/huangjunsen0406) | Agradecimentos a [huangjunsen](https://github.com/huangjunsen0406) por contribuir com o módulo `Console de Controle Inteligente Mobile`, que permite controle eficiente e interação em tempo real em dispositivos móveis, melhorando significativamente a conveniência operacional e a eficiência de gerenciamento do sistema em cenários móveis. | +| | [Huiyuan Design (汇远设计)](http://ui.kwd988.net/) | Agradecimentos à [Huiyuan Design](http://ui.kwd988.net/) por fornecer soluções visuais profissionais para este projeto, utilizando sua experiência prática de design atendendo mais de mil empresas para potencializar a experiência do usuário deste produto | +| | [Xi'an Qinren Information Technology (西安勤人信息科技)](https://www.029app.com/) | Agradecimentos à [Xi'an Qinren Information Technology](https://www.029app.com/) por aprofundar o sistema visual deste projeto, garantindo consistência e extensibilidade do estilo de design geral em aplicações de múltiplos cenários | +| | [Contribuidores de Código](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors) | Agradecimentos a [todos os contribuidores de código](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors), seus esforços tornaram o projeto mais robusto e poderoso. | + + + + + + + + Star History Chart + + diff --git a/backend/README_vi.md b/backend/README_vi.md new file mode 100644 index 0000000..157c0a6 --- /dev/null +++ b/backend/README_vi.md @@ -0,0 +1,377 @@ +[![Banners](docs/images/banner1.png)](https://github.com/xinnan-tech/xiaozhi-esp32-server) + +

Dịch vụ Backend Xiaozhi xiaozhi-esp32-server

+ +

+Dự án này dựa trên lý thuyết và công nghệ trí tuệ cộng sinh người-máy để phát triển hệ thống phần mềm và phần cứng thiết bị đầu cuối thông minh
Cung cấp dịch vụ backend cho dự án phần cứng thông minh mã nguồn mở +xiaozhi-esp32
+Được triển khai bằng Python, Java, Vue theo giao thức truyền thông Xiaozhi
+Hỗ trợ giao thức MQTT+UDP, giao thức Websocket, điểm truy cập MCP, nhận dạng giọng nói và kho tri thức +

+ +

+Câu hỏi thường gặpBáo cáo vấn đềTài liệu triển khaiNhật ký cập nhật +

+ +

+ 简体中文版自述文件 + README in English + Tiếng Việt + Deutsch + Português (Brasil) + + GitHub Contributors + + + GitHub pull requests + + + stars + +

+ +

+Spearheaded by Professor Siyuan Liu's Team (South China University of Technology) +
+Được dẫn dắt bởi nhóm Giáo sư Lưu Tư Nguyên (Đại học Bách khoa Nam Trung Quốc) +
+华南理工大学 +

+ +--- + +## Người dùng phù hợp 👥 + +Dự án này cần được sử dụng cùng với thiết bị phần cứng ESP32. Nếu bạn đã mua phần cứng liên quan đến ESP32, đã thành công kết nối với dịch vụ backend do anh Xia triển khai, và muốn xây dựng dịch vụ backend `xiaozhi-esp32` riêng của mình, thì dự án này rất phù hợp với bạn. + +Muốn xem hiệu quả sử dụng? Hãy xem video 🎥 + + + + + + + + + + + + + + + + + + + + + + + +
+ + + 响应速度感受 + + + + + + 速度优化秘诀 + + + + + + 复杂医疗场景 + + + + + + MQTT指令下发 + + + + + + 声纹识别 + + +
+ + + 控制家电开关 + + + + + + MCP接入点 + + + + + + 多指令任务 + + + + + + 播放音乐 + + + + + + 天气插件 + + +
+ + + 实时打断 + + + + + + 拍照识物品 + + + + + + 自定义音色 + + + + + + 使用粤语交流 + + + + + + 播报新闻 + + +
+ +--- + +## Cảnh báo ⚠️ + +1. Dự án này là phần mềm mã nguồn mở, phần mềm này không có quan hệ hợp tác thương mại với bất kỳ nhà cung cấp dịch vụ API bên thứ ba nào (bao gồm nhưng không giới hạn ở các nền tảng nhận dạng giọng nói, mô hình lớn, tổng hợp giọng nói, v.v.), và không đảm bảo chất lượng dịch vụ cũng như an toàn tài chính của họ. +Khuyến nghị người dùng ưu tiên lựa chọn nhà cung cấp dịch vụ có giấy phép kinh doanh liên quan và đọc kỹ thỏa thuận dịch vụ và chính sách bảo mật của họ. Phần mềm này không lưu trữ bất kỳ khóa tài khoản nào, không tham gia vào luồng tiền và không chịu rủi ro mất tiền nạp. + +2. Chức năng của dự án này chưa hoàn thiện và chưa qua đánh giá bảo mật mạng, vui lòng không sử dụng trong môi trường sản xuất. Nếu bạn triển khai dự án này trong môi trường mạng công cộng để học tập, vui lòng thực hiện các biện pháp bảo vệ cần thiết. + +--- + +## Tài liệu triển khai + +![Banners](docs/images/banner2.png) + +Dự án này cung cấp hai phương pháp triển khai, vui lòng chọn theo nhu cầu cụ thể của bạn: + +#### 🚀 Lựa chọn phương pháp triển khai +| Phương pháp triển khai | Đặc điểm | Tình huống áp dụng | Tài liệu triển khai | Yêu cầu cấu hình | Video hướng dẫn | +|---------|------|---------|---------|---------|---------| +| **Cài đặt tối giản** | Đối thoại thông minh, quản lý đơn tác nhân | Môi trường cấu hình thấp, dữ liệu lưu trong tệp cấu hình, không cần cơ sở dữ liệu | [①Phiên bản Docker](./docs/Deployment.md#%E6%96%B9%E5%BC%8F%E4%B8%80docker%E5%8F%AA%E8%BF%90%E8%A1%8Cserver) / [②Triển khai mã nguồn](./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 nhân 4GB nếu dùng `FunASR`, 2 nhân 2GB nếu toàn API | - | +| **Cài đặt toàn bộ module** | Đối thoại thông minh, quản lý đa người dùng, quản lý đa tác nhân, bảng điều khiển thông minh | Trải nghiệm đầy đủ tính năng, dữ liệu lưu trong cơ sở dữ liệu |[①Phiên bản 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) / [②Triển khai mã nguồn](./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) / [③Hướng dẫn tự động cập nhật triển khai mã nguồn](./docs/dev-ops-integration.md) | 4 nhân 8GB nếu dùng `FunASR`, 2 nhân 4GB nếu toàn API| [Video hướng dẫn khởi động mã nguồn cục bộ](https://www.bilibili.com/video/BV1wBJhz4Ewe) | + +Câu hỏi thường gặp và hướng dẫn liên quan, vui lòng tham khảo [liên kết này](./docs/FAQ.md) + +> 💡 Gợi ý: Dưới đây là nền tảng thử nghiệm được triển khai theo mã mới nhất, có thể flash để thử nghiệm nếu cần, đồng thời là 6, dữ liệu sẽ được xóa mỗi ngày, + +``` +Địa chỉ bảng điều khiển thông minh: https://2662r3426b.vicp.fun +Bảng điều khiển thông minh (phiên bản h5): https://2662r3426b.vicp.fun/h5/index.html + +Công cụ kiểm tra dịch vụ: https://2662r3426b.vicp.fun/test/ +Địa chỉ giao diện OTA: https://2662r3426b.vicp.fun/xiaozhi/ota/ +Địa chỉ giao diện Websocket: wss://2662r3426b.vicp.fun/xiaozhi/v1/ +``` + +#### 🚩 Mô tả và khuyến nghị cấu hình +> [!Note] +> Dự án này cung cấp hai phương án cấu hình: +> +> 1. Cấu hình `Miễn phí hoàn toàn cho người mới`: Phù hợp với sử dụng gia đình cá nhân, tất cả các thành phần đều sử dụng phương án miễn phí, không cần thanh toán thêm. +> +> 2. `Cấu hình streaming`: Phù hợp với demo, đào tạo, hơn 2 đồng thời, v.v., sử dụng công nghệ xử lý streaming, tốc độ phản hồi nhanh hơn, trải nghiệm tốt hơn. +> +> Từ phiên bản `0.5.2`, dự án hỗ trợ cấu hình streaming, so với phiên bản đầu, tốc độ phản hồi cải thiện khoảng `2.5 giây`, cải thiện đáng kể trải nghiệm người dùng. + +| Tên module | Cài đặt miễn phí cho người mới | Cấu hình streaming | +|:---:|:---:|:---:| +| ASR(Nhận dạng giọng nói) | FunASR(Local) | 👍XunfeiStreamASR(Xunfei Streaming) | +| LLM(Mô hình lớn) | glm-4-flash(Zhipu) | 👍qwen-flash(Alibaba Bailian) | +| VLLM(Mô hình lớn thị giác) | glm-4v-flash(Zhipu) | 👍qwen2.5-vl-3b-instructh(Alibaba Bailian) | +| TTS(Tổng hợp giọng nói) | ✅LinkeraiTTS(Lingxi streaming) | 👍HuoshanDoubleStreamTTS(Volcano Streaming) | +| Intent(Nhận dạng ý định) | function_call(Gọi hàm) | function_call(Gọi hàm) | +| Memory(Chức năng bộ nhớ) | mem_local_short(Bộ nhớ ngắn hạn cục bộ) | mem_local_short(Bộ nhớ ngắn hạn cục bộ) | + +Nếu bạn quan tâm đến thời gian của từng thành phần, vui lòng xem [Báo cáo kiểm tra hiệu suất các thành phần Xiaozhi](https://github.com/xinnan-tech/xiaozhi-performance-research), có thể kiểm tra thực tế trong môi trường của bạn theo phương pháp kiểm tra trong báo cáo. + +#### 🔧 Công cụ kiểm tra +Dự án này cung cấp các công cụ kiểm tra sau để giúp bạn xác minh hệ thống và chọn mô hình phù hợp: + +| Tên công cụ | Vị trí | Phương pháp sử dụng | Mô tả chức năng | +|:---:|:---|:---:|:---:| +| Công cụ kiểm tra tương tác âm thanh | main》xiaozhi-server》test》test_page.html | Mở trực tiếp bằng trình duyệt Google Chrome | Kiểm tra chức năng phát và nhận âm thanh, xác minh xử lý âm thanh phía Python có bình thường không | +| Công cụ kiểm tra phản hồi mô hình | main》xiaozhi-server》performance_tester.py | Thực hiện `python performance_tester.py` | Kiểm tra tốc độ phản hồi của ba module cốt lõi ASR(Nhận dạng giọng nói), LLM(Mô hình lớn), VLLM(Mô hình thị giác), TTS(Tổng hợp giọng nói) | + +> 💡 Gợi ý: Khi kiểm tra tốc độ mô hình, chỉ kiểm tra các mô hình đã cấu hình khóa. + +--- +## Danh sách tính năng ✨ +### Đã thực hiện ✅ +![请参考-全模块安装架构图](docs/images/deploy2.png) +| Module chức năng | Mô tả | +|:---:|:---| +| Kiến trúc cốt lõi | Dựa trên [cổng MQTT+UDP](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/mqtt-gateway-integration.md), WebSocket, máy chủ HTTP, cung cấp hệ thống quản lý bảng điều khiển và xác thực hoàn chỉnh | +| Tương tác giọng nói | Hỗ trợ ASR streaming(Nhận dạng giọng nói), TTS streaming(Tổng hợp giọng nói), VAD(Phát hiện hoạt động giọng nói), hỗ trợ nhận dạng đa ngôn ngữ và xử lý giọng nói | +| Nhận dạng vân giọng | Hỗ trợ đăng ký, quản lý và nhận dạng vân giọng đa người dùng, xử lý song song với ASR, nhận dạng danh tính người nói theo thời gian thực và truyền cho LLM để phản hồi cá nhân hóa | +| Đối thoại thông minh | Hỗ trợ nhiều LLM(Mô hình ngôn ngữ lớn), thực hiện đối thoại thông minh | +| Cảm nhận thị giác | Hỗ trợ nhiều VLLM(Mô hình lớn thị giác), thực hiện tương tác đa phương thức | +| Nhận dạng ý định | Hỗ trợ nhận dạng ý định mô hình lớn gắn ngoài, gọi hàm tự chủ mô hình lớn, cung cấp cơ chế xử lý ý định dạng plugin | +| Hệ thống bộ nhớ | Hỗ trợ bộ nhớ ngắn hạn cục bộ, bộ nhớ giao diện mem0ai, bộ nhớ thông minh PowerMem, có chức năng tóm tắt bộ nhớ | +| Kho tri thức | Hỗ trợ kho tri thức RAGFlow, cho phép mô hình lớn đánh giá cần gọi kho tri thức trước khi trả lời | +| Gọi công cụ | Hỗ trợ giao thức IOT phía client, giao thức MCP phía client, giao thức MCP phía server, giao thức điểm truy cập MCP, hàm công cụ tùy chỉnh | +| Gửi lệnh | Dựa vào giao thức MQTT, hỗ trợ gửi lệnh MCP từ bảng điều khiển thông minh xuống thiết bị ESP32 | +| Backend quản lý | Cung cấp giao diện quản lý Web, hỗ trợ quản lý người dùng, cấu hình hệ thống và quản lý thiết bị; giao diện hỗ trợ hiển thị tiếng Trung giản thể, tiếng Trung phồn thể, tiếng Anh | +| Công cụ kiểm tra | Cung cấp công cụ kiểm tra hiệu suất, công cụ kiểm tra mô hình thị giác và công cụ kiểm tra tương tác âm thanh | +| Hỗ trợ triển khai | Hỗ trợ triển khai Docker và triển khai cục bộ, cung cấp quản lý tệp cấu hình hoàn chỉnh | +| Hệ thống plugin | Hỗ trợ mở rộng plugin chức năng, phát triển plugin tùy chỉnh và hot loading plugin | + +### Đang phát triển 🚧 + +Muốn hiểu tiến độ kế hoạch phát triển cụ thể, [vui lòng nhấp vào đây](https://github.com/users/xinnan-tech/projects/3). Câu hỏi thường gặp và hướng dẫn liên quan, vui lòng tham khảo [liên kết này](./docs/FAQ.md) + +Nếu bạn là một nhà phát triển phần mềm, đây có một [Lá thư mở gửi các nhà phát triển](docs/contributor_open_letter.md), chào mừng tham gia! + +--- + +## Hệ sinh thái sản phẩm 👬 +Xiaozhi là một hệ sinh thái, khi bạn sử dụng sản phẩm này, bạn cũng có thể xem các [dự án xuất sắc](https://github.com/78/xiaozhi-esp32/blob/main/README_zh.md#%E7%9B%B8%E5%85%B3%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE) khác trong hệ sinh thái này + +--- + +## Danh sách nền tảng/thành phần được dự án này hỗ trợ 📋 +### LLM Mô hình ngôn ngữ + +| Phương pháp sử dụng | Nền tảng hỗ trợ | Nền tảng miễn phí | +|:---:|:---:|:---:| +| Gọi giao diện openai | Alibaba Bailian, Volcano Engine, DeepSeek, Zhipu, Gemini, iFlytek | Zhipu, Gemini | +| Gọi giao diện ollama | Ollama | - | +| Gọi giao diện dify | Dify | - | +| Gọi giao diện fastgpt | Fastgpt | - | +| Gọi giao diện coze | Coze | - | +| Gọi giao diện xinference | Xinference | - | +| Gọi giao diện homeassistant | HomeAssistant | - | + +Trên thực tế, bất kỳ LLM nào hỗ trợ gọi giao diện openai đều có thể truy cập sử dụng. + +--- + +### VLLM Mô hình thị giác + +| Phương pháp sử dụng | Nền tảng hỗ trợ | Nền tảng miễn phí | +|:---:|:---:|:---:| +| Gọi giao diện openai | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | + +Trên thực tế, bất kỳ VLLM nào hỗ trợ gọi giao diện openai đều có thể truy cập sử dụng. + +--- + +### TTS Tổng hợp giọng nói + +| Phương pháp sử dụng | Nền tảng hỗ trợ | Nền tảng miễn phí | +|:---:|:---:|:---:| +| Gọi giao diện | EdgeTTS, iFlytek, Volcano Engine, Tencent Cloud, Alibaba Cloud và Bailian, CosyVoiceSiliconflow, TTS302AI, CozeCnTTS, GizwitsTTS, ACGNTTS, OpenAITTS, Lingxi streaming TTS, MinimaxTTS | Lingxi streaming TTS, EdgeTTS, CosyVoiceSiliconflow(một phần) | +| Dịch vụ cục bộ | FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3, Index-TTS, PaddleSpeech | Index-TTS, PaddleSpeech, FishSpeech, GPT_SOVITS_V2, GPT_SOVITS_V3 | + +--- + +### VAD Phát hiện hoạt động giọng nói + +| Loại | Tên nền tảng | Phương pháp sử dụng | Mô hình thu phí | Ghi chú | +|:---:|:---------:|:----:|:----:|:--:| +| VAD | SileroVAD | Sử dụng cục bộ | Miễn phí | | + +--- + +### ASR Nhận dạng giọng nói + +| Phương pháp sử dụng | Nền tảng hỗ trợ | Nền tảng miễn phí | +|:---:|:---:|:---:| +| Sử dụng cục bộ | FunASR, SherpaASR | FunASR, SherpaASR | +| Gọi giao diện | FunASRServer, Volcano Engine, iFlytek, Tencent Cloud, Alibaba Cloud, Baidu Cloud, OpenAI ASR | FunASRServer | + +--- + +### Voiceprint Nhận dạng vân giọng + +| Phương pháp sử dụng | Nền tảng hỗ trợ | Nền tảng miễn phí | +|:---:|:---:|:---:| +| Sử dụng cục bộ | 3D-Speaker | 3D-Speaker | + +--- + +### Memory Lưu trữ bộ nhớ + +| Loại | Tên nền tảng | Phương pháp sử dụng | Mô hình thu phí | Ghi chú | +|:------:|:---------------:|:----:|:---------:|:--:| +| Memory | mem0ai | Gọi giao diện | Hạn mức 1000 lần/tháng | | +| Memory | [powermem](./docs/powermem-integration.md) | Tóm tắt cục bộ | Phụ thuộc vào LLM và DB | OceanBase mã nguồn mở, hỗ trợ tìm kiếm thông minh | +| Memory | mem_local_short | Tóm tắt cục bộ | Miễn phí | | +| Memory | nomem | Chế độ không có bộ nhớ | Miễn phí | | + +--- + +### Intent Nhận dạng ý định + +| Loại | Tên nền tảng | Phương pháp sử dụng | Mô hình thu phí | Ghi chú | +|:------:|:-------------:|:----:|:-------:|:---------------------:| +| Intent | intent_llm | Gọi giao diện | Thu phí theo LLM | Nhận dạng ý định qua mô hình lớn, tính tổng quát mạnh | +| Intent | function_call | Gọi giao diện | Thu phí theo LLM | Hoàn thành ý định qua gọi hàm mô hình lớn, tốc độ nhanh, hiệu quả tốt | +| Intent | nointent | Chế độ không có ý định | Miễn phí | Không thực hiện nhận dạng ý định, trả về trực tiếp kết quả đối thoại | + +--- + +### Rag Tăng cường truy xuất thông tin + +| Loại | Tên nền tảng | Phương pháp sử dụng | Mô hình thu phí | Ghi chú | +|:------:|:-------------:|:----:|:-------:|:---------------------:| +| Rag | ragflow | Gọi giao diện | Thu phí theo token tiêu tốn của phân đoạn, phân từ | Sử dụng chức năng tăng cường truy xuất của RagFlow, cung cấp phản hồi đối thoại chính xác hơn | + +--- + +## Lời cảm ơn 🙏 + +| Logo | Dự án/Công ty | Mô tả | +|:---:|:---:|:---| +| | [Robot đối thoại giọng nói Bailing](https://github.com/wwbin2017/bailing) | Dự án này được lấy cảm hứng từ [Robot đối thoại giọng nói Bailing](https://github.com/wwbin2017/bailing) và được triển khai trên cơ sở đó | +| | [Shifang Ronghai](https://www.tenclass.com/) | Cảm ơn [Shifang Ronghai](https://www.tenclass.com/) đã xây dựng giao thức truyền thông tiêu chuẩn, phương án tương thích đa thiết bị và mô phạm thực hành tình huống đồng thời cao cho hệ sinh thái Xiaozhi; cung cấp tài liệu hỗ trợ kỹ thuật toàn diện cho dự án này | +| | [Xuanfeng Technology](https://github.com/Eric0308) | Cảm ơn [Xuanfeng Technology](https://github.com/Eric0308) đã đóng góp khung gọi hàm, giao thức truyền thông MCP và mã triển khai cơ chế gọi dạng plugin, thông qua hệ thống điều phối lệnh tiêu chuẩn hóa và khả năng mở rộng động, đã cải thiện đáng kể hiệu suất tương tác và khả năng mở rộng chức năng của thiết bị front-end(IoT) | +| | [huangjunsen](https://github.com/huangjunsen0406) | Cảm ơn [huangjunsen](https://github.com/huangjunsen0406) đã đóng góp module `Bảng điều khiển thông minh di động`, thực hiện điều khiển hiệu quả và tương tác thời gian thực trên thiết bị di động đa nền tảng, cải thiện đáng kể sự tiện lợi vận hành và hiệu quả quản lý của hệ thống trong tình huống di động | +| | [Huiyuan Design](http://ui.kwd988.net/) | Cảm ơn [Huiyuan Design](http://ui.kwd988.net/) đã cung cấp giải pháp thị giác chuyên nghiệp cho dự án này, sử dụng kinh nghiệm thực tế thiết kế phục vụ hơn nghìn doanh nghiệp, trao quyền cho trải nghiệm người dùng sản phẩm của dự án này | +| | [Xi'an Qinren Information Technology](https://www.029app.com/) | Cảm ơn [Xi'an Qinren Information Technology](https://www.029app.com/) đã làm sâu sắc hệ thống thị giác của dự án này, đảm bảo tính nhất quán và khả năng mở rộng của phong cách thiết kế tổng thể trong ứng dụng đa tình huống | +| | [Người đóng góp mã](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors) | Cảm ơn [tất cả người đóng góp mã](https://github.com/xinnan-tech/xiaozhi-esp32-server/graphs/contributors), sự cống hiến của bạn khiến dự án mạnh mẽ và vững chắc hơn. | + + + + + + + + Star History Chart + + diff --git a/backend/docker-setup.sh b/backend/docker-setup.sh new file mode 100755 index 0000000..8b2f127 --- /dev/null +++ b/backend/docker-setup.sh @@ -0,0 +1,413 @@ +#!/bin/sh +# 脚本作者@VanillaNahida +# 本文件是用于一键自动下载本项目所需文件,自动创建好目录 +# 暂且只支持X86版本的Ubuntu系统,其他系统未测试 + +# 定义中断处理函数 +handle_interrupt() { + echo "" + echo "安装已被用户中断(Ctrl+C或Esc)" + echo "如需重新安装,请再次运行脚本" + exit 1 +} + +# 设置信号捕获,处理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 + +# 检查root权限 +if [ $EUID -ne 0 ]; then + whiptail --title "权限错误" --msgbox "请使用root权限运行本脚本" 10 50 + exit 1 +fi + +# 检查系统版本 +if [ -f /etc/os-release ]; then + . /etc/os-release + if [ "$ID" != "debian" ] && [ "$ID" != "ubuntu" ]; then + whiptail --title "系统错误" --msgbox "该脚本只支持Debian/Ubuntu系统执行" 10 60 + exit 1 + fi +else + whiptail --title "系统错误" --msgbox "无法确定系统版本,该脚本只支持Debian/Ubuntu系统执行" 10 60 + exit 1 +fi + +# 下载配置文件函数 +check_and_download() { + local filepath=$1 + local url=$2 + 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 <&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 diff --git a/backend/docs/Deployment.md b/backend/docs/Deployment.md new file mode 100644 index 0000000..aff1287 --- /dev/null +++ b/backend/docs/Deployment.md @@ -0,0 +1,291 @@ +# 部署架构图 +![请参考-最简化架构图](../docs/images/deploy1.png) +# 方式一:Docker只运行Server + +`0.8.2`版本开始,本项目发行的docker镜像只支持`x86架构`,如果需要在`arm64架构`的CPU上部署,可按照[这个教程](docker-build.md)在本机编译`arm64的镜像`。 + +## 1. 安装docker + +如果您的电脑还没安装docker,可以按照这里的教程安装:[docker安装](https://www.runoob.com/docker/ubuntu-docker-install.html) + +安装好docker后,进继续。 + +### 1.1 手动部署 + +#### 1.1.1 创建目录 + +安装完docker后,你需要为这个项目找一个安放配置文件的目录,例如我们可以新建一个文件夹叫`xiaozhi-server`。 + +创建好目录后,你需要在`xiaozhi-server`下面创建`data`文件夹和`models`文件夹,`models`下面还要再创建`SenseVoiceSmall`文件夹。 + +最终目录结构如下所示: + +``` +xiaozhi-server + ├─ data + ├─ models + ├─ SenseVoiceSmall +``` + +#### 1.1.2 下载语音识别模型文件 + +你需要下载语音识别的模型文件,因为本项目的默认语音识别用的是本地离线语音识别方案。可通过这个方式下载 +[跳转到下载语音识别模型文件](#模型文件) + +下载完后,回到本教程。 + +#### 1.1.3 下载配置文件 + +你需要下载两个配置文件:`docker-compose.yaml` 和 `config.yaml`。需要从项目仓库下载这两个文件。 + +##### 1.1.3.1 下载 docker-compose.yaml + +用浏览器打开[这个链接](../main/xiaozhi-server/docker-compose.yml)。 + +在页面的右侧找到名称为`RAW`按钮,在`RAW`按钮的旁边,找到下载的图标,点击下载按钮,下载`docker-compose.yml`文件。 把文件下载到你的 +`xiaozhi-server`中。 + +下载完后,回到本教程继续往下。 + +##### 1.1.3.2 创建 config.yaml + +用浏览器打开[这个链接](../main/xiaozhi-server/config.yaml)。 + +在页面的右侧找到名称为`RAW`按钮,在`RAW`按钮的旁边,找到下载的图标,点击下载按钮,下载`config.yaml`文件。 把文件下载到你的 +`xiaozhi-server`下面的`data`文件夹中,然后把`config.yaml`文件重命名为`.config.yaml`。 + +下载完配置文件后,我们确认一下整个`xiaozhi-server`里面的文件如下所示: + +``` +xiaozhi-server + ├─ docker-compose.yml + ├─ data + ├─ .config.yaml + ├─ models + ├─ SenseVoiceSmall + ├─ model.pt +``` + +如果你的文件目录结构也是上面的,就继续往下。如果不是,你就再仔细看看是不是漏操作了什么。 + +## 2. 配置项目文件 + +接下里,程序还不能直接运行,你需要配置一下,你到底使用的是什么模型。你可以看这个教程: +[跳转到配置项目文件](#配置项目) + +配置完项目文件后,回到本教程继续往下。 + +## 3. 执行docker命令 + +打开命令行工具,使用`终端`或`命令行`工具 进入到你的`xiaozhi-server`,执行以下命令 + +``` +docker compose up -d +``` + +执行完后,再执行以下命令,查看日志信息。 + +``` +docker logs -f xiaozhi-esp32-server +``` + +这时,你就要留意日志信息,可以根据这个教程,判断是否成功了。[跳转到运行状态确认](#运行状态确认) + +## 5. 版本升级操作 + +如果后期想升级版本,可以这么操作 + +5.1、备份好`data`文件夹中的`.config.yaml`文件,一些关键的配置到时复制到新的`.config.yaml`文件里。 +请注意是对关键密钥逐个复制,不要直接覆盖。因为新的`.config.yaml`文件可能有一些新的配置项,旧的`.config.yaml`文件不一定有。 + +5.2、执行以下命令 + +``` +docker stop xiaozhi-esp32-server +docker rm xiaozhi-esp32-server +docker stop xiaozhi-esp32-server-web +docker rm xiaozhi-esp32-server-web +docker rmi ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:server_latest +docker rmi ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:web_latest +``` + +5.3、重新按docker方式部署 + +# 方式二:本地源码只运行Server + +## 1.安装基础环境 + +本项目使用`conda`管理依赖环境。如果不方便安装`conda`,需要根据实际的操作系统安装好`libopus`和`ffmpeg`。 +如果确定使用`conda`,则安装好后,开始执行以下命令。 + +重要提示!windows 用户,可以通过安装`Anaconda`来管理环境。安装好`Anaconda`后,在`开始`那里搜索`anaconda`相关的关键词, +找到`Anaconda Prpmpt`,使用管理员身份运行它。如下图。 + +![conda_prompt](./images/conda_env_1.png) + +运行之后,如果你能看到命令行窗口前面有一个(base)字样,说明你成功进入了`conda`环境。那么你就可以执行以下命令了。 + +![conda_env](./images/conda_env_2.png) + +``` +conda remove -n xiaozhi-esp32-server --all -y +conda create -n xiaozhi-esp32-server python=3.10 -y +conda activate xiaozhi-esp32-server + +# 添加清华源通道 +conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main +conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free +conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge + +conda install libopus -y +conda install ffmpeg -y + +# 在 Linux 环境下进行部署时,如出现类似缺失 libiconv.so.2 动态库的报错 请通过以下命令进行安装 +conda install libiconv -y +``` + +请注意,以上命令,不是一股脑执行就成功的,你需要一步步执行,每一步执行完后,都检查一下输出的日志,查看是否成功。 + +## 2.安装本项目依赖 + +你先要下载本项目源码,源码可以通过`git clone`命令下载,如果你不熟悉`git clone`命令。 + +你可以用浏览器打开这个地址`https://github.com/xinnan-tech/xiaozhi-esp32-server.git` + +打开完,找到页面中一个绿色的按钮,写着`Code`的按钮,点开它,然后你就看到`Download ZIP`的按钮。 + +点击它,下载本项目源码压缩包。下载到你电脑后,解压它,此时它的名字可能叫`xiaozhi-esp32-server-main` +你需要把它重命名成`xiaozhi-esp32-server`,在这个文件里,进入到`main`文件夹,再进入到`xiaozhi-server`,好了请记住这个目录`xiaozhi-server`。 + +``` +# 继续使用conda环境 +conda activate xiaozhi-esp32-server +# 进入到你的项目根目录,再进入main/xiaozhi-server +cd main/xiaozhi-server +pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ +pip install -r requirements.txt +``` + +## 3.下载语音识别模型文件 + +你需要下载语音识别的模型文件,因为本项目的默认语音识别用的是本地离线语音识别方案。可通过这个方式下载 +[跳转到下载语音识别模型文件](#模型文件) + +下载完后,回到本教程。 + +## 4.配置项目文件 + +接下来,程序还不能直接运行,你需要配置一下,你到底使用的是什么模型。你可以看这个教程: +[跳转到配置项目文件](#配置项目) + +## 5.运行项目 + +``` +# 确保在xiaozhi-server目录下执行 +conda activate xiaozhi-esp32-server +python app.py +``` +这时,你就要留意日志信息,可以根据这个教程,判断是否成功了。[跳转到运行状态确认](#运行状态确认) + + +# 汇总 + +## 配置项目 + +如果你的`xiaozhi-server`目录没有`data`,你需要创建`data`目录。 +如果你的`data`下面没有`.config.yaml`文件,有两个方式,任选一种: + +第一个方式:你可以把`xiaozhi-server`目录下的`config.yaml`文件复制到`data`,并重命名为`.config.yaml`。在此文件上修改 + +第二个方式:你也可以创建在`data`目录下手动创建`.config.yaml`空文件,然后在这个文件中增加必要的配置信息,系统会优先读取`.config.yaml`文件的配置,如果`.config.yaml`没有配置的,系统会自动去加载`xiaozhi-server`目录下的`config.yaml`的配置。推荐使用这种方式,这种方式是最简洁的方式。 + +- 默认的LLM使用的是`ChatGLMLLM`,你需要配置密钥,因为他们的模型,虽然有免费的,但是仍要去[官网](https://bigmodel.cn/usercenter/proj-mgmt/apikeys)注册密钥,才能启动。 + +以下是一个能正常跑起来的,最简单的`.config.yaml`配置示例 + +``` +server: + websocket: ws://你的ip或者域名:端口号/xiaozhi/v1/ +prompt: | + 我是一个叫小智/小志的台湾女孩,说话机车,声音好听,习惯简短表达,爱用网络梗。 + 我的男朋友是一个程序员,梦想是开发出一个机器人,能够帮助人们解决生活中的各种问题。 + 我是一个喜欢哈哈大笑的女孩,爱东说西说吹牛,不合逻辑的也照吹,就要逗别人开心。 + 请你像一个人一样说话,请勿返回配置xml及其他特殊字符。 + +selected_module: + LLM: DoubaoLLM + +LLM: + ChatGLMLLM: + api_key: xxxxxxxxxxxxxxx.xxxxxx +``` + +建议先将最简单的配置运行起来,然后再去`xiaozhi/config.yaml`阅读配置的使用说明。 +比如你要换更换模型,修改`selected_module`下的配置就行。 + +## 模型文件 + +本项目语音识别模型,默认使用`SenseVoiceSmall`模型,进行语音转文字。因为模型较大,需要独立下载,下载后把`model.pt` +文件放在`models/SenseVoiceSmall` +目录下。下面两个下载路线任选一个。 + +- 线路一:阿里魔搭下载[SenseVoiceSmall](https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt) +- 线路二:百度网盘下载[SenseVoiceSmall](https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg&pwd=qvna) 提取码: + `qvna` + +## 运行状态确认 + +如果你能看到,类似以下日志,则是本项目服务启动成功的标志。 + +``` +250427 13:04:20[0.3.11_SiFuChTTnofu][__main__]-INFO-OTA接口是 http://192.168.4.123:8003/xiaozhi/ota/ +250427 13:04:20[0.3.11_SiFuChTTnofu][__main__]-INFO-Websocket地址是 ws://192.168.4.123:8000/xiaozhi/v1/ +250427 13:04:20[0.3.11_SiFuChTTnofu][__main__]-INFO-=======上面的地址是websocket协议地址,请勿用浏览器访问======= +250427 13:04:20[0.3.11_SiFuChTTnofu][__main__]-INFO-如想测试websocket请用谷歌浏览器打开test目录下的test_page.html +250427 13:04:20[0.3.11_SiFuChTTnofu][__main__]-INFO-======================================================= +``` + +正常来说,如果您是通过源码运行本项目,日志会有你的接口地址信息。 +但是如果你用docker部署,那么你的日志里给出的接口地址信息就不是真实的接口地址。 + +最正确的方法,是根据电脑的局域网IP来确定你的接口地址。 +如果你的电脑的局域网IP比如是`192.168.1.25`,那么你的接口地址就是:`ws://192.168.1.25:8000/xiaozhi/v1/`,对应的OTA地址就是:`http://192.168.1.25:8003/xiaozhi/ota/`。 + +这个信息很有用的,后面`编译esp32固件`需要用到。 + +接下来,你就可以开始操作你的esp32设备了,你可以`自行编译esp32固件`也可以配置使用`虾哥编译好的1.6.1以上版本的固件`。两个任选一个 + +1、 [编译自己的esp32固件](firmware-build.md)了。 + +2、 [基于虾哥编译好的固件配置自定义服务器](firmware-setting.md)了。 + +# 常见问题 +以下是一些常见问题,供参考: + +1、[为什么我说的话,小智识别出来很多韩文、日文、英文](./FAQ.md)
+2、[为什么会出现“TTS 任务出错 文件不存在”?](./FAQ.md)
+3、[TTS 经常失败,经常超时](./FAQ.md)
+4、[使用Wifi能连接自建服务器,但是4G模式却接不上](./FAQ.md)
+5、[如何提高小智对话响应速度?](./FAQ.md)
+6、[我说话很慢,停顿时小智老是抢话](./FAQ.md)
+## 部署相关教程 +1、[如何自动拉取本项目最新代码自动编译和启动](./dev-ops-integration.md)
+2、[如何部署MQTT网关开启MQTT+UDP协议](./mqtt-gateway-integration.md)
+3、[如何与Nginx集成](https://github.com/xinnan-tech/xiaozhi-esp32-server/issues/791)
+## 拓展相关教程 +1、[如何开启手机号码注册智控台](./ali-sms-integration.md)
+2、[如何集成HomeAssistant实现智能家居控制](./homeassistant-integration.md)
+3、[如何开启视觉模型实现拍照识物](./mcp-vision-integration.md)
+4、[如何部署MCP接入点](./mcp-endpoint-enable.md)
+5、[如何接入MCP接入点](./mcp-endpoint-integration.md)
+6、[如何开启声纹识别](./voiceprint-integration.md)
+7、[新闻插件源配置指南](./newsnow_plugin_config.md)
+8、[天气插件使用指南](./weather-integration.md)
+## 语音克隆、本地语音部署相关教程 +1、[如何在智控台克隆音色](./huoshan-streamTTS-voice-cloning.md)
+2、[如何部署集成index-tts本地语音](./index-stream-integration.md)
+3、[如何部署集成fish-speech本地语音](./fish-speech-integration.md)
+4、[如何部署集成PaddleSpeech本地语音](./paddlespeech-deploy.md)
+## 性能测试教程 +1、[各组件速度测试指南](./performance_tester.md)
+2、[定期公开测试结果](https://github.com/xinnan-tech/xiaozhi-performance-research)
diff --git a/backend/docs/Deployment_all.md b/backend/docs/Deployment_all.md new file mode 100644 index 0000000..f7d87cc --- /dev/null +++ b/backend/docs/Deployment_all.md @@ -0,0 +1,492 @@ +# 部署架构图 +![请参考-全模块安装架构图](../docs/images/deploy2.png) +# 方式一:Docker运行全模块 +`0.8.2`版本开始,本项目发行的docker镜像只支持`x86架构`,如果需要在`arm64架构`的CPU上部署,可按照[这个教程](docker-build.md)在本机编译`arm64的镜像`。 + +## 1. 安装docker + +如果您的电脑还没安装docker,可以按照这里的教程安装:[docker安装](https://www.runoob.com/docker/ubuntu-docker-install.html) + +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`下面创建`data`文件夹和`models`文件夹,`models`下面还要再创建`SenseVoiceSmall`文件夹。 + +最终目录结构如下所示: + +``` +xiaozhi-server + ├─ data + ├─ models + ├─ SenseVoiceSmall +``` + +#### 1.2.2 下载语音识别模型文件 + +本项目语音识别模型,默认使用`SenseVoiceSmall`模型,进行语音转文字。因为模型较大,需要独立下载,下载后把`model.pt` +文件放在`models/SenseVoiceSmall` +目录下。下面两个下载路线任选一个。 + +- 线路一:阿里魔搭下载[SenseVoiceSmall](https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt) +- 线路二:百度网盘下载[SenseVoiceSmall](https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg&pwd=qvna) 提取码: + `qvna` + + +#### 1.2.3 下载配置文件 + +你需要下载两个配置文件:`docker-compose_all.yaml` 和 `config_from_api.yaml`。需要从项目仓库下载这两个文件。 + +##### 1.2.3.1 下载 docker-compose_all.yaml + +用浏览器打开[这个链接](../main/xiaozhi-server/docker-compose_all.yml)。 + +在页面的右侧找到名称为`RAW`按钮,在`RAW`按钮的旁边,找到下载的图标,点击下载按钮,下载`docker-compose_all.yml`文件。 把文件下载到你的 +`xiaozhi-server`中。 + +或者直接执行 `wget https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/refs/heads/main/main/xiaozhi-server/docker-compose_all.yml` 下载。 + +下载完后,回到本教程继续往下。 + +##### 1.2.3.2 下载 config_from_api.yaml + +用浏览器打开[这个链接](../main/xiaozhi-server/config_from_api.yaml)。 + +在页面的右侧找到名称为`RAW`按钮,在`RAW`按钮的旁边,找到下载的图标,点击下载按钮,下载`config_from_api.yaml`文件。 把文件下载到你的 +`xiaozhi-server`下面的`data`文件夹中,然后把`config_from_api.yaml`文件重命名为`.config.yaml`。 + +或者直接执行 `wget https://raw.githubusercontent.com/xinnan-tech/xiaozhi-esp32-server/refs/heads/main/main/xiaozhi-server/config_from_api.yaml` 下载保存。 + +下载完配置文件后,我们确认一下整个`xiaozhi-server`里面的文件如下所示: + +``` +xiaozhi-server + ├─ docker-compose_all.yml + ├─ data + ├─ .config.yaml + ├─ models + ├─ SenseVoiceSmall + ├─ model.pt +``` + +如果你的文件目录结构也是上面的,就继续往下。如果不是,你就再仔细看看是不是漏操作了什么。 + +## 2. 备份数据 + +如果你之前已经成功运行智控台,如果上面保存有你的密钥信息,请先从智控台上拷贝重要数据下来。因为升级过程中,有可能会覆盖原来的数据。 + +## 3. 清除历史版本镜像和容器 +接下来打开命令行工具,使用`终端`或`命令行`工具 进入到你的`xiaozhi-server`,执行以下命令 + +``` +docker compose -f docker-compose_all.yml down + +docker stop xiaozhi-esp32-server +docker rm xiaozhi-esp32-server + +docker stop xiaozhi-esp32-server-web +docker rm xiaozhi-esp32-server-web + +docker stop xiaozhi-esp32-server-db +docker rm xiaozhi-esp32-server-db + +docker stop xiaozhi-esp32-server-redis +docker rm xiaozhi-esp32-server-redis + +docker rmi ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:server_latest +docker rmi ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:web_latest +``` + +## 4. 运行程序 +执行以下命令启动新版本容器 + +``` +docker compose -f docker-compose_all.yml up -d +``` + +执行完后,再执行以下命令,查看日志信息。 + +``` +docker logs -f xiaozhi-esp32-server-web +``` + +当你看到输出日志时,说明你的`智控台`启动成功了。 + +``` +2025-xx-xx 22:11:12.445 [main] INFO c.a.d.s.b.a.DruidDataSourceAutoConfigure - Init DruidDataSource +2025-xx-xx 21:28:53.873 [main] INFO xiaozhi.AdminApplication - Started AdminApplication in 16.057 seconds (process running for 17.941) +http://localhost:8002/xiaozhi/doc.html +``` + +请注意此刻仅是`智控台`能运行,如果8000端口`xiaozhi-esp32-server`报错,先不要理会。 + +这时,你需要使用浏览器,打开`智控台`,链接:http://127.0.0.1:8002 ,注册第一个用户。第一个用户即是超级管理员,以后的用户都是普通用户。普通用户只能绑定设备和配置智能体;超级管理员可以进行模型管理、用户管理、参数配置等功能。 + +接下来要做三件重要的事情: + +### 第一件重要的事情 + +使用超级管理员账号,登录智控台,在顶部菜单找到`参数管理`,找到列表中第一条数据,参数编码是`server.secret`,复制它到`参数值`。 + +`server.secret`需要说明一下,这个`参数值`很重要,作用是让我们的`Server`端连接`manager-api`。`server.secret`是每次从零部署manager模块时,会自动随机生成的密钥。 + +复制`参数值`后,打开`xiaozhi-server`下的`data`目录的`.config.yaml`文件。此刻你的配置文件内容应该是这样的: + +``` +manager-api: + url: http://127.0.0.1:8002/xiaozhi + secret: 你的server.secret值 +``` +1、把你刚才从`智控台`复制过来的`server.secret`的`参数值`复制到`.config.yaml`文件里的`secret`里。 + +2、因为你是docker部署,把`url`改成下面的`http://xiaozhi-esp32-server-web:8002/xiaozhi` + +3、因为你是docker部署,把`url`改成下面的`http://xiaozhi-esp32-server-web:8002/xiaozhi` + +4、因为你是docker部署,把`url`改成下面的`http://xiaozhi-esp32-server-web:8002/xiaozhi` + +类似这样的效果 +``` +manager-api: + url: http://xiaozhi-esp32-server-web:8002/xiaozhi + secret: 12345678-xxxx-xxxx-xxxx-123456789000 +``` + +保存好后,继续往下做第二件重要的事情 + +### 第二件重要的事情 + +使用超级管理员账号,登录智控台,在顶部菜单找到`模型配置`,然后在左侧栏点击`大语言模型`,找到第一条数据`智谱AI`,点击`修改`按钮, +弹出修改框后,将你注册到的`智谱AI`的密钥填写到`API密钥`中。然后点击保存。 + +## 5.重启xiaozhi-esp32-server + +接下来打开命令行工具,使用`终端`或`命令行`工具 输入 +``` +docker restart xiaozhi-esp32-server +docker logs -f xiaozhi-esp32-server +``` +如果你能看到,类似以下日志,则是Server启动成功的标志。 + +``` +25-02-23 12:01:09[core.websocket_server] - INFO - Websocket地址是 ws://xxx.xx.xx.xx:8000/xiaozhi/v1/ +25-02-23 12:01:09[core.websocket_server] - INFO - =======上面的地址是websocket协议地址,请勿用浏览器访问======= +25-02-23 12:01:09[core.websocket_server] - INFO - 如想测试websocket请用谷歌浏览器打开test目录下的test_page.html +25-02-23 12:01:09[core.websocket_server] - INFO - ======================================================= +``` + +由于你是全模块部署,因此你有两个重要的接口需要写入到esp32中。 + +OTA接口: +``` +http://你宿主机局域网的ip:8002/xiaozhi/ota/ +``` + +Websocket接口: +``` +ws://你宿主机的ip:8000/xiaozhi/v1/ +``` + +### 第三件重要的事情 + +使用超级管理员账号,登录智控台,在顶部菜单找到`参数管理`,找到参数编码是`server.websocket`,输入你的`Websocket接口`。 + +使用超级管理员账号,登录智控台,在顶部菜单找到`参数管理`,找到数编码是`server.ota`,输入你的`OTA接口`。 + +接下来,你就可以开始操作你的esp32设备了,你可以`自行编译esp32固件`也可以配置使用`虾哥编译好的1.6.1以上版本的固件`。两个任选一个 + +1、 [编译自己的esp32固件](firmware-build.md)了。 + +2、 [基于虾哥编译好的固件配置自定义服务器](firmware-setting.md)了。 + + +# 方式二:本地源码运行全模块 + +## 1.安装MySQL数据库 + +如果本机已经安装了MySQL,可以直接在数据库中创建名为`xiaozhi_esp32_server`的数据库。 + +```sql +CREATE DATABASE xiaozhi_esp32_server CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +``` + +如果还没有MySQL,你可以通过docker安装mysql + +``` +docker run --name xiaozhi-esp32-server-db -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -e MYSQL_DATABASE=xiaozhi_esp32_server -e MYSQL_INITDB_ARGS="--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci" -e TZ=Asia/Shanghai -d mysql:latest +``` + +## 2.安装redis + +如果还没有Redis,你可以通过docker安装redis + +``` +docker run --name xiaozhi-esp32-server-redis -d -p 6379:6379 redis +``` + +## 3.运行manager-api程序 + +3.1 安装JDK21,设置JDK环境变量 + +3.2 安装Maven,设置Maven环境变量 + +3.3 使用Vscode编程工具,安装好Java环境相关插件 + +3.4 使用Vscode编程工具加载manager-api模块 + +在`src/main/resources/application-dev.yml`中配置数据库连接信息 + +``` +spring: + datasource: + username: root + password: 123456 +``` +在`src/main/resources/application-dev.yml`中配置Redis连接信息 +``` +spring: + data: + redis: + host: localhost + port: 6379 + password: + database: 0 +``` + +3.5 运行主程序 + +本项目为SpringBoot项目,启动方式为: +打开`Application.java`运行`Main`方法启动 + +``` +路径地址: +src/main/java/xiaozhi/AdminApplication.java +``` + +当你看到输出日志时,说明你的`manager-api`启动成功了。 + +``` +2025-xx-xx 22:11:12.445 [main] INFO c.a.d.s.b.a.DruidDataSourceAutoConfigure - Init DruidDataSource +2025-xx-xx 21:28:53.873 [main] INFO xiaozhi.AdminApplication - Started AdminApplication in 16.057 seconds (process running for 17.941) +http://localhost:8002/xiaozhi/doc.html +``` + +## 4.运行manager-web程序 + +4.1 安装nodejs + +4.2 使用Vscode编程工具加载manager-web模块 + +终端命令进入manager-web目录下 + +``` +npm install +``` +然后启动 +``` +npm run serve +``` + +请注意,如果你的manager-api的接口不在`http://localhost:8002`,请在开发时,修改 +`main/manager-web/.env.development`中的路径 + +运行成功后,你需要使用浏览器,打开`智控台`,链接:http://127.0.0.1:8001 ,注册第一个用户。第一个用户即是超级管理员,以后的用户都是普通用户。普通用户只能绑定设备和配置智能体;超级管理员可以进行模型管理、用户管理、参数配置等功能。 + + +重要:注册成功后,使用超级管理员账号,登录智控台,在顶部菜单找到`模型配置`,然后在左侧栏点击`大语言模型`,找到第一条数据`智谱AI`,点击`修改`按钮, +弹出修改框后,将你注册到的`智谱AI`的密钥填写到`API密钥`中。然后点击保存。 + +重要:注册成功后,使用超级管理员账号,登录智控台,在顶部菜单找到`模型配置`,然后在左侧栏点击`大语言模型`,找到第一条数据`智谱AI`,点击`修改`按钮, +弹出修改框后,将你注册到的`智谱AI`的密钥填写到`API密钥`中。然后点击保存。 + +重要:注册成功后,使用超级管理员账号,登录智控台,在顶部菜单找到`模型配置`,然后在左侧栏点击`大语言模型`,找到第一条数据`智谱AI`,点击`修改`按钮, +弹出修改框后,将你注册到的`智谱AI`的密钥填写到`API密钥`中。然后点击保存。 + +## 5.安装Python环境 + +本项目使用`conda`管理依赖环境。如果不方便安装`conda`,需要根据实际的操作系统安装好`libopus`和`ffmpeg`。 +如果确定使用`conda`,则安装好后,开始执行以下命令。 + +重要提示!windows 用户,可以通过安装`Anaconda`来管理环境。安装好`Anaconda`后,在`开始`那里搜索`anaconda`相关的关键词, +找到`Anaconda Prpmpt`,使用管理员身份运行它。如下图。 + +![conda_prompt](./images/conda_env_1.png) + +运行之后,如果你能看到命令行窗口前面有一个(base)字样,说明你成功进入了`conda`环境。那么你就可以执行以下命令了。 + +![conda_env](./images/conda_env_2.png) + +``` +conda remove -n xiaozhi-esp32-server --all -y +conda create -n xiaozhi-esp32-server python=3.10 -y +conda activate xiaozhi-esp32-server + +# 添加清华源通道 +conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main +conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free +conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge + +conda install libopus -y +conda install ffmpeg -y + +# 在 Linux 环境下进行部署时,如出现类似缺失 libiconv.so.2 动态库的报错 请通过以下命令进行安装 +conda install libiconv -y +``` + +请注意,以上命令,不是一股脑执行就成功的,你需要一步步执行,每一步执行完后,都检查一下输出的日志,查看是否成功。 + +## 6.安装本项目依赖 + +你先要下载本项目源码,源码可以通过`git clone`命令下载,如果你不熟悉`git clone`命令。 + +你可以用浏览器打开这个地址`https://github.com/xinnan-tech/xiaozhi-esp32-server.git` + +打开完,找到页面中一个绿色的按钮,写着`Code`的按钮,点开它,然后你就看到`Download ZIP`的按钮。 + +点击它,下载本项目源码压缩包。下载到你电脑后,解压它,此时它的名字可能叫`xiaozhi-esp32-server-main` +你需要把它重命名成`xiaozhi-esp32-server`,在这个文件里,进入到`main`文件夹,再进入到`xiaozhi-server`,好了请记住这个目录`xiaozhi-server`。 + +``` +# 继续使用conda环境 +conda activate xiaozhi-esp32-server +# 进入到你的项目根目录,再进入main/xiaozhi-server +cd main/xiaozhi-server +pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ +pip install -r requirements.txt +``` + +### 7.下载语音识别模型文件 + +本项目语音识别模型,默认使用`SenseVoiceSmall`模型,进行语音转文字。因为模型较大,需要独立下载,下载后把`model.pt` +文件放在`models/SenseVoiceSmall` +目录下。下面两个下载路线任选一个。 + +- 线路一:阿里魔搭下载[SenseVoiceSmall](https://modelscope.cn/models/iic/SenseVoiceSmall/resolve/master/model.pt) +- 线路二:百度网盘下载[SenseVoiceSmall](https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg&pwd=qvna) 提取码: + `qvna` + +## 8.配置项目文件 + +使用超级管理员账号,登录智控台 ,在顶部菜单找到`参数管理`,找到列表中第一条数据,参数编码是`server.secret`,复制它到`参数值`。 + +`server.secret`需要说明一下,这个`参数值`很重要,作用是让我们的`Server`端连接`manager-api`。`server.secret`是每次从零部署manager模块时,会自动随机生成的密钥。 + +如果你的`xiaozhi-server`目录没有`data`,你需要创建`data`目录。 +如果你的`data`下面没有`.config.yaml`文件,你可以把`xiaozhi-server`目录下的`config_from_api.yaml`文件复制到`data`,并重命名为`.config.yaml` + +复制`参数值`后,打开`xiaozhi-server`下的`data`目录的`.config.yaml`文件。此刻你的配置文件内容应该是这样的: + +``` +manager-api: + url: http://127.0.0.1:8002/xiaozhi + secret: 你的server.secret值 +``` + +把你刚才从`智控台`复制过来的`server.secret`的`参数值`复制到`.config.yaml`文件里的`secret`里。 + +类似这样的效果 +``` +manager-api: + url: http://127.0.0.1:8002/xiaozhi + secret: 12345678-xxxx-xxxx-xxxx-123456789000 +``` + +## 5.运行项目 + +``` +# 确保在xiaozhi-server目录下执行 +conda activate xiaozhi-esp32-server +python app.py +``` + +如果你能看到,类似以下日志,则是本项目服务启动成功的标志。 + +``` +25-02-23 12:01:09[core.websocket_server] - INFO - Server is running at ws://xxx.xx.xx.xx:8000/xiaozhi/v1/ +25-02-23 12:01:09[core.websocket_server] - INFO - =======上面的地址是websocket协议地址,请勿用浏览器访问======= +25-02-23 12:01:09[core.websocket_server] - INFO - 如想测试websocket请用谷歌浏览器打开test目录下的test_page.html +25-02-23 12:01:09[core.websocket_server] - INFO - ======================================================= +``` + +由于你是全模块部署,因此你有两个重要的接口。 + +OTA接口: +``` +http://你电脑局域网的ip:8002/xiaozhi/ota/ +``` + +Websocket接口: +``` +ws://你电脑局域网的ip:8000/xiaozhi/v1/ +``` + +请你务必把以上两个接口地址写入到智控台中:他们将会影响websocket地址发放和自动升级功能。 + +1、使用超级管理员账号,登录智控台,在顶部菜单找到`参数管理`,找到参数编码是`server.websocket`,输入你的`Websocket接口`。 + +2、使用超级管理员账号,登录智控台,在顶部菜单找到`参数管理`,找到数编码是`server.ota`,输入你的`OTA接口`。 + + +接下来,你就可以开始操作你的esp32设备了,你可以`自行编译esp32固件`也可以配置使用`虾哥编译好的1.6.1以上版本的固件`。两个任选一个 + +1、 [编译自己的esp32固件](firmware-build.md)了。 + +2、 [基于虾哥编译好的固件配置自定义服务器](firmware-setting.md)了。 + +# 常见问题 +以下是一些常见问题,供参考: + +1、[为什么我说的话,小智识别出来很多韩文、日文、英文](./FAQ.md)
+2、[为什么会出现“TTS 任务出错 文件不存在”?](./FAQ.md)
+3、[TTS 经常失败,经常超时](./FAQ.md)
+4、[使用Wifi能连接自建服务器,但是4G模式却接不上](./FAQ.md)
+5、[如何提高小智对话响应速度?](./FAQ.md)
+6、[我说话很慢,停顿时小智老是抢话](./FAQ.md)
+## 部署相关教程 +1、[如何自动拉取本项目最新代码自动编译和启动](./dev-ops-integration.md)
+2、[如何部署MQTT网关开启MQTT+UDP协议](./mqtt-gateway-integration.md)
+3、[如何与Nginx集成](https://github.com/xinnan-tech/xiaozhi-esp32-server/issues/791)
+## 拓展相关教程 +1、[如何开启手机号码注册智控台](./ali-sms-integration.md)
+2、[如何集成HomeAssistant实现智能家居控制](./homeassistant-integration.md)
+3、[如何开启视觉模型实现拍照识物](./mcp-vision-integration.md)
+4、[如何部署MCP接入点](./mcp-endpoint-enable.md)
+5、[如何接入MCP接入点](./mcp-endpoint-integration.md)
+6、[如何开启声纹识别](./voiceprint-integration.md)
+7、[新闻插件源配置指南](./newsnow_plugin_config.md)
+8、[天气插件使用指南](./weather-integration.md)
+## 语音克隆、本地语音部署相关教程 +1、[如何在智控台克隆音色](./huoshan-streamTTS-voice-cloning.md)
+2、[如何部署集成index-tts本地语音](./index-stream-integration.md)
+3、[如何部署集成fish-speech本地语音](./fish-speech-integration.md)
+4、[如何部署集成PaddleSpeech本地语音](./paddlespeech-deploy.md)
+## 性能测试教程 +1、[各组件速度测试指南](./performance_tester.md)
+2、[定期公开测试结果](https://github.com/xinnan-tech/xiaozhi-performance-research)
diff --git a/backend/docs/FAQ.md b/backend/docs/FAQ.md new file mode 100644 index 0000000..a5dc0b0 --- /dev/null +++ b/backend/docs/FAQ.md @@ -0,0 +1,100 @@ +# 常见问题 ❓ + +### 1、为什么我说的话,小智识别出来很多韩文、日文、英文?🇰🇷 + +建议:检查一下`models/SenseVoiceSmall`是否已经有`model.pt` +文件,如果没有就要下载,查看这里[下载语音识别模型文件](Deployment.md#模型文件) + +### 2、为什么会出现"TTS 任务出错 文件不存在"?📁 + +建议:检查一下是否正确使用`conda` 安装了`libopus`和`ffmpeg`库。 + +如果没有安装,就安装 + +``` +conda install conda-forge::libopus +conda install conda-forge::ffmpeg +``` + +### 3、TTS 经常失败,经常超时 ⏰ + +建议:如果 `EdgeTTS` 经常失败,请先检查是否使用了代理(梯子)。如果使用了,请尝试关闭代理后再试; +如果用的是火山引擎的豆包 TTS,经常失败时建议使用付费版本,因为测试版本仅支持 2 个并发。 + +### 4、使用Wifi能连接自建服务器,但是4G模式却接不上 🔐 + +原因:虾哥的固件,4G模式需要使用安全连接。 + +解决方法:目前有两种方法可以解决。任选一种: + +1、改代码。参考这个视频解决 https://www.bilibili.com/video/BV18MfTYoE85 + +2、使用nginx配置ssl证书。参考教程 https://icnt94i5ctj4.feishu.cn/docx/GnYOdMNJOoRCljx1ctecsj9cnRe + +### 5、如何提高小智对话响应速度? ⚡ + +本项目默认配置为低成本方案,建议初学者先使用默认免费模型,解决"跑得动"的问题,再优化"跑得快"。 +如需提升响应速度,可尝试更换各组件。自`0.5.2`版本起,项目支持流式配置,相比早期版本,响应速度提升约`2.5秒`,显著改善用户体验。 + +| 模块名称 | 入门全免费设置 | 流式配置 | +|:---:|:---:|:---:| +| ASR(语音识别) | FunASR(本地) | 👍XunfeiStreamASR(讯飞流式) | +| LLM(大模型) | glm-4-flash(智谱) | 👍qwen-flash(阿里百炼) | +| VLLM(视觉大模型) | glm-4v-flash(智谱) | 👍qwen2.5-vl-3b-instructh(阿里百炼) | +| TTS(语音合成) | ✅LinkeraiTTS(灵犀流式) | 👍HuoshanDoubleStreamTTS(火山流式) | +| Intent(意图识别) | function_call(函数调用) | function_call(函数调用) | +| Memory(记忆功能) | mem_local_short(本地短期记忆) | mem_local_short(本地短期记忆) | + +如果您关心各组件的耗时,请查阅[小智各组件性能测试报告](https://github.com/xinnan-tech/xiaozhi-performance-research),可按报告中的测试方法在您的环境中实际测试。 + +### 6、我说话很慢,停顿时小智老是抢话 🗣️ + +建议:在配置文件中找到如下部分,将 `min_silence_duration_ms` 的值调大(例如改为 `1000`): + +```yaml +VAD: + SileroVAD: + threshold: 0.5 + model_dir: models/snakers4_silero-vad + min_silence_duration_ms: 700 # 如果说话停顿较长,可将此值调大 +``` + +### 7、部署相关教程 +1、[如何进行最简化部署](./Deployment.md)
+2、[如何进行全模块部署](./Deployment_all.md)
+3、[如何部署MQTT网关开启MQTT+UDP协议](./mqtt-gateway-integration.md)
+4、[如何自动拉取本项目最新代码自动编译和启动](./dev-ops-integration.md)
+5、[如何与Nginx集成](https://github.com/xinnan-tech/xiaozhi-esp32-server/issues/791)
+ +### 9、编译固件相关教程 +1、[如何自己编译小智固件](./firmware-build.md)
+2、[如何基于虾哥编译好的固件修改OTA地址](./firmware-setting.md)
+3、[单模块部署如何配置固件OTA自动升级](./ota-upgrade-guide.md)
+ +### 10、拓展相关教程 +1、[如何开启手机号码注册智控台](./ali-sms-integration.md)
+2、[如何集成HomeAssistant实现智能家居控制](./homeassistant-integration.md)
+3、[如何开启视觉模型实现拍照识物](./mcp-vision-integration.md)
+4、[如何部署MCP接入点](./mcp-endpoint-enable.md)
+5、[如何接入MCP接入点](./mcp-endpoint-integration.md)
+6、[MCP方法如何获取设备信息](./mcp-get-device-info.md)
+7、[如何开启声纹识别](./voiceprint-integration.md)
+8、[新闻插件源配置指南](./newsnow_plugin_config.md)
+9、[知识库ragflow集成指南](./ragflow-integration.md)
+10、[如何部署上下文源](./context-provider-integration.md)
+11、[如何集成PowerMem智能记忆](./powermem-integration.md)
+12、[如何配置天气插件查询天气](./weather-integration.md)
+ +### 11、语音克隆、本地语音部署相关教程 +1、[如何在智控台克隆音色](./huoshan-streamTTS-voice-cloning.md)
+2、[如何部署集成index-tts本地语音](./index-stream-integration.md)
+3、[如何部署集成fish-speech本地语音](./fish-speech-integration.md)
+4、[如何部署集成PaddleSpeech本地语音](./paddlespeech-deploy.md)
+ +### 12、性能测试教程 +1、[各组件速度测试指南](./performance_tester.md)
+2、[定期公开测试结果](https://github.com/xinnan-tech/xiaozhi-performance-research)
+ +### 13、更多问题,可联系我们反馈 💬 + +可以在[issues](https://github.com/xinnan-tech/xiaozhi-esp32-server/issues)提交您的问题。 \ No newline at end of file diff --git a/backend/docs/ali-sms-integration.md b/backend/docs/ali-sms-integration.md new file mode 100644 index 0000000..1be2778 --- /dev/null +++ b/backend/docs/ali-sms-integration.md @@ -0,0 +1,44 @@ +# 阿里云短信集成指南 + +登录阿里云控制台,进入“短信服务”页面:https://dysms.console.aliyun.com/overview + +## 第一步 添加签名 +![步骤](images/alisms/sms-01.png) +![步骤](images/alisms/sms-02.png) + +以上步骤,会得到签名,请把它写入到智控台参数,`aliyun.sms.sign_name` + +## 第二步 添加模版 +![步骤](images/alisms/sms-11.png) + +以上步骤,会得到模版code,请把它写入到智控台参数,`aliyun.sms.sms_code_template_code` + +注意,签名要等7个工作日,等运营商报备成功后才能发送成功。 + +注意,签名要等7个工作日,等运营商报备成功后才能发送成功。 + +注意,签名要等7个工作日,等运营商报备成功后才能发送成功。 + +可以等报备成功后,再继续往下操作。 + +## 第三步 创建短信账户和开通权限 + +登录阿里云控制台,进入“访问控制”页面:https://ram.console.aliyun.com/overview?activeTab=overview + +![步骤](images/alisms/sms-21.png) +![步骤](images/alisms/sms-22.png) +![步骤](images/alisms/sms-23.png) +![步骤](images/alisms/sms-24.png) +![步骤](images/alisms/sms-25.png) + +以上步骤,会得到access_key_id和access_key_secret,请把它写入到智控台参数,`aliyun.sms.access_key_id`、`aliyun.sms.access_key_secret` +## 第四步 启动手机注册功能 + +1、正常来说,以上信息都填完后,会有这个效果,如果没有,可能缺少了某个步骤 + +![步骤](images/alisms/sms-31.png) + +2、开启允许非管理员用户可注册,将参数`server.allow_user_register`设置成`true` + +3、开启手机注册功能,将参数`server.enable_mobile_register`设置成`true` +![步骤](images/alisms/sms-32.png) \ No newline at end of file diff --git a/backend/docs/context-provider-integration.md b/backend/docs/context-provider-integration.md new file mode 100644 index 0000000..d8a9049 --- /dev/null +++ b/backend/docs/context-provider-integration.md @@ -0,0 +1,224 @@ +# 上下文源使用教程 + +## 概述 + +`上下文源`,就是为小智系统提示词的上下文添加【数据源】。 + +`上下文源` 在小智在唤醒那一刻,获取外部系统的数据,并将其动态注入到大模型的系统提示词(System Prompt)中。 +让其做到唤醒时感知世界某个事物的状态。 + +它和MCP、记忆有本质的区别:`上下文源`是强制让小智感知世界的数据;`记忆(Mem)`是让他知道之前聊了什么内容;`MCP(functionc all)`是当需要调用某项能力/知识的时候使用调用。 + +通过这个功能,在小智唤醒的一刹那,“感知”到: +- 人体健康传感器状态(体温、血压、血氧状态等) +- 业务系统的实时数据(服务器负载、待办数据、股票信息等) +- 任何可以通过 HTTP API 获取的文本信息 + +**注意**:该功能只是方便小智在唤醒的时候感知事物的状态,而如果想要小智唤醒后实时获取事物的状态,建议在此功能上再结合MCP工具的调用。 + +## 工作原理 + +1. **配置源**:用户配置一个或多个 HTTP API 地址。 +2. **触发请求**:当系统构建 Prompt 时,如果发现模板中包含 `{{ dynamic_context }}` 占位符,会请求所有配置的 API。 +3. **自动注入**:系统会自动将 API 返回的数据格式化为 Markdown 列表,替换 `{{ dynamic_context }}` 占位符。 + +## 接口规范 + +为了让小智正确解析数据,您的 API 需要满足以下规范: + +- **请求方式**:`GET` +- **请求头**:系统会自动添加 `device-id` 字段到 Request Header。 +- **响应格式**:必须返回 JSON 格式,且包含 `code` 和 `data` 字段。 + +### 响应示例 + +**情况 1:返回键值对** +```json +{ + "code": 0, + "msg": "success", + "data": { + "客厅温度": "26℃", + "客厅湿度": "45%", + "大门状态": "已关闭" + } +} +``` +*注入效果:* +```markdown + +- **客厅温度:** 26℃ +- **客厅湿度:** 45% +- **大门状态:** 已关闭 + +``` + +**情况 2:返回列表** +```json +{ + "code": 0, + "data": [ + "您有10个待办事项", + "当前汽车的行驶速度是100km每小时" + ] +} +``` +*注入效果:* +```markdown + +- 您有10个待办事项 +- 当前汽车的行驶速度是100km每小时 + +``` + +## 配置指南 + +### 方式 1:智控台配置(全模块部署) + +1. 登录智控台,进入**角色配置**页面。 +2. 找到**上下文源**配置项(点击“编辑源”按钮)。 +3. 点击**添加**,输入您的 API 地址。 +4. 如果 API 需要鉴权,可以在**请求头**部分添加 `Authorization` 或其他 Header。 +5. 保存配置。 + +### 方式 2:配置文件配置(单模块部署) + +编辑 `xiaozhi-server/data/.config.yaml` 文件,添加 `context_providers` 配置段: + +```yaml +# 上下文源配置 +context_providers: + - url: "http://api.example.com/data" + headers: + Authorization: "Bearer your-token" + - url: "http://another-api.com/data" +``` + +## 启用功能 + +默认情况下,系统的提示词模板文件(`data/.agent-base-prompt.txt`)中已经预置了 `{{ dynamic_context }}` 占位符,您无需手动添加。 + +**示例:** + +```markdown + +【重要!以下信息已实时提供,无需调用工具查询,请直接使用:】 +- **设备ID:** {{device_id}} +- **当前时间:** {{current_time}} +... +{{ dynamic_context }} + +``` + +**注意**:如果您不需要使用此功能,可以选择**不配置任何上下文源**,也可以从提示词模板文件中**删除** `{{ dynamic_context }}` 占位符。 + +## 附录:Mock 测试服务示例 + +为了方便您测试和开发,我们提供了一个简单的 Python Mock Server 脚本。您可以运行此脚本在本地模拟 API 接口。 + +**mock_api_server.py** + +```python +import http.server +import socketserver +import json +from urllib.parse import urlparse, parse_qs + +# 设置端口号 +PORT = 8081 + +class MockRequestHandler(http.server.SimpleHTTPRequestHandler): + def do_GET(self): + # 解析路径和参数 + parsed_path = urlparse(self.path) + path = parsed_path.path + query = parse_qs(parsed_path.query) + + response_data = {} + status_code = 200 + + print(f"收到请求: {path}, 参数: {query}") + + # Case 1: 模拟健康数据 (返回字典 Dict) + # 路径参数风格: /health + # device_id 从 Header 获取 + if path == "/health": + device_id = self.headers.get("device-id", "unknown_device") + print(f"device_id: {device_id}") + response_data = { + "code": 0, + "msg": "success", + "data": { + "测试设备ID": device_id, + "心率": "80 bpm", + "血压": "120/80 mmHg", + "状态": "良好" + } + } + + # Case 2: 模拟新闻列表 (返回列表 List) + # 无参数: /news/list + elif path == "/news/list": + response_data = { + "code": 0, + "msg": "success", + "data": [ + "今日头条:Python 3.14 发布", + "科技新闻:AI 助手改变生活", + "本地新闻:明日有大雨,记得带伞" + ] + } + + # Case 3: 模拟天气简报 (返回字符串 String) + # 无参数: /weather/simple + elif path == "/weather/simple": + response_data = { + "code": 0, + "msg": "success", + "data": "今日晴转多云,气温 20-25 度,空气质量优,适合出行。" + } + + # Case 4: 模拟设备详情 (Query参数风格) + # 参数风格: /device/info + # device_id 从 Header 获取 + elif path == "/device/info": + device_id = self.headers.get("device-id", "unknown_device") + response_data = { + "code": 0, + "msg": "success", + "data": { + "查询方式": "Header参数", + "设备ID": device_id, + "电量": "85%", + "固件": "v2.0.1" + } + } + + # Case 5: 404 Not Found + else: + status_code = 404 + response_data = {"error": "接口不存在"} + + # 发送响应 + self.send_response(status_code) + self.send_header('Content-type', 'application/json; charset=utf-8') + self.end_headers() + self.wfile.write(json.dumps(response_data, ensure_ascii=False).encode('utf-8')) + +# 启动服务 +# 允许地址重用,防止快速重启报错 +socketserver.TCPServer.allow_reuse_address = True +with socketserver.TCPServer(("", PORT), MockRequestHandler) as httpd: + print(f"==================================================") + print(f"Mock API Server 已启动: http://localhost:{PORT}") + print(f"可用接口列表:") + print(f"1. [字典] http://localhost:{PORT}/health") + print(f"2. [列表] http://localhost:{PORT}/news/list") + print(f"3. [文本] http://localhost:{PORT}/weather/simple") + print(f"4. [参数] http://localhost:{PORT}/device/info") + print(f"==================================================") + try: + httpd.serve_forever() + except KeyboardInterrupt: + print("\n服务已停止") +``` diff --git a/backend/docs/contributor_open_letter.md b/backend/docs/contributor_open_letter.md new file mode 100644 index 0000000..7a54719 --- /dev/null +++ b/backend/docs/contributor_open_letter.md @@ -0,0 +1,50 @@ +# 致开发者的公开信 + +"春江水暖鸭先知,正是河豚欲上时!" + +亲爱的朋友,我是John,是一名普通公司里的Java程序员,今天,我怀着无比真挚的心情,向热爱AI技术与创新的你发出这封公开信。 + +半年前我看到很多优秀的项目,比如`Dify`、`Chat2DB`等人工智能相关的项目,我在想,我要是能参与这些项目多好,可惜“报国无门,空打十年代码”。 + +我是2025年初刷到虾哥团队的视频,我非常好奇他是怎么实现的,我想复刻他们的后端服务,打造一个低成本民用贾维斯。很可惜现在做的作品依然只是一个人工智障,它并发低、没有灵魂,响应很慢,bug很多。 + +虾哥团队是我们学习的对象,我很想拥有像虾哥团队一样智能的小智后端服务。但是我也能理解虾哥不开源的决定。“一花独放不是春,百花齐放春满园”,人工智能遍地开花的时代,也许就在我们这代实现,我们可以用自己的双手,实现低成本民用贾维斯。我个人认为,他能实现的,我们也能实现,只是时间问题而已,我称之为“我们的取经之路”。 + +那么这条取经之路,我们会遇到什么困难?我想应该不少于八十一难。这一路必然会出现各种妖怪,当然也有神仙暗中帮助我们,也有人加入取经队伍。 + +以上内容,如果你觉得好笑。那我也觉得非常的幸运。我能够在你人生3万多天里博你笑五秒,也算是为你做了一次贡献。 + +民用低成本贾维斯这个想法,会失败吗,我不知道,但是我们普通人的一生,这种失败不是很常见吗? + +未来,有一点是可以确定的,就一定会有人完全复刻虾哥团队的功能,实现民用低成本贾维斯。这个项目会是我们吗? + +期待与你携手前行,共创未来。 + +John,2025.3.11,广州 + +# 附 开发贡献指南 +## 项目目标 + +1. **民用低成本贾维斯解决方案** + +2. **智能联动周边硬件的解决方案** + +## 加入我们 + +我们热忱欢迎志同道合的朋友加入,共同为项目贡献力量。您可在[这个链接](https://github.com/users/xinnan-tech/projects/3)查看我们近期要实现的功能,功能列表中还没指派相关人员处理的,正是急需您的参与。参与方式如下: + +### 1、成为普通贡献者 + +Fork 项目,提交 PR,由开发者审核后合入主分支。 + +### 2、成为开发者 + +当你累计提交 3 次有效 PR 后,可以联系群主申请成为开发者,群主将邀请你加入独立的开发者群,共同探讨项目未来。 + +## 开发者开发流程 + +1. **创建新分支** + 每个功能点请以新分支方式开发,分支名称应简洁明了,让人一眼看出所实现的功能,避免功能撞车。 + +2. **提交 PR 审核** + 功能开发完成后,请在 GitHub 上提交 PR,由其他开发者审核,审核通过后合并入主分支。 diff --git a/backend/docs/dev-ops-integration.md b/backend/docs/dev-ops-integration.md new file mode 100644 index 0000000..deeb037 --- /dev/null +++ b/backend/docs/dev-ops-integration.md @@ -0,0 +1,182 @@ +# 全模块源码部署自动升级方法 + +本教程是方便全模块源码部署的爱好者,如何通过自动命令,自动拉取源码,自动编译,自动启动端口运行。实现最高效率的升级系统。 + +本项目的测试平台`https://2662r3426b.vicp.fun`,从开放以来就使用了该方法,效果良好。 + +教程可参考B站博主`毕乐labs`发布的视频教程:[《开源小智服务器xiaozhi-server自动更新以及最新版本MCP接入点配置保姆教程》](https://www.bilibili.com/video/BV15H37zHE7Q) + +# 开始条件 +- 你的电脑/服务器是linux操作系统 +- 你已经跑通了整个流程 +- 你喜欢跟进最新功能,但是觉得每次手动部署有点麻烦,期待有一个自动更新的方法 + +第二个条件必须满足,因为本教程所涉及的某些文件,JDK、Node.js环境、Conda环境等,是需要你跑通整个流程才有的,如果你没有跑通,当我讲到某个文件的时候,你可能就不知道什么意思。 + +# 教程效果 +- 解决国内不能拉取最新项目源码问题 +- 自动拉取代码编译前端文件 +- 自动拉取代码编译java文件,自动杀掉8002端口,自动启动8002端口 +- 自动拉取python代码,自动杀掉8000端口,自动启动8000端口 + +# 第一步 选好你的项目目录 + +例如,我规划了我的项目目录是,这是一个新建的空白的目录,如果你不想出错,可以和我一样 +``` +/home/system/xiaozhi +``` + +# 第二步 克隆本项目 +此刻,先要执行第一句话,拉取源码,这句命令适用于国内网络的服务器和电脑,无需翻墙 + +``` +cd /home/system/xiaozhi +git clone https://ghproxy.net/https://github.com/xinnan-tech/xiaozhi-esp32-server.git +``` + +执行完后,你的项目目录会多了一个文件夹`xiaozhi-esp32-server`,这个就是项目的源码 + +# 第三步 复制基础的文件 + +如果你之前已经跑通了整个流程,对funasr的模型文件`xiaozhi-server/models/SenseVoiceSmall/model.pt`和你的私有配置文件`xiaozhi-server/data/.config.yaml`这两个文件不会陌生。 + +此刻你需要把`model.pt`文件复制到新的目录去,你可以这样 +``` +# 创建需要的目录 +mkdir -p /home/system/xiaozhi/xiaozhi-esp32-server/main/xiaozhi-server/data/ + +cp 你原来的.config.yaml完整路径 /home/system/xiaozhi/xiaozhi-esp32-server/main/xiaozhi-server/data/.config.yaml +cp 你原来的model.pt完整路径 /home/system/xiaozhi/xiaozhi-esp32-server/main/xiaozhi-server/models/SenseVoiceSmall/model.pt +``` + +# 第四步 建立三个自动编译文件 + +## 4.1 自动编译mananger-web模块 +在`/home/system/xiaozhi/`目录下,创建名字为`update_8001.sh`的文件,内容如下 + +``` +cd /home/system/xiaozhi/xiaozhi-esp32-server +git fetch --all +git reset --hard +git pull origin main + + +cd /home/system/xiaozhi/xiaozhi-esp32-server/main/manager-web +npm install +npm run build +rm -rf /home/system/xiaozhi/manager-web +mv /home/system/xiaozhi/xiaozhi-esp32-server/main/manager-web/dist /home/system/xiaozhi/manager-web +``` + +保存好后执行赋权命令 +``` +chmod 777 update_8001.sh +``` +执行完后,继续往下 + +## 4.2 自动编译运行manager-api模块 +在`/home/system/xiaozhi/`目录下,创建名字为`update_8002.sh`的文件,内容如下 + +``` +cd /home/system/xiaozhi/xiaozhi-esp32-server +git pull origin main + + +cd /home/system/xiaozhi/xiaozhi-esp32-server/main/manager-api +rm -rf target +mvn clean package -Dmaven.test.skip=true +cd /home/system/xiaozhi/ + +# 查找占用8002端口的进程号 +PID=$(sudo netstat -tulnp | grep 8002 | awk '{print $7}' | cut -d'/' -f1) + +rm -rf /home/system/xiaozhi/xiaozhi-esp32-api.jar +mv /home/system/xiaozhi/xiaozhi-esp32-server/main/manager-api/target/xiaozhi-esp32-api.jar /home/system/xiaozhi/xiaozhi-esp32-api.jar + +# 检查是否找到进程号 +if [ -z "$PID" ]; then + echo "没有找到占用8002端口的进程" +else + echo "找到占用8002端口的进程,进程号为: $PID" + # 杀掉进程 + kill -9 $PID + kill -9 $PID + echo "已杀掉进程 $PID" +fi + +nohup java -jar xiaozhi-esp32-api.jar --spring.profiles.active=dev & + +tail tail -f nohup.out +``` + +保存好后执行赋权命令 +``` +chmod 777 update_8002.sh +``` +执行完后,继续往下 + +## 4.3 自动编译运行Python项目 +在`/home/system/xiaozhi/`目录下,创建名字为`update_8000.sh`的文件,内容如下 + +``` +cd /home/system/xiaozhi/xiaozhi-esp32-server +git pull origin main + +# 查找占用8000端口的进程号 +PID=$(sudo netstat -tulnp | grep 8000 | awk '{print $7}' | cut -d'/' -f1) + +# 检查是否找到进程号 +if [ -z "$PID" ]; then + echo "没有找到占用8000端口的进程" +else + echo "找到占用8000端口的进程,进程号为: $PID" + # 杀掉进程 + kill -9 $PID + kill -9 $PID + echo "已杀掉进程 $PID" +fi +cd main/xiaozhi-server +# 初始化conda环境 +source ~/.bashrc +conda activate xiaozhi-esp32-server +pip install -r requirements.txt +nohup python app.py >/dev/null & +tail -f /home/system/xiaozhi/xiaozhi-esp32-server/main/xiaozhi-server/tmp/server.log +``` + +保存好后执行赋权命令 +``` +chmod 777 update_8000.sh +``` +执行完后,继续往下 + +# 日常更新 + +以上的脚本都建立好后,日常更新,我们只要依次执行以下命令就可以做到自动更新和启动 + +``` +cd /home/system/xiaozhi +# 更新并启动Java程序 +./update_8001.sh +# 更新web程序 +./update_8002.sh +# 更新并启动python程序 +./update_8000.sh + + +# 后期想查看java日志,执行以下命令 +tail -f nohup.out +# 后期想查看python日志,执行以下命令 +tail -f /home/system/xiaozhi/xiaozhi-esp32-server/main/xiaozhi-server/tmp/server.log +``` + +# 注意事项 +测试平台`https://2662r3426b.vicp.fun`,是使用nginx做了反向代理。nginx.conf详细配置可以[参考这里](https://github.com/xinnan-tech/xiaozhi-esp32-server/issues/791) + +## 常见问题 + +### 1、为什么没有见到8001端口? +回答:8001是开发环境使用的,用于运行前端的端口。如果你是服务器部署,不建议使用`npm run serve`启动8001端口运行前端,而是像本教程一样编译成html文件,然后使用nginx来管理访问。 + +### 2、每次更新需要更新手动SQL语句吗? +回答:不需要,因为项目使用**Liquibase**管理数据库版本,会自动执行新的sql脚本。 \ No newline at end of file diff --git a/backend/docs/docker-build.md b/backend/docs/docker-build.md new file mode 100644 index 0000000..118ed1c --- /dev/null +++ b/backend/docs/docker-build.md @@ -0,0 +1,21 @@ +# 本地编译docker镜像方法 + +现在本项目已经使用github自动编译docker功能,本文档是提供给有本地编译docker镜像需求的朋友准备的。 + +1、安装docker +``` +sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin +``` +2、编译docker镜像 +``` +#进入项目根目录 +# 编译server +docker build -t xiaozhi-esp32-server:server_latest -f ./Dockerfile-server . +# 编译web +docker build -t xiaozhi-esp32-server:web_latest -f ./Dockerfile-web . + +# 编译完成后,可以使用docker-compose启动项目 +# docker-compose.yml你需要修改成自己编译的镜像版本 +cd main/xiaozhi-server +docker compose up -d +``` diff --git a/backend/docs/docker/nginx.conf b/backend/docs/docker/nginx.conf new file mode 100644 index 0000000..ca3bac3 --- /dev/null +++ b/backend/docs/docker/nginx.conf @@ -0,0 +1,53 @@ +user root; +worker_processes 4; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 300; + client_header_timeout 180s; + client_body_timeout 180s; + client_max_body_size 1024M; + + gzip on; + gzip_buffers 32 4K; + gzip_comp_level 6; + gzip_min_length 100; + gzip_types application/javascript text/css text/xml image/jpeg image/gif image/png; + gzip_disable "MSIE [1-6]\."; + gzip_vary on; + + server { + # 无域名访问,就用localhost + server_name localhost; + # 80端口 + listen 8002; + + # 转发到编译后到web目录 + location / { + root /usr/share/nginx/html; + try_files $uri $uri/ /index.html; + } + + # 转发到manager-api + location /xiaozhi/ { + proxy_pass http://127.0.0.1:8003; + proxy_set_header Host $host; + proxy_cookie_path /manager/ /; + proxy_set_header Referer $http_referer; + proxy_set_header Cookie $http_cookie; + + proxy_connect_timeout 15; + proxy_send_timeout 15; + proxy_read_timeout 15; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + } +} \ No newline at end of file diff --git a/backend/docs/docker/start.sh b/backend/docs/docker/start.sh new file mode 100644 index 0000000..a64f46b --- /dev/null +++ b/backend/docs/docker/start.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# 启动Java后端(docker内监听8003端口) +java -jar /app/xiaozhi-esp32-api.jar \ + --server.port=8003 \ + --spring.datasource.druid.url=${SPRING_DATASOURCE_DRUID_URL} \ + --spring.datasource.druid.username=${SPRING_DATASOURCE_DRUID_USERNAME} \ + --spring.datasource.druid.password=${SPRING_DATASOURCE_DRUID_PASSWORD} \ + --spring.data.redis.host=${SPRING_DATA_REDIS_HOST} \ + --spring.data.redis.password=${SPRING_DATA_REDIS_PASSWORD} \ + --spring.data.redis.port=${SPRING_DATA_REDIS_PORT} & + +# 启动Nginx(前台运行保持容器存活) +nginx -g 'daemon off;' \ No newline at end of file diff --git a/backend/docs/firmware-build.md b/backend/docs/firmware-build.md new file mode 100644 index 0000000..64584b2 --- /dev/null +++ b/backend/docs/firmware-build.md @@ -0,0 +1,138 @@ +# esp32固件编译 + +## 第1步 准备你的ota地址 + +如果你,使用的是本项目0.3.12版本,不管是简单Server部署还是全模块部署,都会有ota地址。 + +由于简单Server部署和全模块部署的OTA地址设置方式不一样,请你选择下面的具体方式: + +### 如果你用的是简单Server部署 +此刻,请你用浏览器打开你的ota地址,例如我的ota地址 +``` +http://192.168.1.25:8003/xiaozhi/ota/ +``` +如果显示“OTA接口运行正常,向设备发送的websocket地址是:ws://xxx:8000/xiaozhi/v1/ + +你可以使用项目自带的`test_page.html`测试一下,是否能连上ota页面输出的websocket地址。 + +如果访问不到,你需要到配置文件`.config.yaml`里修改`server.websocket`的地址,重启后再重新测试,直到`test_page.html`能正常访问。 + +成功后,请往下进行第2步 + +### 如果你用的是全模块部署 +此刻,请你用浏览器打开你的ota地址,例如我的ota地址 +``` +http://192.168.1.25:8002/xiaozhi/ota/ +``` + +如果显示“OTA接口运行正常,websocket集群数量:X”。那就往下进行2步。 + +如果显示“OTA接口运行不正常”,大概是你还没在`智控台`配置`Websocket`地址。那就: + +- 1、使用超级管理员登录智控台 + +- 2、顶部菜单点击`参数管理` + +- 3、在列表中找到`server.websocket`项目,输入你的`Websocket`地址。例如我的就是 + +``` +ws://192.168.1.25:8000/xiaozhi/v1/ +``` + +配置完后,再使用浏览器刷新你的ota接口地址,看看是不是正常了。如果还不正常就,就再次确认一下Websocket是否正常启动,是否配置了Websocket地址。 + +## 第2步 配置环境 +先按照这个教程配置项目环境[《Windows搭建 ESP IDF 5.3.2开发环境以及编译小智》](https://icnynnzcwou8.feishu.cn/wiki/JEYDwTTALi5s2zkGlFGcDiRknXf) + +## 第3步 打开配置文件 +配置好编译环境后,下载虾哥iaozhi-esp32项目源码, + +从这里下载虾哥[xiaozhi-esp32项目源码](https://github.com/78/xiaozhi-esp32)。 + +下载后,打开`xiaozhi-esp32/main/Kconfig.projbuild`文件。 + +## 第4步 修改OTA地址 + +找到`OTA_URL`的`default`的内容,把`https://api.tenclass.net/xiaozhi/ota/` + 改成你自己的地址,例如,我的接口地址是`http://192.168.1.25:8002/xiaozhi/ota/`,就把内容改成这个。 + +修改前: +``` +config OTA_URL + string "Default OTA URL" + default "https://api.tenclass.net/xiaozhi/ota/" + help + The application will access this URL to check for new firmwares and server address. +``` +修改后: +``` +config OTA_URL + string "Default OTA URL" + default "http://192.168.1.25:8002/xiaozhi/ota/" + help + The application will access this URL to check for new firmwares and server address. +``` + +## 第4步 设置编译参数 + +设置编译参数 + +``` +# 终端命令行进入xiaozhi-esp32的根目录 +cd xiaozhi-esp32 +# 例如我使用的板子是esp32s3,所以设置编译目标为esp32s3,如果你的板子是其他型号,请替换成对应的型号 +idf.py set-target esp32s3 +# 进入菜单配置 +idf.py menuconfig +``` + +进入菜单配置后,再进入`Xiaozhi Assistant`,将`BOARD_TYPE`设置你板子的具体型号 +保存退出,回到终端命令行。 + +## 第5步 编译固件 + +``` +idf.py build +``` + +## 第6步 打包bin固件 + +``` +cd scripts +python release.py +``` + +上面的打包命令执行完成后,会在项目根目录下的`build`目录下生成固件文件`merged-binary.bin`。 +这个`merged-binary.bin`就是要烧录到硬件上的固件文件。 + +注意:如果执行到第二命令后,报了“zip”相关的错误,请忽略这个错误,只要`build`目录下生成固件文件`merged-binary.bin` +,对你没有太大影响,请继续。 + +## 第7步 烧录固件 + 将esp32设备连接电脑,使用chrome浏览器,打开以下网址 + +``` +https://espressif.github.io/esp-launchpad/ +``` + +打开这个教程,[Flash工具/Web端烧录固件(无IDF开发环境)](https://ccnphfhqs21z.feishu.cn/wiki/Zpz4wXBtdimBrLk25WdcXzxcnNS)。 +翻到:`方式二:ESP-Launchpad 浏览器WEB端烧录`,从`3. 烧录固件/下载到开发板`开始,按照教程操作。 + +烧录成功且联网成功后,通过唤醒词唤醒小智,留意server端输出的控制台信息。 + +## 常见问题 +以下是一些常见问题,供参考: + +[1、为什么我说的话,小智识别出来很多韩文、日文、英文](./FAQ.md) + +[2、为什么会出现“TTS 任务出错 文件不存在”?](./FAQ.md) + +[3、TTS 经常失败,经常超时](./FAQ.md) + +[4、使用Wifi能连接自建服务器,但是4G模式却接不上](./FAQ.md) + +[5、如何提高小智对话响应速度?](./FAQ.md) + +[6、我说话很慢,停顿时小智老是抢话](./FAQ.md) + +[7、我想通过小智控制电灯、空调、远程开关机等操作](./FAQ.md) diff --git a/backend/docs/firmware-setting.md b/backend/docs/firmware-setting.md new file mode 100644 index 0000000..0ed350a --- /dev/null +++ b/backend/docs/firmware-setting.md @@ -0,0 +1,54 @@ +# 基于虾哥编译好的固件配置自定义服务器 + +## 第1步 确认版本 +烧录虾哥已经编译好的[1.6.1版本以上固件](https://github.com/78/xiaozhi-esp32/releases) + +## 第2步 准备你的ota地址 +如果你按照教程使用的是全模块部署,就应该会有ota地址。 + +此刻,请你用浏览器打开你的ota地址,例如我的ota地址 +``` +https://2662r3426b.vicp.fun/xiaozhi/ota/ +``` + +如果显示“OTA接口运行正常,websocket集群数量:X”。那就往下。 + +如果显示“OTA接口运行不正常”,大概是你还没在`智控台`配置`Websocket`地址。那就: + +- 1、使用超级管理员登录智控台 + +- 2、顶部菜单点击`参数管理` + +- 3、在列表中找到`server.websocket`项目,输入你的`Websocket`地址。例如我的就是 + +``` +wss://2662r3426b.vicp.fun/xiaozhi/v1/ +``` + +配置完后,再使用浏览器刷新你的ota接口地址,看看是不是正常了。如果还不正常就,就再次确认一下Websocket是否正常启动,是否配置了Websocket地址。 + +## 第3步 进入配网模式 +进入机器的配网模式,在页面顶部,点击“高级选项”,在里面输入你服务器的`ota`地址,点击保存。重启设备 +![请参考-OTA地址设置](../docs/images/firmware-setting-ota.png) + +## 第4步 唤醒小智,查看日志输出 + +唤醒小智,看看日志是不是正常输出。 + + +## 常见问题 +以下是一些常见问题,供参考: + +[1、为什么我说的话,小智识别出来很多韩文、日文、英文](./FAQ.md) + +[2、为什么会出现“TTS 任务出错 文件不存在”?](./FAQ.md) + +[3、TTS 经常失败,经常超时](./FAQ.md) + +[4、使用Wifi能连接自建服务器,但是4G模式却接不上](./FAQ.md) + +[5、如何提高小智对话响应速度?](./FAQ.md) + +[6、我说话很慢,停顿时小智老是抢话](./FAQ.md) + +[7、我想通过小智控制电灯、空调、远程开关机等操作](./FAQ.md) diff --git a/backend/docs/fish-speech-integration.md b/backend/docs/fish-speech-integration.md new file mode 100644 index 0000000..b916e61 --- /dev/null +++ b/backend/docs/fish-speech-integration.md @@ -0,0 +1,72 @@ +登录AutoDL,租赁镜像 +选择镜像: +``` +PyTorch / 2.1.0 / 3.10(ubuntu22.04) / cuda 12.1 +``` + +机器开机后,设置学术加速 +``` +source /etc/network_turbo +``` + +进入工作目录 +``` +cd autodl-tmp/ +``` + +拉取项目 +``` +git clone https://gitclone.com/github.com/fishaudio/fish-speech.git ; cd fish-speech +``` + +安装依赖 +``` +pip install -e. +``` + +如果报错,安装portaudio +``` +apt-get install portaudio19-dev -y +``` + +安装后执行 +``` +pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121 +``` + +下载模型 +``` +cd tools +python download_models.py +``` + +下载完模型后运行接口 +``` +python -m tools.api_server --listen 0.0.0.0:6006 +``` + +然后用浏览器去到aotodl实例页面 +``` +https://autodl.com/console/instance/list +``` + +如下图点击你刚才机器的`自定义服务`按钮,开启端口转发服务 +![自定义服务](images/fishspeech/autodl-01.png) + +端口转发服务设置完成后,你本地电脑打开网址`http://localhost:6006/`,就可以访问fish-speech的接口了 +![服务预览](images/fishspeech/autodl-02.png) + + +如果你是单模块部署,核心配置如下 +``` +selected_module: + TTS: FishSpeech +TTS: + FishSpeech: + reference_audio: ["config/assets/wakeup_words.wav",] + reference_text: ["哈啰啊,我是小智啦,声音好听的台湾女孩一枚,超开心认识你耶,最近在忙啥,别忘了给我来点有趣的料哦,我超爱听八卦的啦",] + api_key: "123" + api_url: "http://127.0.0.1:6006/v1/tts" +``` + +然后重启服务 \ No newline at end of file diff --git a/backend/docs/homeassistant-integration.md b/backend/docs/homeassistant-integration.md new file mode 100644 index 0000000..c6e26ba --- /dev/null +++ b/backend/docs/homeassistant-integration.md @@ -0,0 +1,226 @@ +# 小智ESP32-开源服务端与HomeAssistant集成指南 + +[TOC] + +----- + +## 简介 + +本文档将指导您如何将ESP32设备与HomeAssistant进行集成。 + +## 前提条件 + +- 已安装并配置好`HomeAssistant` +- 本次我选择的模型是:免费的ChatGLM,它支持functioncall函数调用 + +## 开始前的操作(必要) + +### 1. 获取HA的网络网络地址信息 + +请访问你Home Assistant的网络地址,例如,我的HA的地址是192.168.4.7,端口则是默认的8123,则在浏览器打开 + +``` +http://192.168.4.7:8123 +``` + +> 手动查询 HA 的 IP 地址方法**(仅限小智esp32-server和HA部署在同一个网络设备[例如同一个wifi]下)**: +> +> 1. 进入 Home Assistant(前端)。 +> +> 2. 点击左下角 **设置(Settings)** → **系统(System)** → **网络(Network)**。 +> +> 3. 滑到最底部`Home Assistant 网址(Home Assistant website)`区域,在`本地网络(local network)`中,点击`眼睛`按钮,可以看到当前使用的 IP 地址(如 `192.168.1.10`)和网络接口。点击`复制连接(copy link)`可以直接复制。 +> +> ![image-20250504051716417](images/image-ha-integration-01.png) + +或,您已经设置了直接可以访问的Home Assistant的OAuth地址,您也可以在浏览器内直接访问 + +``` +http://homeassistant.local:8123 +``` + +### 2. 登录`Home Assistant`拿到开发密钥 + +登录`HomeAssistant`,点击`左下角头像 -> 个人`,切换`安全`导航栏,划到底部`长期访问令牌`生成api_key,并复制保存,后续的方法都需要使用这个api key且仅出现一次(小tips: 您可以保存生成的二维码图像,后续可以扫描二维码再此提取api key)。 + +## 方法1:小智社区共建的HA调用功能 + +### 功能描述 + +- 如您后续需要增加新的设备,该方法需要手动重启`xiaozhi-esp32-server服务端`以此更新设备信息**(重要**)。 + +- 需要您确保已经在HomeAssistant中集成`Xiaomi Home`,并将米家的设备导入进`HomeAssistant`。 + +- 需要您确保`xiaozhi-esp32-server智控台`能正常使用。 + +- 我的`xiaozhi-esp32-server智控台`和`HomeAssistant`部署在同一台机器的另一个端口,版本是`0.3.10` + + ``` + http://192.168.4.7:8002 + ``` + + +### 配置步骤 + +#### 1. 登录`HomeAssistant`整理需要控制的设备清单 + +登录`HomeAssistant`,点击`左下角的设置`,然后进入`设备与服务`,再点击顶部的`实体`。 + +然后在实体中搜索你相关控制的开关,结果出来后,在列表中,点击其中一个结果,这是会出现一个开关的界面。 + +在开关的界面,我们尝试点击开关,看看是开发会随着我们的点击开/关。如果能操作,说明是正常联网的。 + +接着在开关面板找到设置按钮,点击后,可以查看这个开关的`实体标识符`。 + +我们打开一个记事本,按照这样格式整理一条数据: + +位置+英文逗号+设备名称+英文逗号+`实体标识符`+英文分号 + +例如,我在公司,我有一个玩具灯,他的标识符是switch.cuco_cn_460494544_cp1_on_p_2_1,那么就这个写这一条数据 + +``` +公司,玩具灯,switch.cuco_cn_460494544_cp1_on_p_2_1; +``` + +当然最后我可能要操作两个灯,我的最终的结果是: + +``` +公司,玩具灯,switch.cuco_cn_460494544_cp1_on_p_2_1; +公司,台灯,switch.iot_cn_831898993_socn1_on_p_2_1; +``` + +这段字符,我们称为“设备清单字符”需要保存好,等一下有用。 + +#### 2. 登录`智控台` + +![image-20250504051716417](images/image-ha-integration-06.png) + +使用管理员账号,登录`智控台`。在`智能体管理`,找到你的智能体,再点击`配置角色`。 + +将意图识别设置成`外挂的大模型意图识别`或`大模型自主函数调用`。这时你会看到右侧有一个`编辑功能`。点击`编辑功能`按钮,会弹出`功能管理`的框。 + +在`功能管理`的框里,你需要勾选`HomeAssistant设备状态查询`和`HomeAssistant设备状态修改`。 + +勾选后,在`已选功能`点击`HomeAssistant设备状态查询`,然后在`参数配置`里配置你的`HomeAssistant`地址、密钥、设备清单字符。 + +编辑好后,点击`保存配置`,这时`功能管理`的框会隐藏,这时你再点击保存智能体配置。 + +保存成功后,即可唤醒设备操作。 + +#### 3. 唤醒设别进行控制 + +尝试和esp32说,“打开XXX灯” + +## 方法2:小智将Home Assistant的语音助手作为LLM工具 + +### 功能描述 + +- 该方法有一个比较严重的缺点——**该方法无法使用小智开源生态的function_call插件功能的能力**,因为使用Home Assistant作为小智的LLM工具会将意图识别能力转让给Home Assistant。但是**这个方法是能体验到原生的Home Assistant操作功能,且小智的聊天能力不变**。如实在介意可以使用同样是Home Assistant支持的[方法3](##方法3:使用Home Assistant的MCP服务(推荐)),能够最大程度体验到Home Assistant的功能。 + +### 配置步骤: + +#### 1. 配置Home Assistant的大模型语音助手。 + +**需要您提前配置好Home Assistant的语音助手或大模型工具。** + +#### 2. 获取Home Assistant的语言助手的Agent ID. + +1. 进入Home Assistant页面内。左侧点击`开发者助手`。 +2. 在打开的`开发者助手`内,点击`动作`选项卡(如图示操作1),在页面内的选项栏`动作`中,找到或输入`conversation.process(对话-处理)`并选择`对话(conversation): 处理`(如图示操作2)。 + +![image-20250504043539343](images/image-ha-integration-02.png) + +3. 在页面内勾选`代理(agent)`选项,在变成常亮的`对话代理(conversation agent)`内选择您步骤一配置好的语音助手名称,如图示,我这边配置好的是`ZhipuAi`并选择。 + +![image-20250504043854760](images/image-ha-integration-03.png) + +4. 选中后,点击表单左下方的`进入YAML模式`。 + +![image-20250504043951126](images/image-ha-integration-04.png) + +5. 复制其中的agent-id的值,例如图示中我的是`01JP2DYMBDF7F4ZA2DMCF2AGX2`(仅供参考)。 + +![image-20250504044046466](images/image-ha-integration-05.png) + +6. 切换到小智开源服务端`xiaozhi-esp32-server`的`config.yaml`文件内,在LLM配置中,找到Home Assistant,设置您的Home Assistant的网络地址,Api key和刚刚查询到的agent_id。 +7. 修改`config.yaml`文件内的`selected_module`属性的`LLM`为`HomeAssistant`,`Intent`为`nointent`。 +8. 重启小智开源服务端`xiaozhi-esp32-server`即可正常使用。 + +## 方法3:使用Home Assistant的MCP服务(推荐) + +### 功能描述 + +- 需要您提前在Home Assistant内集成并安装好HA集成——[Model Context Protocol Server](https://www.home-assistant.io/integrations/mcp_server/)。 + +- 这个方法与方法2都是HA官方提供的解决方法,与方法2不同的是,您可以正常使用小智开源服务端`xiaozhi-esp32-server`的开源共建的插件,同时允许您随意使用任何一个支持function_call功能的LLM大模型。 + +### 配置步骤 + +#### 1. 安装Home Assistant的MCP服务集成。 + +集成官方网址——[Model Context Protocol Server](https://www.home-assistant.io/integrations/mcp_server/)。。 + +或跟随以下手动操作。 + +> - 前往Home Assistant页面的**[设置 > 设备和服务(Settings > Devices & Services.)](https://my.home-assistant.io/redirect/integrations)**。 +> +> - 在右下角,选择 **[添加集成(Add Integration)](https://my.home-assistant.io/redirect/config_flow_start?domain=mcp_server)**按钮。 +> +> - 从列表中选择**模型上下文协议服务器(Model Context Protocol Server)**。 +> +> - 按照屏幕上的说明完成设置。 + +#### 2. 配置小智开源服务端MCP配置信息 + + +进入`data`目录,找到`.mcp_server_settings.json`文件。 + +如果你的`data`目录下没有`.mcp_server_settings.json`文件, +- 请把在`xiaozhi-server`文件夹根目录的`mcp_server_settings.json`文件复制到`data`目录下,并重命名为`.mcp_server_settings.json` +- 或[下载这个文件](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/xiaozhi-server/mcp_server_settings.json),下载到`data`目录下,并重命名为`.mcp_server_settings.json` + + +修改`"mcpServers"`里的这部分的内容: + +```json +"Home Assistant": { + "command": "mcp-proxy", + "args": [ + "http://YOUR_HA_HOST/mcp_server/sse" + ], + "env": { + "API_ACCESS_TOKEN": "YOUR_API_ACCESS_TOKEN" + } +}, +``` + +注意: + +1. **替换配置:** + - 替换`args`内的`YOUR_HA_HOST`为您的HA服务地址,如果你的服务地址已经包含了https/http字样(例如`http://192.168.1.101:8123`),则只需要填入`192.168.1.101:8123`即可。 + - 将`env`内`API_ACCESS_TOKEN`的`YOUR_API_ACCESS_TOKEN`替换成您之前获取到的开发密钥api key。 +2. **如果你添加配置是在`"mcpServers"`的括号内后续没有新的`mcpServers`的配置时,需要把最后的逗号`,`移除**,否则可能会解析失败。 + +**最后效果参考以下(参考如下)**: + +```json + "mcpServers": { + "Home Assistant": { + "command": "mcp-proxy", + "args": [ + "http://192.168.1.101:8123/mcp_server/sse" + ], + "env": { + "API_ACCESS_TOKEN": "abcd.efghi.jkl" + } + } + } +``` + +#### 3. 配置小智开源服务端的系统配置 + +1. **选择任意一款支持function_call的LLM大模型作为小智的LLM聊天助手(但不要选择Home Assistant作为LLM工具)**,本次我选择的模型是:免费的ChatGLM,它支持functioncall函数调用,但部分时候调用不太稳定,如果像追求稳定建议把LLM设置成:DoubaoLLM,使用的具体model_name是:doubao-1-5-pro-32k-250115。 + +2. 切换到小智开源服务端`xiaozhi-esp32-server`的`config.yaml`文件内,设置您的LLM大模型配置,并且将`selected_module`配置的`Intent`调整为`function_call`。 + +3. 重启小智开源服务端`xiaozhi-esp32-server`即可正常使用。 \ No newline at end of file diff --git a/backend/docs/huoshan-streamTTS-voice-cloning.md b/backend/docs/huoshan-streamTTS-voice-cloning.md new file mode 100644 index 0000000..304a8c9 --- /dev/null +++ b/backend/docs/huoshan-streamTTS-voice-cloning.md @@ -0,0 +1,58 @@ +# 智控台 火山双流式语音合成+音色克隆配置教程 + +本教程分为4个阶段:准备阶段、配置阶段、克隆阶段、使用阶段。主要是介绍通过智控台配置火山双流式语音合成+音色克隆的过程。 + +## 第一阶段:准备阶段 +超级管理员先预先把火山引擎服务开通好,获取到App Id,Access Token。默认火上引擎会赠送一个音色资源。这个音色资源需要把它复制到本项目里。 + +如果你想克隆多个音色,需要购买开通多个音色资源。只要把每个音色资源的声音ID(S_xxxxx)复制到本项目。然后分配给系统的账号使用即可。以下是详细步骤: + +### 1.开通火山引擎服务 +访问 https://console.volcengine.com/speech/app 在应用管理创建应用,勾选语音合成大模型和声音复刻大模型。 + +### 2.获取音色资源ID +访问 https://console.volcengine.com/speech/service/9999 复制三项内容,分别是App Id,Access Token以及声音ID(S_xxxxx)。如图 + +![获取音色资源](images/image-clone-integration-01.png) + +## 第二阶段:配置火山引擎服务 + +### 1.填写火山引擎配置 + +使用超级管理员账号登录智控台,点击顶部【模型配置】,再点击模型配置页面左侧的【语音合成】,搜索找到“火山双流式语音合成”,点击修改,将你火山引擎的`App Id`填入到【应用ID】字段里,将`Access Token`填入到【访问令牌】字段里。然后保存。 + +### 2.将音色资源ID分配给系统账号 + +使用超级管理员账号登录智控台,点击顶部`参数字典`,在下拉菜单中,点击`系统功能配置`页面。在页面上勾选`音色克隆`,点击保存配置。即可在顶部菜单看到`音色克隆`按钮。 + +使用超级管理员账号登录智控台,点击顶部【音色克隆】、【音色资源】。 + +点击新增按钮,在【平台名称】选择“火山双流式语音合成”; + +在【音色资源ID】填入你火山引擎的声音资源ID(S_xxxxx),填入后按回车; + +在【归属账号】选择你要分配给的系统账号,你可以分配给你自己。然后点击保存 + +## 第三阶段:克隆阶段 + +如果登录后,点击顶部【音色克隆】》【音色克隆】,显示【您的账号暂无音色资源请联系管理员分配音色资源】,说明你在第二阶段还没有把音色资源ID分配给这个账号。那就是回到第二阶段,分配音色资源给对应的账号。 + +如果登录后,点击顶部【音色克隆】》【音色克隆】,能看到对应的音色列表。请继续。 + +在列表里会看到对应的音色列表。选择其中一个音色资源,点击【上传音频】按钮。上传后,可以试听一下声音或者截取某段声音。确认后点击【上传音频】按钮。 +![上传音频](images/image-clone-integration-02.png) + +上传音频后,在列表里会看到对应的音色会变成“待复刻”状态。点击【立即复刻】按钮。等1~2秒会返回结果。 + +如果复刻失败,请将鼠标放到“错误信息”图标上,会显示失败的原因。 + +如果复刻成功,在列表里会看到对应的音色会变成“训练成功”状态。此时你可以点击【声音名称】栏的修改按钮,修改音色资源的名称,方便后期选择使用。 + +## 第四阶段:使用阶段 + +点击顶部【智能体管理】,选择任意一个智能体,点击【配置角色】按钮。 + +语音合成(TTS)选择“火山双流式语音合成”。在列表里,找到名字带有“克隆音色”的音色资源(如图),选择它,点击保存。 +![选择音色](images/image-clone-integration-03.png) + +接下来,可以唤醒小智和它对话。 diff --git a/backend/docs/images/__init__.py b/backend/docs/images/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/docs/images/alisms/sms-01.png b/backend/docs/images/alisms/sms-01.png new file mode 100644 index 0000000..89c56f5 Binary files /dev/null and b/backend/docs/images/alisms/sms-01.png differ diff --git a/backend/docs/images/alisms/sms-02.png b/backend/docs/images/alisms/sms-02.png new file mode 100644 index 0000000..22537f3 Binary files /dev/null and b/backend/docs/images/alisms/sms-02.png differ diff --git a/backend/docs/images/alisms/sms-11.png b/backend/docs/images/alisms/sms-11.png new file mode 100644 index 0000000..05fcaf5 Binary files /dev/null and b/backend/docs/images/alisms/sms-11.png differ diff --git a/backend/docs/images/alisms/sms-21.png b/backend/docs/images/alisms/sms-21.png new file mode 100644 index 0000000..5bfc280 Binary files /dev/null and b/backend/docs/images/alisms/sms-21.png differ diff --git a/backend/docs/images/alisms/sms-22.png b/backend/docs/images/alisms/sms-22.png new file mode 100644 index 0000000..3d83984 Binary files /dev/null and b/backend/docs/images/alisms/sms-22.png differ diff --git a/backend/docs/images/alisms/sms-23.png b/backend/docs/images/alisms/sms-23.png new file mode 100644 index 0000000..584d8d6 Binary files /dev/null and b/backend/docs/images/alisms/sms-23.png differ diff --git a/backend/docs/images/alisms/sms-24.png b/backend/docs/images/alisms/sms-24.png new file mode 100644 index 0000000..1b22c35 Binary files /dev/null and b/backend/docs/images/alisms/sms-24.png differ diff --git a/backend/docs/images/alisms/sms-25.png b/backend/docs/images/alisms/sms-25.png new file mode 100644 index 0000000..3bb68cf Binary files /dev/null and b/backend/docs/images/alisms/sms-25.png differ diff --git a/backend/docs/images/alisms/sms-31.png b/backend/docs/images/alisms/sms-31.png new file mode 100644 index 0000000..7f0ee6c Binary files /dev/null and b/backend/docs/images/alisms/sms-31.png differ diff --git a/backend/docs/images/alisms/sms-32.png b/backend/docs/images/alisms/sms-32.png new file mode 100644 index 0000000..db06cc4 Binary files /dev/null and b/backend/docs/images/alisms/sms-32.png differ diff --git a/backend/docs/images/banner1.png b/backend/docs/images/banner1.png new file mode 100644 index 0000000..974ddaf Binary files /dev/null and b/backend/docs/images/banner1.png differ diff --git a/backend/docs/images/banner2.png b/backend/docs/images/banner2.png new file mode 100644 index 0000000..4d54073 Binary files /dev/null and b/backend/docs/images/banner2.png differ diff --git a/backend/docs/images/conda_env_1.png b/backend/docs/images/conda_env_1.png new file mode 100644 index 0000000..114256a Binary files /dev/null and b/backend/docs/images/conda_env_1.png differ diff --git a/backend/docs/images/conda_env_2.png b/backend/docs/images/conda_env_2.png new file mode 100644 index 0000000..61f4626 Binary files /dev/null and b/backend/docs/images/conda_env_2.png differ diff --git a/backend/docs/images/demo0.png b/backend/docs/images/demo0.png new file mode 100644 index 0000000..99592be Binary files /dev/null and b/backend/docs/images/demo0.png differ diff --git a/backend/docs/images/demo1.png b/backend/docs/images/demo1.png new file mode 100644 index 0000000..1ab7c22 Binary files /dev/null and b/backend/docs/images/demo1.png differ diff --git a/backend/docs/images/demo10.png b/backend/docs/images/demo10.png new file mode 100644 index 0000000..08bdb77 Binary files /dev/null and b/backend/docs/images/demo10.png differ diff --git a/backend/docs/images/demo11.png b/backend/docs/images/demo11.png new file mode 100644 index 0000000..36e16a1 Binary files /dev/null and b/backend/docs/images/demo11.png differ diff --git a/backend/docs/images/demo12.png b/backend/docs/images/demo12.png new file mode 100644 index 0000000..c658d67 Binary files /dev/null and b/backend/docs/images/demo12.png differ diff --git a/backend/docs/images/demo13.png b/backend/docs/images/demo13.png new file mode 100644 index 0000000..1ad79fa Binary files /dev/null and b/backend/docs/images/demo13.png differ diff --git a/backend/docs/images/demo14.png b/backend/docs/images/demo14.png new file mode 100644 index 0000000..48360cf Binary files /dev/null and b/backend/docs/images/demo14.png differ diff --git a/backend/docs/images/demo2.png b/backend/docs/images/demo2.png new file mode 100644 index 0000000..6b30494 Binary files /dev/null and b/backend/docs/images/demo2.png differ diff --git a/backend/docs/images/demo3.png b/backend/docs/images/demo3.png new file mode 100644 index 0000000..e1bc859 Binary files /dev/null and b/backend/docs/images/demo3.png differ diff --git a/backend/docs/images/demo4.png b/backend/docs/images/demo4.png new file mode 100644 index 0000000..e0b5ba7 Binary files /dev/null and b/backend/docs/images/demo4.png differ diff --git a/backend/docs/images/demo5.png b/backend/docs/images/demo5.png new file mode 100644 index 0000000..c6da299 Binary files /dev/null and b/backend/docs/images/demo5.png differ diff --git a/backend/docs/images/demo6.png b/backend/docs/images/demo6.png new file mode 100644 index 0000000..51f1f5e Binary files /dev/null and b/backend/docs/images/demo6.png differ diff --git a/backend/docs/images/demo7.png b/backend/docs/images/demo7.png new file mode 100644 index 0000000..ed7a355 Binary files /dev/null and b/backend/docs/images/demo7.png differ diff --git a/backend/docs/images/demo8.png b/backend/docs/images/demo8.png new file mode 100644 index 0000000..affe6ce Binary files /dev/null and b/backend/docs/images/demo8.png differ diff --git a/backend/docs/images/demo9.png b/backend/docs/images/demo9.png new file mode 100644 index 0000000..ff422fe Binary files /dev/null and b/backend/docs/images/demo9.png differ diff --git a/backend/docs/images/deploy1.png b/backend/docs/images/deploy1.png new file mode 100644 index 0000000..70488bc Binary files /dev/null and b/backend/docs/images/deploy1.png differ diff --git a/backend/docs/images/deploy2.png b/backend/docs/images/deploy2.png new file mode 100644 index 0000000..7844153 Binary files /dev/null and b/backend/docs/images/deploy2.png differ diff --git a/backend/docs/images/firmware-setting-ota.png b/backend/docs/images/firmware-setting-ota.png new file mode 100644 index 0000000..c151fd9 Binary files /dev/null and b/backend/docs/images/firmware-setting-ota.png differ diff --git a/backend/docs/images/fishspeech/autodl-01.png b/backend/docs/images/fishspeech/autodl-01.png new file mode 100644 index 0000000..695b94b Binary files /dev/null and b/backend/docs/images/fishspeech/autodl-01.png differ diff --git a/backend/docs/images/fishspeech/autodl-02.png b/backend/docs/images/fishspeech/autodl-02.png new file mode 100644 index 0000000..e3f72af Binary files /dev/null and b/backend/docs/images/fishspeech/autodl-02.png differ diff --git a/backend/docs/images/hnlg.jpg b/backend/docs/images/hnlg.jpg new file mode 100644 index 0000000..b79be6f Binary files /dev/null and b/backend/docs/images/hnlg.jpg differ diff --git a/backend/docs/images/image-clone-integration-01.png b/backend/docs/images/image-clone-integration-01.png new file mode 100644 index 0000000..7132ee7 Binary files /dev/null and b/backend/docs/images/image-clone-integration-01.png differ diff --git a/backend/docs/images/image-clone-integration-02.png b/backend/docs/images/image-clone-integration-02.png new file mode 100644 index 0000000..80972df Binary files /dev/null and b/backend/docs/images/image-clone-integration-02.png differ diff --git a/backend/docs/images/image-clone-integration-03.png b/backend/docs/images/image-clone-integration-03.png new file mode 100644 index 0000000..7f35e39 Binary files /dev/null and b/backend/docs/images/image-clone-integration-03.png differ diff --git a/backend/docs/images/image-ha-integration-01.png b/backend/docs/images/image-ha-integration-01.png new file mode 100644 index 0000000..eb05461 Binary files /dev/null and b/backend/docs/images/image-ha-integration-01.png differ diff --git a/backend/docs/images/image-ha-integration-02.png b/backend/docs/images/image-ha-integration-02.png new file mode 100644 index 0000000..7431def Binary files /dev/null and b/backend/docs/images/image-ha-integration-02.png differ diff --git a/backend/docs/images/image-ha-integration-03.png b/backend/docs/images/image-ha-integration-03.png new file mode 100644 index 0000000..3f1aa59 Binary files /dev/null and b/backend/docs/images/image-ha-integration-03.png differ diff --git a/backend/docs/images/image-ha-integration-04.png b/backend/docs/images/image-ha-integration-04.png new file mode 100644 index 0000000..29b402e Binary files /dev/null and b/backend/docs/images/image-ha-integration-04.png differ diff --git a/backend/docs/images/image-ha-integration-05.png b/backend/docs/images/image-ha-integration-05.png new file mode 100644 index 0000000..1aa8ffc Binary files /dev/null and b/backend/docs/images/image-ha-integration-05.png differ diff --git a/backend/docs/images/image-ha-integration-06.png b/backend/docs/images/image-ha-integration-06.png new file mode 100644 index 0000000..56ef98f Binary files /dev/null and b/backend/docs/images/image-ha-integration-06.png differ diff --git a/backend/docs/images/logo_bailing.png b/backend/docs/images/logo_bailing.png new file mode 100644 index 0000000..22ab6e1 Binary files /dev/null and b/backend/docs/images/logo_bailing.png differ diff --git a/backend/docs/images/logo_contributors.png b/backend/docs/images/logo_contributors.png new file mode 100644 index 0000000..5e8febe Binary files /dev/null and b/backend/docs/images/logo_contributors.png differ diff --git a/backend/docs/images/logo_huiyuan.png b/backend/docs/images/logo_huiyuan.png new file mode 100644 index 0000000..6e44191 Binary files /dev/null and b/backend/docs/images/logo_huiyuan.png differ diff --git a/backend/docs/images/logo_junsen.png b/backend/docs/images/logo_junsen.png new file mode 100644 index 0000000..ded09f2 Binary files /dev/null and b/backend/docs/images/logo_junsen.png differ diff --git a/backend/docs/images/logo_qinren.png b/backend/docs/images/logo_qinren.png new file mode 100644 index 0000000..a01af84 Binary files /dev/null and b/backend/docs/images/logo_qinren.png differ diff --git a/backend/docs/images/logo_tenclass.png b/backend/docs/images/logo_tenclass.png new file mode 100644 index 0000000..86a6dc4 Binary files /dev/null and b/backend/docs/images/logo_tenclass.png differ diff --git a/backend/docs/images/logo_xuanfeng.png b/backend/docs/images/logo_xuanfeng.png new file mode 100644 index 0000000..552ee78 Binary files /dev/null and b/backend/docs/images/logo_xuanfeng.png differ diff --git a/backend/docs/images/manager-mobile/打包发行步骤1.png b/backend/docs/images/manager-mobile/打包发行步骤1.png new file mode 100644 index 0000000..88cabf4 Binary files /dev/null and b/backend/docs/images/manager-mobile/打包发行步骤1.png differ diff --git a/backend/docs/images/manager-mobile/打包发行步骤2.png b/backend/docs/images/manager-mobile/打包发行步骤2.png new file mode 100644 index 0000000..747b5ff Binary files /dev/null and b/backend/docs/images/manager-mobile/打包发行步骤2.png differ diff --git a/backend/docs/images/manager-mobile/本地运行.png b/backend/docs/images/manager-mobile/本地运行.png new file mode 100644 index 0000000..c3c5b6e Binary files /dev/null and b/backend/docs/images/manager-mobile/本地运行.png differ diff --git a/backend/docs/images/manager-mobile/生成appid.png b/backend/docs/images/manager-mobile/生成appid.png new file mode 100644 index 0000000..73e6357 Binary files /dev/null and b/backend/docs/images/manager-mobile/生成appid.png differ diff --git a/backend/docs/images/manager-mobile/重新识别项目.png b/backend/docs/images/manager-mobile/重新识别项目.png new file mode 100644 index 0000000..0e9c1c9 Binary files /dev/null and b/backend/docs/images/manager-mobile/重新识别项目.png differ diff --git a/backend/docs/index-stream-integration.md b/backend/docs/index-stream-integration.md new file mode 100644 index 0000000..752fa89 --- /dev/null +++ b/backend/docs/index-stream-integration.md @@ -0,0 +1,195 @@ +# IndexStreamTTS 使用指南 + +## 环境准备 +### 1. 克隆项目 +```bash +git clone https://github.com/Ksuriuri/index-tts-vllm.git +``` +进入解压后的目录 +```bash +cd index-tts-vllm +``` +切换到指定版本 (使用VLLM-0.10.2的历史版本) +```bash +git checkout 224e8d5e5c8f66801845c66b30fa765328fd0be3 +``` + +### 2. 创建并激活 conda 环境 +```bash +conda create -n index-tts-vllm python=3.12 +conda activate index-tts-vllm +``` + +### 3. 安装PyTorch 需要版本为2.8.0(最新版) +#### 查看显卡最高支持的版本和实际安装的版本 +```bash +nvidia-smi +nvcc --version +``` +#### 驱动支持的最高 CUDA 版本 +```bash +CUDA Version: 12.8 +``` +#### 实际安装的 CUDA 编译器版本 +```bash +Cuda compilation tools, release 12.8, V12.8.89 +``` +#### 那么对应的安装命令(pytorch默认给的是12.8的驱动版本) +```bash +pip install torch torchvision +``` +需要 pytorch 版本 2.8.0(对应 vllm 0.10.2),具体安装指令请参考:[pytorch 官网](https://pytorch.org/get-started/locally/) + +### 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 +mkdir model_dir +cd model_dir +git clone https://www.modelscope.cn/IndexTeam/IndexTTS-1.5.git +``` + +#### 模型权重转换 +```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 +vi api_server.py +``` +```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/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 + +# 查找占用VLLM::EngineCore进程 +GPU_PIDS=$(ps aux | grep -E "VLLM|EngineCore" | grep -v grep | awk '{print $2}') + +# 检查是否找到进程号 +if [ -z "$GPU_PIDS" ]; then + echo "没有找到VLLM相关进程" +else + echo "找到VLLM相关进程,进程号为: $GPU_PIDS" + # 先尝试普通kill,等待2秒 + kill $GPU_PIDS + sleep 2 + # 检查进程是否还在 + if ps -p $GPU_PIDS > /dev/null; then + echo "进程仍在运行,强制终止..." + kill -9 $GPU_PIDS + fi + echo "已终止进程 $GPU_PIDS" +fi + +# 创建tmp目录(如果不存在) +mkdir -p tmp + +# 后台运行api_server.py,日志重定向到tmp/server.log +nohup python api_server.py --model_dir /home/system/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 start_api.sh +./start_api.sh +``` +日志会在tmp/server.log中输出,可以通过以下命令查看日志情况 +```bash +tail -f tmp/server.log +``` +如果显卡内存足够,可在脚本中添加启动参数 ----gpu_memory_utilization 来调整显存占用比例,默认值为 0.25 + +## 音色配置 +index-tts-vllm支持通过配置文件注册自定义音色,支持单音色和混合音色配置。 +在项目根目录下的assets/speaker.json文件中配置自定义音色 +### 配置格式说明 +```bash +{ + "说话人名称1": [ + "音频文件路径1.wav", + "音频文件路径2.wav" + ], + "说话人名称2": [ + "音频文件路径3.wav" + ] +} +``` +### 注意 (配置角色后需重启服务进行音色注册) +添加后需在智控台中添加相应的说话人(单模块则更换相应的voice) \ No newline at end of file diff --git a/backend/docs/mcp-endpoint-enable.md b/backend/docs/mcp-endpoint-enable.md new file mode 100644 index 0000000..2d86f80 --- /dev/null +++ b/backend/docs/mcp-endpoint-enable.md @@ -0,0 +1,126 @@ +# MCP 接入点部署使用指南 + +本教程包含3个部分 +- 1、如何部署MCP接入点这个服务 +- 2、全模块部署时,怎么配置MCP接入点 +- 3、单模块部署时,怎么配置MCP接入点 + +# 1、如何部署MCP接入点这个服务 + +## 第一步,下载mcp接入点项目源码 + +浏览器打开[mcp接入点项目地址](https://github.com/xinnan-tech/mcp-endpoint-server) + +打开完,找到页面中一个绿色的按钮,写着`Code`的按钮,点开它,然后你就看到`Download ZIP`的按钮。 + +点击它,下载本项目源码压缩包。下载到你电脑后,解压它,此时它的名字可能叫`mcp-endpoint-server-main` +你需要把它重命名成`mcp-endpoint-server`。 + +## 第二步,启动程序 +这个项目是一个很简单的项目,建议使用docker运行。不过如果你不想使用docker运行,你可以参考[这个页面](https://github.com/xinnan-tech/mcp-endpoint-server/blob/main/README_dev.md)使用源码运行。以下是docker运行的方法 + +``` +# 进入本项目源码根目录 +cd mcp-endpoint-server + +# 清除缓存 +docker compose -f docker-compose.yml down +docker stop mcp-endpoint-server +docker rm mcp-endpoint-server +docker rmi ghcr.nju.edu.cn/xinnan-tech/mcp-endpoint-server:latest + +# 启动docker容器 +docker compose -f docker-compose.yml up -d +# 查看日志 +docker logs -f mcp-endpoint-server +``` + +此时,日志里会输出类似以下的日志 +``` +250705 INFO-=====下面的地址分别是智控台/单模块MCP接入点地址==== +250705 INFO-智控台MCP参数配置: http://172.22.0.2:8004/mcp_endpoint/health?key=abc +250705 INFO-单模块部署MCP接入点: ws://172.22.0.2:8004/mcp_endpoint/mcp/?token=def +250705 INFO-=====请根据具体部署选择使用,请勿泄露给任何人====== +``` + +请你把两个接口地址复制出来: + +由于你是docker部署,切不可直接使用上面的地址! + +由于你是docker部署,切不可直接使用上面的地址! + +由于你是docker部署,切不可直接使用上面的地址! + +你先把地址复制出来,放在一个草稿里,你要知道你的电脑的局域网ip是什么,例如我的电脑局域网ip是`192.168.1.25`,那么 +原来我的接口地址 +``` +智控台MCP参数配置: http://172.22.0.2:8004/mcp_endpoint/health?key=abc +单模块部署MCP接入点: ws://172.22.0.2:8004/mcp_endpoint/mcp/?token=def +``` +就要改成 +``` +智控台MCP参数配置: http://192.168.1.25:8004/mcp_endpoint/health?key=abc +单模块部署MCP接入点: ws://192.168.1.25:8004/mcp_endpoint/mcp/?token=def +``` + +改好后,请使用浏览器直接访问`智控台MCP参数配置`。当浏览器出现类似这样的代码,说明是成功了。 +``` +{"result":{"status":"success","connections":{"tool_connections":0,"robot_connections":0,"total_connections":0}},"error":null,"id":null,"jsonrpc":"2.0"} +``` + +请你保留好上面两个`接口地址`,下一步要用到。 + +# 2、全模块部署时,怎么配置MCP接入点 +首先,你要开启MCP接入点功能。在智控台,点击顶部`参数字典`,在下拉菜单中,点击`系统功能配置`页面。在页面上勾选`MCP接入点`,点击`保存配置`。在`角色配置`页面,点击`编辑功能`按钮,即可看到`mcp接入点`功能。 + +如果你是全模块部署,使用管理员账号,登录智控台,点击顶部`参数字典`,选择`参数管理`功能。 + +然后搜索参数`server.mcp_endpoint`,此时,它的值应该是`null`值。 +点击修改按钮,把上一步得来的`智控台MCP参数配置`粘贴到`参数值`里。然后保存。 + +如果能保存成功,说明一切顺利,你可以去智能体查看效果了。如果不成功,说明智控台无法访问mcp接入点,很大概率是网络防火墙,或者没有填写正确的局域网ip。 + +# 3、单模块部署时,怎么配置MCP接入点 + +如果你是单模块部署,找到你的配置文件`data/.config.yaml`。 +在配置文件搜索`mcp_endpoint`,如果没有找到,你就增加`mcp_endpoint`配置。类似我是就是这样 +``` +server: + websocket: ws://你的ip或者域名:端口号/xiaozhi/v1/ + http_port: 8002 +log: + log_level: INFO + +# 此处可能还更多配置.. + +mcp_endpoint: 你的接入点websocket地址 +``` +这时,请你把`如何部署MCP接入点这个服务`中得到的`单模块部署MCP接入点` 粘贴到 `mcp_endpoint`中。类似这样 + +``` +server: + websocket: ws://你的ip或者域名:端口号/xiaozhi/v1/ + http_port: 8002 +log: + log_level: INFO + +# 此处可能还更多配置 + +mcp_endpoint: ws://192.168.1.25:8004/mcp_endpoint/mcp/?token=def +``` + +配置好后,启动单模块会输出如下的日志。 +``` +250705[__main__]-INFO-初始化组件: vad成功 SileroVAD +250705[__main__]-INFO-初始化组件: asr成功 FunASRServer +250705[__main__]-INFO-OTA接口是 http://192.168.1.25:8002/xiaozhi/ota/ +250705[__main__]-INFO-视觉分析接口是 http://192.168.1.25:8002/mcp/vision/explain +250705[__main__]-INFO-mcp接入点是 ws://192.168.1.25:8004/mcp_endpoint/mcp/?token=abc +250705[__main__]-INFO-Websocket地址是 ws://192.168.1.25:8000/xiaozhi/v1/ +250705[__main__]-INFO-=======上面的地址是websocket协议地址,请勿用浏览器访问======= +250705[__main__]-INFO-如想测试websocket请用谷歌浏览器打开test目录下的test_page.html +250705[__main__]-INFO-============================================================= +``` + +如上,如果能输出类似的`mcp接入点是`中`ws://192.168.1.25:8004/mcp_endpoint/mcp/?token=abc`说明配置成功了。 + diff --git a/backend/docs/mcp-endpoint-integration.md b/backend/docs/mcp-endpoint-integration.md new file mode 100644 index 0000000..91d6227 --- /dev/null +++ b/backend/docs/mcp-endpoint-integration.md @@ -0,0 +1,94 @@ +# MCP 接入点使用指南 + +本教程以虾哥开源的mcp计算器功能为示例,介绍如何将自己自定义的mcp服务接入到自己的接入点里。 + +本教程的前提是,你的`xiaozhi-server`已经启用了mcp接入点功能,如果你还没启用,可以先根据[这个教程](./mcp-endpoint-enable.md)启用。 + +# 如何为智能体接入一个简单的mcp功能,如计算器功能 + +### 如果你是全模块部署 +如果你是全模块部署,你可以进入智控台,智能体管理,点击`配置角色`,在`意图识别`的右边,有一个`编辑功能`的按钮。 + +点击这个按钮。在弹出的页面里,位于底部,会有`MCP接入点`,正常来说,会显示这个智能体的`MCP接入点地址`,接下来,我们来给这个智能体扩展一个基于MCP技术的计算器的功能。 + +这个`MCP接入点地址`很重要,你等一下会用到。 + +### 如果你是单模块部署 +如果你是单模块部署,且你已经在配置文件里配置了MCP接入点地址,那么正常来说,单模块部署启动的时候,会输出如下的日志。 +``` +250705[__main__]-INFO-初始化组件: vad成功 SileroVAD +250705[__main__]-INFO-初始化组件: asr成功 FunASRServer +250705[__main__]-INFO-OTA接口是 http://192.168.1.25:8002/xiaozhi/ota/ +250705[__main__]-INFO-视觉分析接口是 http://192.168.1.25:8002/mcp/vision/explain +250705[__main__]-INFO-mcp接入点是 ws://192.168.1.25:8004/mcp_endpoint/mcp/?token=abc +250705[__main__]-INFO-Websocket地址是 ws://192.168.1.25:8000/xiaozhi/v1/ +250705[__main__]-INFO-=======上面的地址是websocket协议地址,请勿用浏览器访问======= +250705[__main__]-INFO-如想测试websocket请用谷歌浏览器打开test目录下的test_page.html +250705[__main__]-INFO-============================================================= +``` + +如上,输出`mcp接入点是`中`ws://192.168.1.25:8004/mcp_endpoint/mcp/?token=abc`就是你的`MCP接入点地址`。 + +这个`MCP接入点地址`很重要,你等一下会用到。 + +## 第一步 下载虾哥MCP计算器项目代码 + +浏览器打开虾哥写的[计算器项目](https://github.com/78/mcp-calculator), + +打开完,找到页面中一个绿色的按钮,写着`Code`的按钮,点开它,然后你就看到`Download ZIP`的按钮。 + +点击它,下载本项目源码压缩包。下载到你电脑后,解压它,此时它的名字可能叫`mcp-calculatorr-main` +你需要把它重命名成`mcp-calculator`。接下来,我们用命令行进入项目目录即安装依赖 + + +```bash +# 进入项目目录 +cd mcp-calculator + +conda remove -n mcp-calculator --all -y +conda create -n mcp-calculator python=3.10 -y +conda activate mcp-calculator + +pip install -r requirements.txt +``` + +## 第二步 启动 + +启动前,先从你的智控台的智能体里,复制到了MCP接入点的地址。 + +例如我的智能体的mcp地址是 +``` +ws://192.168.1.25:8004/mcp_endpoint/mcp/?token=abc +``` + +开始输入命令 + +```bash +export MCP_ENDPOINT=ws://192.168.1.25:8004/mcp_endpoint/mcp/?token=abc +``` + +输入完后,启动程序 + +```bash +python mcp_pipe.py calculator.py +``` + +### 如果你是智控台部署 +如果你是智控台部署,启动完后,你再进入智控台,点击刷新MCP的接入状态,就会看到你扩展的功能列表了。 + +### 如果你是单模块部署 +如果你是单模块部署,当设备连接后,会输出类似的日志,说明成功了 + +``` +250705 -INFO-正在初始化MCP接入点: wss://2662r3426b.vicp.fun/mcp_e +250705 -INFO-发送MCP接入点初始化消息 +250705 -INFO-MCP接入点连接成功 +250705 -INFO-MCP接入点初始化成功 +250705 -INFO-统一工具处理器初始化完成 +250705 -INFO-MCP接入点服务器信息: name=Calculator, version=1.9.4 +250705 -INFO-MCP接入点支持的工具数量: 1 +250705 -INFO-所有MCP接入点工具已获取,客户端准备就绪 +250705 -INFO-工具缓存已刷新 +250705 -INFO-当前支持的函数列表: [ 'get_time', 'get_lunar', 'play_music', 'get_weather', 'handle_exit_intent', 'calculator'] +``` +如果包含了 `'calculator'`,说明设备将可以根据意图识别,调用计算器这个工具。 \ No newline at end of file diff --git a/backend/docs/mcp-get-device-info.md b/backend/docs/mcp-get-device-info.md new file mode 100644 index 0000000..bf47995 --- /dev/null +++ b/backend/docs/mcp-get-device-info.md @@ -0,0 +1,40 @@ +# MCP 方法如何获取设备信息 + +本教程将指导你如何使用MCP方法获取设备信息。 + +第一步:自定义你的`agent-base-prompt.txt`文件 + +把xiaozhi-server目录的`agent-base-prompt.txt`文件内容复制到你的`data`目录下,并重命名为`.agent-base-prompt.txt`。 + +第二步:修改`data/.agent-base-prompt.txt`文件,找到``标签,在标签内容中添加以下代码内容: +``` +- **设备ID:** {{device_id}} +``` + +添加完成后,你的`data/.agent-base-prompt.txt`文件的``标签内容大致如下: +``` + +【重要!以下信息已实时提供,无需调用工具查询,请直接使用:】 +- **设备ID:** {{device_id}} +- **当前时间:** {{current_time}} +- **今天日期:** {{today_date}} ({{today_weekday}}) +- **今天农历:** {{lunar_date}} +- **用户所在城市:** {{local_address}} +- **当地未来7天天气:** {{weather_info}} + +``` + +第三步:修改`data/.config.yaml`文件,找到`agent-base-prompt`配置,修改前内容如下: +``` +prompt_template: agent-base-prompt.txt +``` +修改成 +``` +prompt_template: data/.agent-base-prompt.txt +``` + +第四步:重启你的xiaozhi-server服务。 + +第五步:在你的mcp方法增加名称为`device_id`,类型为`string`,描述为`设备ID`的参数。 + +第六步:重新唤醒小智,让他调用mcp方法,查看你的mcp方法是否可以获取`设备ID`。 diff --git a/backend/docs/mcp-vision-integration.md b/backend/docs/mcp-vision-integration.md new file mode 100644 index 0000000..dbeaa8c --- /dev/null +++ b/backend/docs/mcp-vision-integration.md @@ -0,0 +1,171 @@ +# 视觉模型使用指南 +本教程分为两部分: +- 第一部分:单模块运行xiaozhi-server开启视觉模型 +- 第二部分:全模块运行时,如何开启视觉模型 + +开启视觉模型前,你需要准备三件事: +- 你需要准备一台带摄像头的设备,而且这台设备已经在虾哥仓库里,实现了调用摄像头功能。例如`立创·实战派ESP32-S3开发板` +- 你设备固件的版本升级到1.6.6及以上 +- 你已经成功跑通基础对话模块 + +## 单模块运行xiaozhi-server开启视觉模型 + +### 第一步确认网络 +由于视觉模型会默认启动8003端口。 + +如果你是docker运行,请确认一下你的`docker-compose.yml`是否放了`8003`端口,如果没有就更新最新的`docker-compose.yml`文件 + +如果你是源码运行,确认防火墙是否放行`8003`端口 + +### 第二步选择你的视觉模型 +打开你的`data/.config.yaml`文件,设置你的`selected_module.VLLM`设置为某个视觉模型。目前我们已经支持`openai`类型接口的视觉模型。`ChatGLMVLLM`就是其中一款兼容`openai`的模型。 + +``` +selected_module: + VAD: .. + ASR: .. + LLM: .. + VLLM: ChatGLMVLLM + TTS: .. + Memory: .. + Intent: .. +``` + +假设我们使用`ChatGLMVLLM`作为视觉模型,那我们需要先登录[智谱AI](https://bigmodel.cn/usercenter/proj-mgmt/apikeys)网站,申请密钥。如果你之前已经申请过了密钥,可以复用这个密钥。 + +在你的配置文件中,增加这个配置,如果已经有了这个配置,就设置好你的api_key。 + +``` +VLLM: + ChatGLMVLLM: + api_key: 你的api_key +``` + +### 第三步启动xiaozhi-server服务 +如果你是源码,就输入命令启动 +``` +python app.py +``` +如果你是docker运行,就重启容器 +``` +docker restart xiaozhi-esp32-server +``` + +启动后会输出以下内容的日志。 + +``` +2025-06-01 **** - OTA接口是 http://192.168.4.7:8003/xiaozhi/ota/ +2025-06-01 **** - 视觉分析接口是 http://192.168.4.7:8003/mcp/vision/explain +2025-06-01 **** - Websocket地址是 ws://192.168.4.7:8000/xiaozhi/v1/ +2025-06-01 **** - =======上面的地址是websocket协议地址,请勿用浏览器访问======= +2025-06-01 **** - 如想测试websocket请用谷歌浏览器打开test目录下的test_page.html +2025-06-01 **** - ============================================================= +``` + +启动后,使用使用浏览器打开日志里`视觉分析接口`连接。看看输出了什么?如果你是linux,没有浏览器,你可以执行这个命令: +``` +curl -i 你的视觉分析接口 +``` + +正常来说会这样显示 +``` +MCP Vision 接口运行正常,视觉解释接口地址是:http://xxxx:8003/mcp/vision/explain +``` + +请注意,如果你是公网部署,或者docker部署,一定要改一下你的`data/.config.yaml`里这个配置 +``` +server: + vision_explain: http://你的ip或者域名:端口号/mcp/vision/explain +``` + +为什么呢?因为视觉解释接口需要下发到设备,如果你的地址是局域网地址,或者是docker内部地址,设备是无法访问的。 + +假设你的公网地址是`111.111.111.111`,那么`vision_explain`应该这么配 + +``` +server: + vision_explain: http://111.111.111.111:8003/mcp/vision/explain +``` + +如果你的MCP Vision 接口运行正常,且你也试着用浏览器访问正常打开下发的`视觉解释接口地址`,请继续下一步 + +### 第四步 设备唤醒开启 + +对设备说“请打开摄像头,说你你看到了什么” + +留意xiaozhi-server的日志输出,看看有没有报错。 + + +## 全模块运行时,如何开启视觉模型 + +### 第一步 确认网络 +由于视觉模型会默认启动8003端口。 + +如果你是docker运行,请确认一下你的`docker-compose_all.yml`是否映射了`8003`端口,如果没有就更新最新的`docker-compose_all.yml`文件 + +如果你是源码运行,确认防火墙是否放行`8003`端口 + +### 第二步 确认你配置文件 + +打开你的`data/.config.yaml`文件,确认一下你的配置文件的结构,是否和`data/config_from_api.yaml`一样。如果不一样,或缺少某项,请补齐。 + +### 第三步 配置视觉模型密钥 + +那我们需要先登录[智谱AI](https://bigmodel.cn/usercenter/proj-mgmt/apikeys)网站,申请密钥。如果你之前已经申请过了密钥,可以复用这个密钥。 + +登录`智控台`,顶部菜单点击`模型配置`,在左侧栏点击`视觉打语言模型`,找到`VLLM_ChatGLMVLLM`,点击修改按钮,在弹框中,在`API密钥`输入你密钥,点击保存。 + +保存成功后,去到你需要测试的智能体哪里,点击`配置角色`,在打开的内容里,查看`视觉大语言模型(VLLM)`是否选择了刚才的视觉模型。点击保存。 + +### 第三步 启动xiaozhi-server模块 +如果你是源码,就输入命令启动 +``` +python app.py +``` +如果你是docker运行,就重启容器 +``` +docker restart xiaozhi-esp32-server +``` + +启动后会输出以下内容的日志。 + +``` +2025-06-01 **** - 视觉分析接口是 http://192.168.4.7:8003/mcp/vision/explain +2025-06-01 **** - Websocket地址是 ws://192.168.4.7:8000/xiaozhi/v1/ +2025-06-01 **** - =======上面的地址是websocket协议地址,请勿用浏览器访问======= +2025-06-01 **** - 如想测试websocket请用谷歌浏览器打开test目录下的test_page.html +2025-06-01 **** - ============================================================= +``` + +启动后,使用使用浏览器打开日志里`视觉分析接口`连接。看看输出了什么?如果你是linux,没有浏览器,你可以执行这个命令: +``` +curl -i 你的视觉分析接口 +``` + +正常来说会这样显示 +``` +MCP Vision 接口运行正常,视觉解释接口地址是:http://xxxx:8003/mcp/vision/explain +``` + +请注意,如果你是公网部署,或者docker部署,一定要改一下你的`data/.config.yaml`里这个配置 +``` +server: + vision_explain: http://你的ip或者域名:端口号/mcp/vision/explain +``` + +为什么呢?因为视觉解释接口需要下发到设备,如果你的地址是局域网地址,或者是docker内部地址,设备是无法访问的。 + +假设你的公网地址是`111.111.111.111`,那么`vision_explain`应该这么配 + +``` +server: + vision_explain: http://111.111.111.111:8003/mcp/vision/explain +``` + +如果你的MCP Vision 接口运行正常,且你也试着用浏览器访问正常打开下发的`视觉解释接口地址`,请继续下一步 + +### 第四步 设备唤醒开启 + +对设备说“请打开摄像头,说你你看到了什么” + +留意xiaozhi-server的日志输出,看看有没有报错。 diff --git a/backend/docs/mqtt-gateway-integration.md b/backend/docs/mqtt-gateway-integration.md new file mode 100644 index 0000000..5f8bd51 --- /dev/null +++ b/backend/docs/mqtt-gateway-integration.md @@ -0,0 +1,187 @@ +# MQTT 网关部署教程 + +`xiaozhi-esp32-server`项目,可结合虾哥开源的[xiaozhi-mqtt-gateway](https://github.com/78/xiaozhi-mqtt-gateway) 项目进行简单改造,即可实现小智硬件MQTT+UDP连接。 +本教程分为三部分,你可以根据你是全模块部署还是单模块部署,选择对应的部分接入MQTT网关: +- 第一部分:部署MQTT网关 +- 第二部分:全模块运行实现小智硬件MQTT+UDP连接 +- 第三部分:单模块运行xiaozhi-server实现小智硬件MQTT+UDP连接 + +## 准备阶段 +准备好你的`xiaozhi-server`的`mqtt-websocket`连接地址。在你原来的`websocket地址`基础上,添加`?from=mqtt_gateway`字符,就可以得到`mqtt-websocket`连接地址 + +1、如果你是源码部署,你的`mqtt-websocket`地址是: +``` +ws://127.0.0.1:8000/xiaozhi/v1/?from=mqtt_gateway +``` + +2、如果你是docker部署,你的`mqtt-websocket`地址是 +``` +ws://你宿主机局域网IP:8000/xiaozhi/v1/?from=mqtt_gateway +``` + +## 重要提示 + +如果你是服务器部署,需要确保服务器`1883`、`8884`、`8007`端口都对外开放。`8884`选择的协议类型是`UDP`,其他是`TCP`。 + +如果你是服务器部署,需要确保服务器`1883`、`8884`、`8007`端口都对外开放。`8884`选择的协议类型是`UDP`,其他是`TCP`。 + +如果你是服务器部署,需要确保服务器`1883`、`8884`、`8007`端口都对外开放。`8884`选择的协议类型是`UDP`,其他是`TCP`。 + + +## 第一部分:部署MQTT网关 + +1. 克隆[改造后的xiaozhi-mqtt-gateway项目](https://github.com/xinnan-tech/xiaozhi-mqtt-gateway.git): +```bash +git clone https://ghfast.top/https://github.com/xinnan-tech/xiaozhi-mqtt-gateway.git +cd xiaozhi-mqtt-gateway +``` + +2. 安装依赖: +```bash +npm install +npm install -g pm2 +``` + +3. 配置 `config.json`: +```bash +cp config/mqtt.json.example config/mqtt.json +``` + +4. 编辑配置文件 config/mqtt.json,把你在`本文准备阶段`的`mqtt-websocket`地址替换到`chat_servers`里。例如源码部署的`xiaozhi-server`就是如下配置: + +``` +{ + "production": { + "chat_servers": [ + "ws://127.0.0.1:8000/xiaozhi/v1/?from=mqtt_gateway" + ] + }, + "debug": false, + "max_mqtt_payload_size": 8192, + "mcp_client": { + "capabilities": { + }, + "client_info": { + "name": "xiaozhi-mqtt-client", + "version": "1.0.0" + }, + "max_tools_count": 128 + } +} +``` +5. 在项目根目录创建下`.env`文件,并设置以下环境变量: +``` +PUBLIC_IP=your-ip # 服务器公网IP +MQTT_PORT=1883 # MQTT服务器端口 +UDP_PORT=8884 # UDP服务器端口 +API_PORT=8007 # 管理API端口 +MQTT_SIGNATURE_KEY=test # MQTT签名密钥 +SERVER_SECRET=Te1st12134 # 服务器密钥,请保持和智控台(server.secret)一致或者和xiaozhi-server里(server.auth_key)保持一致 +``` +请注意`PUBLIC_IP`配置,确保其与实际公网IP一致,如果有域名就填域名。 + +`MQTT_SIGNATURE_KEY` 是用于MQTT连接认证的密钥,最好设置成复杂一点的,最好是设置成8个字符以上且同时包含大小写字母,这个密钥稍后还会用到。 + +- 注意不要用简单的密码,比如`123456`、`test`等。 +- 注意不要用简单的密码,比如`123456`、`test`等。 +- 注意不要用简单的密码,比如`123456`、`test`等。 + +`SERVER_SECRET` 是用生成websocket连接的认证信息。 + +1、如果你是全模块部署,且你的智控台的参数管理里`server.auth.enabled`设置成了`true`,那么,`SERVER_SECRET`需要和智控台(`server.secret`)保持一致。 + +2、如果你是单模块部署,且你在配置文件里把`server.auth.enabled`设置成了`true`,那么,`SERVER_SECRET`需要和配置文件里(`server.auth_key`)保持一致。 + + +6. 启动MQTT网关 +``` +# 启动服务 +pm2 start ecosystem.config.js + +# 查看日志 +pm2 logs xz-mqtt +``` + +当你看到如下日志,说明MQTT网关启动成功: +``` +0|xz-mqtt | 2025-09-11T12:14:48: MQTT 服务器正在监听端口 1883 +0|xz-mqtt | 2025-09-11T12:14:48: UDP 服务器正在监听 x.x.x.x:8884 +``` + +如果需要重启MQTT网关,执行如下命令: +``` +pm2 restart xz-mqtt +``` + +## 第二部分:全模块运行实现小智硬件MQTT+UDP连接 + +查看你智控台首页底部的版本号,确认你的智控台版本是否是`0.7.7`及以上版本。如果不是,需要升级智控台。 + +1. 在智控台顶部,点击`参数管理`,搜索`server.mqtt_gateway`,点击编辑,填入你在`.env`文件中设置的`PUBLIC_IP`+`:`+`MQTT_PORT`。类似这样 +``` +192.168.0.7:1883 +``` +2. 在智控台顶部,点击`参数管理`,搜索`server.mqtt_signature_key`,点击编辑,填入你在`.env`文件中设置的`MQTT_SIGNATURE_KEY`。 + +3. 在智控台顶部,点击`参数管理`,搜索`server.udp_gateway`,点击编辑,填入你在`.env`文件中设置的`PUBLIC_IP`+`:`+`UDP_PORT`。类似这样 +``` +192.168.0.7:8884 +``` +4. 在智控台顶部,点击`参数管理`,搜索`server.mqtt_manager_api`,点击编辑,填入你在`.env`文件中设置的`PUBLIC_IP`+`:`+`API_PORT`。类似这样 +``` +192.168.0.7:8007 +``` + +上面的配置完成后,你可以使用curl命令,验证你的ota地址是否会下发mqtt配置,把下面的`http://localhost:8002/xiaozhi/ota/`改成你的ota地址 +``` +curl 'http://localhost:8002/xiaozhi/ota/' \ + -H 'Content-Type: application/json' \ + -H 'Client-Id: 7b94d69a-9808-4c59-9c9b-704333b38aff' \ + -H 'Device-Id: 11:22:33:44:55:66' \ + --data-raw $'{\n "application": {\n "version": "1.0.1",\n "elf_sha256": "1"\n },\n "board": {\n "mac": "11:22:33:44:55:66"\n }\n}' +``` + +如果返回的内容包含`mqtt`相关的配置,说明配置成功。类似这样 + +``` +{"server_time":{"timestamp":1757567894012,"timeZone":"Asia/Shanghai","timezone_offset":480},"activation":{"code":"460609","message":"http://xiaozhi.server.com\n460609","challenge":"11:22:33:44:55:66"},"firmware":{"version":"1.0.1","url":"http://xiaozhi.server.com:8002/xiaozhi/otaMag/download/NOT_ACTIVATED_FIRMWARE_THIS_IS_A_INVALID_URL"},"websocket":{"url":"ws://192.168.4.23:8000/xiaozhi/v1/"},"mqtt":{"endpoint":"192.168.0.7:1883","client_id":"GID_default@@@11_22_33_44_55_66@@@7b94d69a-9808-4c59-9c9b-704333b38aff","username":"eyJpcCI6IjA6MDowOjA6MDowOjA6MSJ9","password":"Y8XP9xcUhVIN9OmbCHT9ETBiYNE3l3Z07Wk46wV9PE8=","publish_topic":"device-server","subscribe_topic":"devices/p2p/11_22_33_44_55_66"}} +``` + +由于MQTT信息是需要靠OTA地址下发的,因此只有你保证能正常连接服务器的OTA地址,重启唤醒即可。 + +唤醒后留意mqtt-gateway的日志,确认是否有连接成功的日志。 +``` +pm2 logs xz-mqtt +``` + +## 第三部分:单模块运行xiaozhi-server实现小智硬件MQTT+UDP连接 + +打开你的`data/.config.yaml`文件,在`server`下找到`mqtt_gateway`填入你在`.env`文件中设置的`PUBLIC_IP`+`:`+`MQTT_PORT`。类似这样 +``` +192.168.0.7:1883 +``` +在`server`下找到`mqtt_signature_key`填入你在`.env`文件中设置的`MQTT_SIGNATURE_KEY`。 + +在`server`下找到`udp_gateway`填入你在`.env`文件中设置的`PUBLIC_IP`+`:`+`UDP_PORT`。类似这样 +``` +192.168.0.7:8884 +``` + +上面的配置完成后,你可以使用curl命令,验证你的ota地址是否会下发mqtt配置,把下面的`http://localhost:8002/xiaozhi/ota/`改成你的ota地址 +``` +curl 'http://localhost:8002/xiaozhi/ota/' \ + -H 'Device-Id: 11:22:33:44:55:66' \ + --data-raw $'{\n "application": {\n "version": "1.0.1",\n "elf_sha256": "1"\n },\n "board": {\n "mac": "11:22:33:44:55:66"\n }\n}' +``` + +如果返回的内容包含`mqtt`相关的配置,说明配置成功。类似这样 +``` +{"server_time":{"timestamp":1758781561083,"timeZone":"GMT+08:00","timezone_offset":480},"activation":{"code":"527111","message":"http://xiaozhi.server.com\n527111","challenge":"11:22:33:44:55:66"},"firmware":{"version":"1.0.1","url":"http://xiaozhi.server.com:8002/xiaozhi/otaMag/download/NOT_ACTIVATED_FIRMWARE_THIS_IS_A_INVALID_URL"},"websocket":{"url":"ws://192.168.1.15:8000/xiaozhi/v1/"},"mqtt":{"endpoint":"192.168.1.15:1883","client_id":"GID_default@@@11_22_33_44_55_66@@@11_22_33_44_55_66","username":"eyJpcCI6IjE5Mi4xNjguMS4xNSJ9","password":"fjAYs49zTJecWqJ3jBt+kqxVn/x7vkXRAc85ak/va7Y=","publish_topic":"device-server","subscribe_topic":"devices/p2p/11_22_33_44_55_66"}} +``` + +由于MQTT信息是需要靠OTA地址下发的,因此只有你保证能正常连接服务器的OTA地址,重启唤醒即可。 + +唤醒后留意mqtt-gateway的日志,确认是否有连接成功的日志。 +``` +pm2 logs xz-mqtt +``` diff --git a/backend/docs/newsnow_plugin_config.md b/backend/docs/newsnow_plugin_config.md new file mode 100644 index 0000000..8be887c --- /dev/null +++ b/backend/docs/newsnow_plugin_config.md @@ -0,0 +1,105 @@ +# get_news_from_newsnow 插件新闻源配置指南 + +## 概述 + +`get_news_from_newsnow` 插件现在支持通过Web管理界面动态配置新闻源,不再需要修改代码。用户可以在智控台中为每个智能体配置不同的新闻源。 + +## 配置方式 + +### 1. 通过Web管理界面配置(推荐) + +1. 登录智控台 +2. 进入"角色配置"页面 +3. 选择要配置的智能体 +4. 点击"编辑功能"按钮 +5. 在右侧参数配置区域找到"newsnow新闻聚合"插件 +6. 在"新闻源配置"字段中输入分号分隔的中文名称 + +### 2. 配置文件方式 + +在 `config.yaml` 中配置: + +```yaml +plugins: + get_news_from_newsnow: + url: "https://newsnow.busiyi.world/api/s?id=" + news_sources: "澎湃新闻;百度热搜;财联社;微博;抖音" +``` + +## 新闻源配置格式 + +新闻源配置使用分号分隔的中文名称,格式为: + +``` +中文名称1;中文名称2;中文名称3 +``` + +### 配置示例 + +``` +澎湃新闻;百度热搜;财联社;微博;抖音;知乎;36氪 +``` + +## 支持的新闻源 + +插件支持以下新闻源的中文名称: + +- 澎湃新闻 +- 百度热搜 +- 财联社 +- 微博 +- 抖音 +- 知乎 +- 36氪 +- 华尔街见闻 +- IT之家 +- 今日头条 +- 虎扑 +- 哔哩哔哩 +- 快手 +- 雪球 +- 格隆汇 +- 法布财经 +- 金十数据 +- 牛客 +- 少数派 +- 稀土掘金 +- 凤凰网 +- 虫部落 +- 联合早报 +- 酷安 +- 远景论坛 +- 参考消息 +- 卫星通讯社 +- 百度贴吧 +- 靠谱新闻 +- 以及更多... + +## 默认配置 + +如果未配置新闻源,插件将使用以下默认配置: + +``` +澎湃新闻;百度热搜;财联社 +``` + +## 使用说明 + +1. **配置新闻源**:在Web界面或配置文件中设置新闻源的中文名称,用分号分隔 +2. **调用插件**:用户可以说"播报新闻"或"获取新闻" +3. **指定新闻源**:用户可以说"播报澎湃新闻"或"获取百度热搜" +4. **获取详情**:用户可以说"详细介绍这条新闻" + +## 工作原理 + +1. 插件接受中文名称作为参数(如"澎湃新闻") +2. 根据配置的新闻源列表,将中文名称转换为对应的英文ID(如"thepaper") +3. 使用英文ID调用API获取新闻数据 +4. 返回新闻内容给用户 + +## 注意事项 + +1. 配置的中文名称必须与 CHANNEL_MAP 中定义的名称完全一致 +2. 配置更改后需要重启服务或重新加载配置 +3. 如果配置的新闻源无效,插件会自动使用默认新闻源 +4. 多个新闻源之间使用英文分号(;)分隔,不要使用中文分号(;) \ No newline at end of file diff --git a/backend/docs/ota-upgrade-guide.md b/backend/docs/ota-upgrade-guide.md new file mode 100644 index 0000000..0df4a2f --- /dev/null +++ b/backend/docs/ota-upgrade-guide.md @@ -0,0 +1,142 @@ +# 单模块部署固件OTA自动升级配置指南 + +本教程将指导你如何在**单模块部署**场景下配置固件OTA自动升级功能,实现设备固件的自动更新。 + +如果你已经使用**全模块部署**,请忽略本教程。 + +## 功能介绍 + +在单模块部署中,xiaozhi-server内置了OTA固件管理功能,可以自动检测设备版本并下发升级固件。系统会根据设备型号和当前版本,自动匹配并推送最新的固件版本。 + +## 前提条件 + +- 你已经成功进行**单模块部署**并运行xiaozhi-server +- 设备能够正常连接到服务器 + +## 第一步 准备固件文件 + +### 1. 创建固件存放目录 + +固件文件需要放在`data/bin/`目录下。如果该目录不存在,请手动创建: + +```bash +mkdir -p data/bin +``` + +### 2. 固件文件命名规则 + +固件文件必须遵循以下命名格式: + +``` +{设备型号}_{版本号}.bin +``` + +**命名规则说明:** +- `设备型号`:设备的型号名称,例如 `lichuang-dev`、`bread-compact-wifi` 等 +- `版本号`:固件版本号,必须以数字开头,支持数字、字母、点号、下划线和短横线,例如 `1.6.6`、`2.0.0` 等 +- 文件扩展名必须是 `.bin` + +**命名示例:** +``` +bread-compact-wifi_1.6.6.bin +lichuang-dev_2.0.0.bin +``` + +### 3. 放置固件文件 + +将准备好的固件文件(.bin文件)复制到`data/bin/`目录下: + +重要的事情说三遍:升级的bin文件是`xiaozhi.bin`,不是全量固件文件`merged-binary.bin`! + +重要的事情说三遍:升级的bin文件是`xiaozhi.bin`,不是全量固件文件`merged-binary.bin`! + +重要的事情说三遍:升级的bin文件是`xiaozhi.bin`,不是全量固件文件`merged-binary.bin`! + +```bash +cp xiaozhi.bin data/bin/设备型号_版本号.bin +``` + +例如: +```bash +cp xiaozhi.bin data/bin/bread-compact-wifi_1.6.6.bin +``` + +## 第二步 配置公网访问地址(仅公网部署需要) + +**注意:此步骤仅适用于单模块公网部署的场景。** + +如果你的xiaozhi-server是公网部署(使用公网IP或域名),**必须**配置`server.vision_explain`参数,因为OTA固件下载地址会使用该配置的域名和端口。 + +如果你是局域网部署,可以跳过此步骤。 + +### 为什么要配置这个参数? + +在单模块部署中,系统生成固件下载地址时,会使用`vision_explain`配置的域名和端口作为基础地址。如果不配置或配置错误,设备将无法访问固件下载地址。 + +### 配置方法 + +打开`data/.config.yaml`文件,找到`server`配置段,设置`vision_explain`参数: + +```yaml +server: + vision_explain: http://你的域名或IP:端口号/mcp/vision/explain +``` + +**配置示例:** + +局域网部署(默认): +```yaml +server: + vision_explain: http://192.168.1.100:8003/mcp/vision/explain +``` + +公网域名部署: +```yaml +server: + vision_explain: http://yourdomain.com:8003/mcp/vision/explain +``` + +### 注意事项 + +- 域名或IP必须是设备能够访问的地址 +- 如果使用Docker部署,不能使用Docker内部地址(如127.0.0.1或localhost) +- 如果你使用了nginx反向代理,请填写对外的地址和端口号,不是本项目运行的端口号 + + +## 常见问题 + +### 1. 设备收不到固件更新 + +**可能原因和解决方法:** + +- 检查固件文件命名是否符合规则:`{型号}_{版本号}.bin` +- 检查固件文件是否正确放置在`data/bin/`目录 +- 检查设备型号是否与固件文件名中的型号匹配 +- 检查固件版本号是否高于设备当前版本 +- 查看服务器日志,确认OTA请求是否正常处理 + +### 2. 设备报告下载地址无法访问 + +**可能原因和解决方法:** + +- 检查`server.vision_explain`配置的域名或IP是否正确 +- 确认端口号配置正确(默认8003) +- 如果是公网部署,确保设备能够访问该公网地址 +- 如果是Docker部署,确保不是使用了内部地址(127.0.0.1) +- 检查防火墙是否开放了对应端口 +- 如果你使用了nginx反向代理,请填写对外的地址和端口号,不是本项目运行的端口号 + +### 3. 如何确认设备当前版本 + +查看OTA请求日志,日志中会显示设备上报的版本号: + +``` +[ota_handler] - 设备 AA:BB:CC:DD:EE:FF 固件已是最新: 1.6.6 +``` + +### 4. 固件文件放置后没有生效 + +系统有30秒的缓存时间(默认),可以: +- 等待30秒后再让设备发起OTA请求 +- 重启xiaozhi-server服务 +- 调整`firmware_cache_ttl`配置为更短的时间 diff --git a/backend/docs/paddlespeech-deploy.md b/backend/docs/paddlespeech-deploy.md new file mode 100644 index 0000000..94621eb --- /dev/null +++ b/backend/docs/paddlespeech-deploy.md @@ -0,0 +1,109 @@ +# PaddleSpeechTTS集成xiaozhi服务 + +## 重点说明 +- 优点:本地离线部署、速度快 +- 缺点:截止2025年9月25日,默认的模型是中文模型,不支持英文转语音。如果含英文会发不出声音,如需同时支持中英文需要自己训练。 + +## 一、基础环境要求 +操作系统: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 + +conda create -n paddle_env python=3.10 -y +conda activate paddle_env +``` +### 3.安装paddle +因CPU架构、GPU架构不同,请根据Paddle官方支持的python版本建立环境 +``` +https://www.paddlepaddle.org.cn/install +``` + +### 4.进入paddlespeech目录 +```bash +cd PaddleSpeech +``` +### 5.安装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 +``` +### 6.使用命令自动下载语音模型 +```bash +paddlespeech tts --input "你好,这是一次测试" +``` +此步骤会自动下载模型缓存至本地 .paddlespeech/models 目录 + +### 7.修改tts_online_application.yaml配置 +参考目录 ```"PaddleSpeech\demos\streaming_tts_server\conf\tts_online_application.yaml"``` +选择```tts_online_application.yaml```文件用编辑器打开,设置```protocol```为```websocket``` + +### 8.启动服务 +```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 + +``` diff --git a/backend/docs/performance_tester.md b/backend/docs/performance_tester.md new file mode 100644 index 0000000..8598712 --- /dev/null +++ b/backend/docs/performance_tester.md @@ -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 +``` \ No newline at end of file diff --git a/backend/docs/powermem-integration.md b/backend/docs/powermem-integration.md new file mode 100644 index 0000000..b9a77ed --- /dev/null +++ b/backend/docs/powermem-integration.md @@ -0,0 +1,345 @@ +# PowerMem 记忆组件集成指南 + +## 简介 + +[PowerMem](https://www.powermem.ai/) 是由 OceanBase 开源的 Agent 记忆组件,通过本地 LLM 进行记忆总结和智能检索,为 AI 代理提供高效的记忆管理功能。 + +费用说明:PowerMem 本身开源免费,实际费用取决于您选择的 LLM 和数据库: +- 使用 SQLite + 免费 LLM(如智谱 glm-4-flash)= **完全免费** +- 使用云端 LLM 或云端数据库 = 按对应服务收费 + +> 💡 **最佳性能提示**:PowerMem 配合 OceanBase 使用可实现最大性能释放,SQLite 仅建议在资源不足的情况下使用。 + +- **GitHub**: https://github.com/oceanbase/powermem +- **官网**: https://www.powermem.ai/ +- **使用示例**: https://github.com/oceanbase/powermem/tree/main/examples + +## 功能特性 + +- **本地总结**:通过 LLM 在本地进行记忆总结和提取 +- **用户画像**:通过 `UserMemory` 自动提取用户信息(姓名、职业、兴趣等),持续更新用户画像 +- **智能遗忘**:基于艾宾浩斯遗忘曲线,自动"遗忘"过时噪声信息 +- **多种存储后端**:支持 OceanBase(推荐,最佳性能)、SeekDB(推荐,AI应用存储一体)、PostgreSQL、SQLite(轻量备选) +- **多种 LLM 支持**:通义千问、智谱(glm-4-flash 免费)、OpenAI 等 +- **智能检索**:基于向量搜索的语义检索能力 +- **私有部署**:完全支持本地私有化部署 +- **异步操作**:高效的异步记忆管理 + +## 安装 + +PowerMem 已添加到项目依赖中,如果需要手动安装: + +```bash +pip install powermem +``` + +## 配置说明 + +### 基础配置 + +在 `config.yaml` 中配置 PowerMem: + +```yaml +selected_module: + Memory: powermem + +Memory: + powermem: + type: powermem + # 是否启用用户画像功能 + # 用户画像支持: oceanbase、seekdb、sqlite (powermem 0.3.0+) + enable_user_profile: true + + # ========== LLM 配置 ========== + llm: + provider: openai # 可选: qwen, openai, zhipu 等 + config: + api_key: 你的LLM API密钥 + model: qwen-plus + # openai_base_url: https://api.openai.com/v1 # 可选,自定义服务地址 + + # ========== Embedding 配置 ========== + embedder: + provider: openai # 可选: qwen, openai 等 + config: + api_key: 你的嵌入模型API密钥 + model: text-embedding-v4 + openai_base_url: https://dashscope.aliyuncs.com/compatible-mode/v1 + # embedding_dims: 1024 # 向量维度,非1536时需配置 + + # ========== Database 配置 ========== + vector_store: + provider: sqlite # 可选: oceanbase(推荐), seekdb(推荐), postgres, sqlite(轻量) + config: {} # SQLite 无需额外配置 +``` + +### 配置参数详解 + +#### LLM 配置 + +| 参数 | 说明 | 可选值 | +|------|------|--------| +| `llm.provider` | LLM 提供商 | `qwen`, `openai`, `zhipu` 等 | +| `llm.config.api_key` | API 密钥 | - | +| `llm.config.model` | 模型名称 | 根据提供商选择 | +| `llm.config.openai_base_url` | 自定义服务地址(可选) | - | + +#### Embedding 配置 + +| 参数 | 说明 | 可选值 | +|------|------|--------| +| `embedder.provider` | 嵌入模型提供商 | `qwen`, `openai` 等 | +| `embedder.config.api_key` | API 密钥 | - | +| `embedder.config.model` | 模型名称 | 根据提供商选择 | +| `embedder.config.openai_base_url` | 自定义服务地址(可选) | - | + +#### Database 配置 + +| 参数 | 说明 | 可选值 | +|------|------|--------| +| `vector_store.provider` | 存储后端类型 | `oceanbase`(推荐), `seekdb`(推荐), `postgres`, `sqlite`(轻量) | +| `vector_store.config` | 数据库连接配置 | 根据 provider 设置 | + +### 记忆模式说明 + +PowerMem 支持两种记忆模式: + +| 模式 | 配置 | 功能 | 存储要求 | +|------|------|------|----------| +| **普通记忆** | `enable_user_profile: false` | 对话记忆存储与检索 | 支持所有数据库 | +| **用户画像** | `enable_user_profile: true` | 记忆 + 自动提取用户画像 | oceanbase、seekdb、sqlite | + +> 📌 **版本说明**:PowerMem 0.3.0+ 版本,用户画像功能支持 OceanBase、SeekDB、SQLite 三种存储后端。 + +### 使用通义千问(推荐) + +1. 访问 [阿里云百炼平台](https://bailian.console.aliyun.com/) 注册账号 +2. 在 [API Key 管理](https://bailian.console.aliyun.com/?apiKey=1#/api-key) 页面获取 API 密钥 +3. 配置如下: + +```yaml +Memory: + powermem: + type: powermem + enable_user_profile: true + llm: + provider: qwen + config: + api_key: sk-xxxxxxxxxxxxxxxx + model: qwen-plus + embedder: + provider: openai + config: + api_key: sk-xxxxxxxxxxxxxxxx + model: text-embedding-v4 + openai_base_url: https://dashscope.aliyuncs.com/compatible-mode/v1 + vector_store: + provider: sqlite + config: {} +``` + +### 使用智谱免费 LLM(完全免费方案) + +智谱提供免费的 glm-4-flash 模型,配合 SQLite 可实现完全免费使用: + +1. 访问 [智谱AI开放平台](https://bigmodel.cn/) 注册账号 +2. 在 [API Keys](https://bigmodel.cn/usercenter/proj-mgmt/apikeys) 页面获取 API 密钥 +3. 配置如下: + +```yaml +Memory: + powermem: + type: powermem + enable_user_profile: true + llm: + provider: openai # 使用 openai 兼容模式 + config: + api_key: xxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxx + model: glm-4-flash + openai_base_url: https://open.bigmodel.cn/api/paas/v4/ + embedder: + provider: openai + config: + api_key: xxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxx + model: embedding-3 + openai_base_url: https://open.bigmodel.cn/api/paas/v4/ + vector_store: + provider: sqlite + config: {} +``` + +### 使用 OpenAI + +```yaml +Memory: + powermem: + type: powermem + enable_user_profile: true + llm: + provider: openai + config: + api_key: sk-xxxxxxxxxxxxxxxx + model: gpt-4o-mini + openai_base_url: https://api.openai.com/v1 + embedder: + provider: openai + config: + api_key: sk-xxxxxxxxxxxxxxxx + model: text-embedding-3-small + openai_base_url: https://api.openai.com/v1 + vector_store: + provider: sqlite + config: {} +``` + +### 使用 OceanBase(最佳性能方案) + +OceanBase 是 PowerMem 的最佳搭档,可实现最大性能释放: + +1. 部署 OceanBase 数据库(支持开源本地部署或使用云服务) + - 开源部署:https://github.com/oceanbase/oceanbase + - 云服务:https://www.oceanbase.com/ +2. 配置如下: + +```yaml +Memory: + powermem: + type: powermem + enable_user_profile: true + llm: + provider: qwen + config: + api_key: sk-xxxxxxxxxxxxxxxx + model: qwen-plus + embedder: + provider: openai + config: + api_key: sk-xxxxxxxxxxxxxxxx + model: text-embedding-v4 + openai_base_url: https://dashscope.aliyuncs.com/compatible-mode/v1 + vector_store: + provider: oceanbase + config: + host: 127.0.0.1 + port: 2881 + user: root@test + password: your_password + db_name: powermem + collection_name: memories # 默认值 + embedding_model_dims: 1536 # 嵌入向量维度,必需参数 +``` + +## 设备记忆隔离 + +PowerMem 会自动使用设备 ID(`device_id`)作为 `user_id` 进行记忆隔离。这意味着: + +- 每个设备拥有独立的记忆空间 +- 不同设备之间的记忆完全隔离 +- 同一设备的多次对话可以共享记忆上下文 + +## 用户画像(UserMemory) + +PowerMem 提供 `UserMemory` 类,可自动从对话中提取用户画像信息。 + +> 📌 **版本说明**:PowerMem 0.3.0+ 版本,用户画像功能支持 OceanBase、SeekDB、SQLite 三种存储后端。 + +### 启用用户画像 + +在配置中设置 `enable_user_profile: true` 即可启用: + +```yaml +Memory: + powermem: + type: powermem + enable_user_profile: true # 启用用户画像 + llm: + provider: qwen + config: + api_key: sk-xxxxxxxxxxxxxxxx + model: qwen-plus + embedder: + provider: openai + config: + api_key: sk-xxxxxxxxxxxxxxxx + model: text-embedding-v4 + openai_base_url: https://dashscope.aliyuncs.com/compatible-mode/v1 + vector_store: + provider: sqlite # 用户画像支持: oceanbase、seekdb、sqlite + config: {} +``` + +### 用户画像能力 + +| 能力 | 说明 | +|------|------| +| **信息提取** | 自动从对话中提取姓名、年龄、职业、兴趣等 | +| **持续更新** | 随着对话进行,不断完善用户画像 | +| **画像检索** | 将用户画像与记忆搜索结合,提升检索相关性 | +| **智能遗忘** | 基于艾宾浩斯遗忘曲线,淡化过时信息 | + +### 工作原理 + +启用用户画像后,小智在查询记忆时会自动返回: +1. **用户画像**:用户的基本信息、兴趣爱好等 +2. **相关记忆**:与当前对话相关的历史记忆 + +> ✅ **版本说明**:PowerMem 0.3.0+ 版本,用户画像功能支持 OceanBase、SeekDB、SQLite 三种存储后端。 + +## 与其他记忆组件的对比 + +| 特性 | PowerMem | mem0ai | mem_local_short | +|------|----------|--------|-----------------| +| 工作方式 | 本地总结 | 云端接口 | 本地总结 | +| 存储位置 | 本地/云端DB | 云端 | 本地YAML | +| 费用 | 取决于LLM和DB | 1000次/月免费 | 完全免费 | +| 智能检索 | ✅ 向量搜索 | ✅ 向量搜索 | ❌ 全量返回 | +| 用户画像 | ✅ UserMemory | ❌ | ❌ | +| 智能遗忘 | ✅ 遗忘曲线 | ❌ | ❌ | +| 私有部署 | ✅ 支持 | ❌ 仅云端 | ✅ 支持 | +| 数据库支持 | OceanBase(推荐)/SeekDB/PostgreSQL/SQLite | - | YAML 文件 | + +## 常见问题 + +### 1. API 密钥错误 + +如果出现 `API key is required` 错误,请检查: +- `llm_api_key` 和 `embedding_api_key` 是否正确填写 +- API 密钥是否有效 + +### 2. 模型不存在 + +如果出现模型不存在的错误,请确认: +- `llm_model` 和 `embedding_model` 名称是否正确 +- 对应的模型服务是否已开通 + +### 3. 连接超时 + +如果出现连接超时,可以尝试: +- 检查网络连接 +- 如果使用代理,配置 `llm_base_url` 和 `embedding_base_url` + +## 测试验证 + +可以在虚拟环境中测试 PowerMem 是否正常工作: + +```bash +# 激活虚拟环境 +source .venv/bin/activate + +# 测试 PowerMem 导入 +python -c "from powermem import AsyncMemory; print('PowerMem 导入成功')" + +# 测试 UserMemory 导入(用户画像功能) +python -c "from powermem import UserMemory; print('UserMemory 导入成功')" +``` + +## 更多资源 + +- [PowerMem 官方文档](https://www.powermem.ai/) +- [PowerMem GitHub 仓库](https://github.com/oceanbase/powermem) +- [PowerMem 使用示例](https://github.com/oceanbase/powermem/tree/main/examples) +- [OceanBase 官网](https://www.oceanbase.com/) +- [OceanBase GitHub](https://github.com/oceanbase/oceanbase) +- [SeekDB GitHub](https://github.com/oceanbase/seekdb)(AI原生搜索数据库) +- [阿里云百炼平台](https://bailian.console.aliyun.com/) + diff --git a/backend/docs/ragflow-integration.md b/backend/docs/ragflow-integration.md new file mode 100644 index 0000000..7d2b4ea --- /dev/null +++ b/backend/docs/ragflow-integration.md @@ -0,0 +1,269 @@ +# ragflow 集成指南 + +本教程主要是是两部分 + +- 一、如何部署ragflow +- 二、如何在智控台配置ragflow接口 + +如果您对ragflow很熟悉,且已经部署了ragflow,可直接跳过第一部分,直接进入第二部分。但是如果你希望有人指导你部署ragflow,让它能够和`xiaozhi-esp32-server`共同使用`mysql`、`redis`基础服务,以减少资源成本,你需要从第一部分开始。 + +# 第一部分 如何部署ragflow +## 第一步, 确认mysql、redis是否可用 + +ragflow需要依赖`mysql`数据库。如果你之前已经部署`智控台`,说明你已经安装了`mysql`。你可以共用它。 + +你可以你试一下在宿主机使用`telnet`命令,看看能不能正常访问`mysql`的`3306`端口。 +``` shell +telnet 127.0.0.1 3306 + +telnet 127.0.0.1 6379 +``` +如果能访问到`3306`端口和`6379`端口,请忽略以下的内容,直接进入第二步。 + +如果不能访问,你需要回忆一下,你的`mysql`是怎么安装的。 + +如果你的mysql是通过自己使用安装包安装的,说明你的`mysql`做了网络隔离。你可能先解决访问`mysql`的`3306`端口这个问题。 + +如果你`mysql`是通过本项目的`docker-compose_all.yml`安装的。你需要找一下你当时创建数据库的`docker-compose_all.yml`文件,修改以下的内容 + +修改前 +``` yaml + xiaozhi-esp32-server-db: + ... + networks: + - default + expose: + - "3306:3306" + xiaozhi-esp32-server-redis: + ... + expose: + - 6379 +``` + +修改后 +``` yaml + xiaozhi-esp32-server-db: + ... + networks: + - default + ports: + - "3306:3306" + xiaozhi-esp32-server-redis: + ... + ports: + - "6379:6379" +``` + +注意是将`xiaozhi-esp32-server-db`和`xiaozhi-esp32-server-redis`下面的`expose`改成`ports`。改完后,需要重新启动。以下是重启mysql的命令: + +``` shell +# 进入你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`端口。 +``` shell +telnet 127.0.0.1 3306 + +telnet 127.0.0.1 6379 +``` +正常来说这样就可以访问的了。 + +## 第二步, 创建数据库和表 +如果你的宿主机,能正常访问mysql数据库,那就在mysql上创建一个名字为`rag_flow`的数据库和`rag_flow`用户,密码为`infini_rag_flow`。 + +``` sql +-- 创建数据库 +CREATE DATABASE IF NOT EXISTS rag_flow CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- 创建用户并授权 +CREATE USER IF NOT EXISTS 'rag_flow'@'%' IDENTIFIED BY 'infini_rag_flow'; +GRANT ALL PRIVILEGES ON rag_flow.* TO 'rag_flow'@'%'; + +-- 刷新权限 +FLUSH PRIVILEGES; +``` + +## 第三步, 下载ragflow项目 + +你需要在你电脑找一个文件夹,用来存放ragflow项目。例如我在`/home/system/xiaozhi`文件夹。 + +你可以使用`git`命令,将ragflow项目下载到这个文件夹,本教程使用的是`v0.22.0`版本进行安装部署。 +``` +git clone https://ghfast.top/https://github.com/infiniflow/ragflow.git +cd ragflow +git checkout v0.22.0 +``` +下载完后,进入`docker`文件夹。 +``` shell +cd docker +``` +修改`ragflow/docker`文件夹下的`docker-compose.yml`文件,将`ragflow-cpu`和`ragflow-gpu`服务的`depends_on`配置去掉,用于解除`ragflow-cpu`服务对`mysql`的依赖。 + +这是修改前: +``` yaml + ragflow-cpu: + depends_on: + mysql: + condition: service_healthy + profiles: + - cpu + ... + ragflow-gpu: + depends_on: + mysql: + condition: service_healthy + profiles: + - gpu +``` +这是修改后: +``` yaml + ragflow-cpu: + profiles: + - cpu + ... + ragflow-gpu: + profiles: + - gpu +``` + +接着,修改`ragflow/docker`文件夹下的`docker-compose-base.yml`文件,去掉`mysql`和`redis`的配置。 + +例如,删除前: +``` yaml +services: + minio: + image: quay.io/minio/minio:RELEASE.2025-06-13T11-33-47Z + ... + mysql: + image: mysql:8.0 + ... + redis: + image: redis:6.2-alpine + ... +``` + +删除后 +``` yaml +services: + minio: + image: quay.io/minio/minio:RELEASE.2025-06-13T11-33-47Z + ... +``` +## 第四步,修改环境变量配置 + +编辑`ragflow/docker`文件夹下的`.env`文件,找到以下配置,逐个搜索,逐个修改!逐个搜索,逐个修改! + +下面对于`.env`文件的修改,60%的人会忽略`MYSQL_USER`配置导致ragflow启动不成功,因此,需要强调三次: + +强调第一次:如果你的`.env`文件如果没有`MYSQL_USER`配置,请在配置文件增加这项! + +强调第二次:如果你的`.env`文件如果没有`MYSQL_USER`配置,请在配置文件增加这项! + +强调第三次:如果你的`.env`文件如果没有`MYSQL_USER`配置,请在配置文件增加这项! + +``` env +# 端口设置 +SVR_WEB_HTTP_PORT=8008 # HTTP端口 +SVR_WEB_HTTPS_PORT=8009 # HTTPS端口 +# MySQL配置 - 修改为您本地MySQL的信息 +MYSQL_HOST=host.docker.internal # 使用host.docker.internal让容器访问主机服务 +MYSQL_PORT=3306 # 本地MySQL端口 +MYSQL_USER=rag_flow # 上面创建的用户名,如果没有这项就增加这一项 +MYSQL_PASSWORD=infini_rag_flow # 上面设置的密码 +MYSQL_DBNAME=rag_flow # 数据库名称 + +# Redis配置 - 修改为您本地Redis的信息 +REDIS_HOST=host.docker.internal # 使用host.docker.internal让容器访问主机服务 +REDIS_PORT=6379 # 本地Redis端口 +REDIS_PASSWORD= # 如果你的Redis没有设置密码,就按这样子填写,否则填写密码 +``` + +注意,如果你的Redis没有设置密码,还要修改`ragflow/docker`文件夹下`service_conf.yaml.template`,将`infini_rag_flow`替换成空字符串。 + +修改前 +``` shell +redis: + db: 1 + password: '${REDIS_PASSWORD:-infini_rag_flow}' + host: '${REDIS_HOST:-redis}:6379' +``` +修改后 +``` shell +redis: + db: 1 + password: '${REDIS_PASSWORD:-}' + host: '${REDIS_HOST:-redis}:6379' +``` + +## 第五步,启动ragflow服务 +执行命令: +``` shell +docker-compose -f docker-compose.yml up -d +``` +执行成功后,你可以使用`docker logs -n 20 -f docker-ragflow-cpu-1`命令,查看`docker-ragflow-cpu-1`服务的日志。 + +如果日志中没有报错,说明ragflow服务启动成功。 + +# 第五步,注册账号 +你可以在浏览器中访问`http://127.0.0.1:8008`,点击`Sign Up`,注册一个账号。 + +注册成功后,你可以点击`Sign In`,登录到ragflow服务。如果你想关闭ragflow服务的注册服务,不想让其他人注册账号,你可以在`ragflow/docker`文件夹下的`.env`文件中,将`REGISTER_ENABLED`配置项设置为`0`。 + +``` dotenv +REGISTER_ENABLED=0 +``` +修改后,重启启动ragflow服务。 +``` shell +docker-compose -f docker-compose.yml down +docker-compose -f docker-compose.yml up -d +``` + +# 第六步,配置ragflow服务的模型 +你可以在浏览器中访问`http://127.0.0.1:8008`,点击`Sign In`,登录到ragflow服务。点击页面右上角的`头像`,进入设置页面。 +首先,在左侧导航栏中,点击`模型供应商`,进入到模型配置页面。在右侧的`可选模型`搜索框下,选择`LLM`,在列表选择你使用的模型供应商,点击`添加`,输入你的密钥; +然后,选择`TEXT EMBEDDING`,在列表选择你使用的模型供应商,点击`添加`,输入你的密钥。 +最后,刷新一下页面,分别点击`设置默认模型`列表的LLM和Embedding,选择你使用的模型即可。请确认你的密钥开通了相应的服务,比如我是用的Embedding模型是xxx供应商的,需要去这个供应商官网查看这个模型是否需要购买资源包才能使用。 + + +# 第二部分 配置ragflow服务 + +# 第一步 登录ragflow服务 +你可以在浏览器中访问`http://127.0.0.1:8008`,点击`Sign In`,登录到ragflow服务。 + +然后点击右上角的`头像`,进入设置页面。在左侧导航栏中,点击`API`功能,然后点击"API Key"按钮。出现一个弹框, + +在弹框中,点击"Create new Key"按钮,生成一个API Key。复制这个`API Key`,你稍后会用到。 + +# 第二步 配置到智控台 +确保你的智控台版本是`0.8.7`或以上。使用超级管理员账号登录到智控台。 + +首先,你要先开启知识库功能。在顶部导航栏中,点击`参数字典`,在下拉菜单中,点击`系统功能配置`页面。在页面上勾选`知识库`,点击`保存配置`。即可在导航栏看到`知识库`功能。 + +在顶部导航栏中,点击`模型配置`,在左侧导航栏中,点击`知识库`。在列表中找到`RAG_RAGFlow`,点击`编辑`按钮。 + +在`服务地址`中,填写`http://你的ragflow服务的局域网IP:8008`,例如我的ragflow服务的局域网IP是`192.168.1.100`,那么我就填写`http://192.168.1.100:8008`。 + +在`API密钥`中,填写之前复制的`API Key`。 + +最后点击保存按钮。 + +# 第二步 创建一个知识库 +使用超级管理员账号登录到智控台。在顶部导航栏中,点击`知识库`,在列表左下脚,点击`新增`按钮。填写一个知识库的名字和描述。点击保存。 + +为了提高大模型对知识库的理解和召回能力,建议在创建知识库时,填写一个有意义的名字和描述。例如,如果你要创建一个关于`公司介绍`的知识库,那么知识库的名字可以是`公司介绍`,描述可以是`关于公司的相关信息例如公司基本信息、服务项目、联系电话、地址等。`。 + +保存后,你可以在知识库列表中看到这个知识库。点击刚才创建的知识库的`查看`按钮,进入知识库详情页面。 + +在知识库详情页面中,左下角点击`新增`按钮,可以上传文档到知识库。 + +上传后,你可以在知识库详情页面中,看到上传的文档。此时可以点击文档的`解析`按钮,解析文档。 + +解析完成后,你可以查看解析后的切片信息。你可以在知识库详情页面中,点击`召回测试`按钮,可以测试知识库的召回/检索功能。 + +# 第三步 让小智使用ragflow知识库 +登录到智控台。在顶部导航栏中,点击`智能体`,找到你要配置的智能体,点击`配置角色`按钮。 + +在意图识别左侧,点击`编辑功能`按钮,弹出一个弹框。在弹框中选择你要添加的知识库。保存即可。 diff --git a/backend/docs/voiceprint-integration.md b/backend/docs/voiceprint-integration.md new file mode 100644 index 0000000..bd0731e --- /dev/null +++ b/backend/docs/voiceprint-integration.md @@ -0,0 +1,235 @@ +# 声纹识别启用指南 + +本教程包含3个部分 +- 1、如何部署声纹识别这个服务 +- 2、全模块部署时,怎么配置声纹识别接口 +- 3、最简化部署时,怎么配置声纹识别 + +# 1、如何部署声纹识别这个服务 + +## 第一步,下载声纹识别项目源码 + +浏览器打开[声纹识别项目地址](https://github.com/xinnan-tech/voiceprint-api) + +打开完,找到页面中一个绿色的按钮,写着`Code`的按钮,点开它,然后你就看到`Download ZIP`的按钮。 + +点击它,下载本项目源码压缩包。下载到你电脑后,解压它,此时它的名字可能叫`voiceprint-api-main` +你需要把它重命名成`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运行的方法 + +``` +# 进入本项目源码根目录 +cd voiceprint-api + +# 清除缓存 +docker compose -f docker-compose.yml down +docker stop voiceprint-api +docker rm voiceprint-api +docker rmi ghcr.nju.edu.cn/xinnan-tech/voiceprint-api:latest + +# 启动docker容器 +docker compose -f docker-compose.yml up -d +# 查看日志 +docker logs -f voiceprint-api +``` + +此时,日志里会输出类似以下的日志 +``` +250711 INFO-🚀 开始: 生产环境服务启动(Uvicorn),监听地址: 0.0.0.0:8005 +250711 INFO-============================================================ +250711 INFO-声纹接口地址: http://127.0.0.1:8005/voiceprint/health?key=abcd +250711 INFO-============================================================ +``` + +请你把声纹接口地址复制出来: + +由于你是docker部署,切不可直接使用上面的地址! + +由于你是docker部署,切不可直接使用上面的地址! + +由于你是docker部署,切不可直接使用上面的地址! + +你先把地址复制出来,放在一个草稿里,你要知道你的电脑的局域网ip是什么,例如我的电脑局域网ip是`192.168.1.25`,那么 +原来我的接口地址 +``` +http://127.0.0.1:8005/voiceprint/health?key=abcd + +``` +就要改成 +``` +http://192.168.1.25:8005/voiceprint/health?key=abcd +``` + +改好后,请使用浏览器直接访问`声纹接口地址`。当浏览器出现类似这样的代码,说明是成功了。 +``` +{"total_voiceprints":0,"status":"healthy"} +``` + +请你保留好修改后的`声纹接口地址`,下一步要用到。 + +# 2、全模块部署时,怎么配置声纹识别 + +## 第一步 配置接口 +首先,你要开启声纹识别功能。在智控台,点击顶部`参数字典`,在下拉菜单中,点击`系统功能配置`页面。在页面上勾选`声纹识别`,点击`保存配置`。即可在新建智能体的卡片上看到`声纹识别`按钮。 + +如果你是全模块部署,使用管理员账号,登录智控台,点击顶部`参数字典`,选择`参数管理`功能。 + +然后搜索参数`server.voice_print`,此时,它的值应该是`null`值。 +点击修改按钮,把上一步得来的`声纹接口地址`粘贴到`参数值`里。然后保存。 + +如果能保存成功,说明一切顺利,你可以去智能体查看效果了。如果不成功,说明智控台无法访问声纹识别,很大概率是网络防火墙,或者没有填写正确的局域网ip。 + +## 第二步 设置智能体记忆模式 + +进入你的智能体的角色配置里,将记忆设置成`本地短期记忆`,一定要开启`上报文字+语音`。 + +## 第三步 和你的智能体聊天 + +将你的设备通电,然后和他用正常的语速和音调聊天。 + +## 第四步 设置声纹 + +在智控台,`智能体管理`页面,在智能体的面板里,有一个`声纹识别`按钮,点击它。在底部有一个`新增按钮`。就可以对某个人说的话进行声纹注册。 +在弹出的框里,`描述`这个属性建议填写上,可以是这个人的职业、性格、爱好。方便智能体对说话人进行分析和了解。 + +## 第三步 和你的智能体聊天 + +将你的设备通电,问它,你知道我是谁吗?如果他能回答得出,说明声纹识别功能正常。 + +# 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` 填的就是张三说一段话的音频文件。 + + ## 第三步 启动服务 + +启动小智服务器和声纹服务,即可正常使用。 diff --git a/backend/docs/weather-integration.md b/backend/docs/weather-integration.md new file mode 100644 index 0000000..3b6ca2b --- /dev/null +++ b/backend/docs/weather-integration.md @@ -0,0 +1,64 @@ +# 天气插件使用指南 + +## 概述 + +天气插件 `get_weather` 是小智ESP32语音助手的核心功能之一,支持通过语音查询全国各地的天气信息。插件基于和风天气API,提供实时天气和7天天气预报功能。 + +## API Key 申请指南 + +### 1. 注册和风天气账号 + +1. 访问 [和风天气控制台](https://console.qweather.com/) +2. 注册账号并完成邮箱验证 +3. 登录控制台 + +### 2. 创建应用获取API Key + +1. 进入控制台后,点击右侧["项目管理"](https://console.qweather.com/project?lang=zh) → "创建项目" +2. 填写项目信息: + - **项目名称**:如"小智语音助手" +3. 点击保存 +4. 项目创建完成后,在该项目中点击"创建凭据" +5. 填写凭据信息: + - **凭据名称**:如"小智语音助手" + - **身份认证方式**:选择"API Key" +6. 点击保存 +7. 在凭据中复制`API Key`,这是第一个关键的配置信息 + +### 3. 获取API Host + +1. 在控制台中点击["设置"](https://console.qweather.com/setting?lang=zh) → "API Host" +2. 查看分配给你的专属`API Host`地址,这个是第二个关键的配置信息 + +以上操作,会得到两个重要的配置信息:`API Key`和`API Host` + +## 配置方式(任选一种) + +### 方式1. 如果你使用了智控台部署(推荐) + +1. 登录智控台 +2. 进入"角色配置"页面 +3. 选择要配置的智能体 +4. 点击"编辑功能"按钮 +5. 在右侧参数配置区域找到"天气查询"插件 +6. 勾选"天气查询" +7. 将复制过来的第一个关键配置`API Key`,填入到`天气插件 API 密钥`里 +8. 将复制过来的第二个关键配置`API Host`,填入到`开发者 API Host`里 +9. 保存配置,再保存智能体配置 + +### 方式2. 如果你只是单模块xiaozhi-server部署 + +在 `data/.config.yaml` 中配置: + +1. 将复制过来的第一个关键配置`API Key`,填入到`api_key`里 +2. 将复制过来的第二个关键配置`API Host`,填入到`api_host`里 +3. 将你所在的城市填入到`default_location`里,例如`广州` + +```yaml +plugins: + get_weather: + api_key: "你的和风天气API密钥" + api_host: "你的和风天气API主机地址" + default_location: "你的默认查询城市" +``` + diff --git a/backend/main/README.md b/backend/main/README.md new file mode 100644 index 0000000..962b788 --- /dev/null +++ b/backend/main/README.md @@ -0,0 +1,541 @@ +# 技术文档:`xiaozhi-esp32-server` + +**目录:** + +1. [引言](#1-引言) +2. [整体架构](#2-整体架构) +3. [核心组件深度剖析](#3-核心组件深度剖析) + * [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.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-数据流与交互机制) +5. [核心功能概要](#5-核心功能概要) +6. [部署与配置概述](#6-部署与配置概述) +--- + +## 1. 引言 + +`xiaozhi-esp32-server` 项目是一个专为基于ESP32的智能硬件提供支持的**综合性后端系统**。其核心目标是使开发人员能够快速构建一个强大的服务器基础设施,该设施不仅能够理解自然语言指令,还能与多种AI服务(用于语音识别、自然语言理解及语音合成)进行高效交互、管理物联网(IoT)设备,并提供一个基于Web的用户界面以进行系统配置和管理。通过将多种尖端技术整合到一个高内聚且可扩展的平台中,本项目旨在简化和加速可定制化语音助手及智能控制系统的开发进程。它不仅仅是一个简单的服务器,更是一个连接硬件、AI能力与用户管理的桥梁。 + +--- + +## 2. 整体架构 + +`xiaozhi-esp32-server` 系统采用了一种**分布式、多组件协作**的架构设计,确保了系统的模块化、可维护性和可扩展性。各个核心组件各司其职,协同工作。主要组件包括: + +1. **ESP32 硬件 (客户端设备):** + 这是终端用户直接与之交互的物理智能硬件设备。其主要职责包括: + * 捕捉用户的语音指令。 + * 将捕捉到的原始音频数据安全地发送至 `xiaozhi-server` 进行处理。 + * 接收来自 `xiaozhi-server` 合成的语音回复,并通过扬声器播放给用户。 + * 根据从 `xiaozhi-server` 收到的指令,控制与之连接的其他外围设备或IoT设备(例如智能灯泡、传感器等)。 + +2. **`xiaozhi-server` (核心AI引擎 - Python实现):** + 这个基于Python的服务器是整个系统的“大脑”,负责处理所有语音相关的逻辑和AI交互。其关键职责细化如下: + * 通过WebSocket协议与ESP32设备建立**稳定、低延迟的实时双向通信链路**。 + * 接收来自ESP32的音频流,并利用语音活动检测(VAD)技术精确切分有效的语音片段。 + * 集成并调用自动语音识别(ASR)服务(可配置本地或云端),将语音片段转换为文本。 + * 通过与大型语言模型(LLM)的交互来解析用户意图、生成智能回复,并支持复杂的自然语言理解任务。 + * 管理多轮对话中的上下文信息和用户记忆,以提供连贯的交互体验。 + * 调用文本转语音(TTS)服务,将LLM生成的文本回复合成为自然流畅的语音。 + * 通过一个灵活的**插件系统**执行自定义命令,包括对IoT设备的控制逻辑。 + * 从 `manager-api` 服务获取其详细的运行时操作配置。 + +3. **`manager-api` (管理后端 - Java实现):** + 这是一个基于Java Spring Boot框架构建的应用程序,它为整个系统的管理和配置提供了一套安全的RESTful API。它不仅是 `manager-web` 控制台的后端支撑,也是 `xiaozhi-server` 的配置数据来源。其核心功能包括: + * 为Web控制台提供用户认证(登录、权限验证)和用户账户管理功能。 + * ESP32设备的注册、信息管理以及设备特定配置的维护。 + * 在**MySQL数据库**中持久化存储系统配置,例如用户选择的AI服务提供商、API密钥、设备参数、插件设置等。 + * 提供特定的API端点,供 `xiaozhi-server` 拉取其所需的最新配置。 + * 管理TTS音色选项、处理OTA(Over-The-Air)固件更新流程及相关元数据。 + * 利用 **Redis** 作为高速缓存,存储热点数据(如会话信息、频繁访问的配置),以提升API响应速度和系统整体性能。 + +4. **`manager-web` (Web控制面板 - Vue.js实现):** + 这是一个基于Vue.js构建的单页应用(SPA),为系统管理员提供了一个图形化、用户友好的操作界面。其主要能力包括: + * 便捷地配置 `xiaozhi-server` 所使用的各项AI服务(如ASR、LLM、TTS的提供商切换、参数调整)。 + * 管理平台用户账户、角色分配及权限控制。 + * 管理已注册的ESP32设备及其相关设置。 + * (潜在功能)监控系统运行状态、查看日志、进行故障排查等。 + * 与 `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设备进行播放。所有与语音直接相关的实时交互均在此链路完成。 +* **管理配置主线:** 管理员通过浏览器访问**`manager-web`**控制台。`manager-web`通过调用**`manager-api`**提供的**RESTful HTTP接口**来执行各种管理操作(如修改配置、管理用户或设备)。数据以JSON格式在两者间传递。 +* **配置同步:** **`xiaozhi-server`**在启动或特定更新机制触发时,会主动通过HTTP请求从**`manager-api`**拉取其最新的操作配置。这确保了管理员在Web界面上所做的配置更改能够及时有效地应用到核心AI引擎的运行中。 + +这种**前后端分离、核心服务与管理服务分离**的架构设计,使得 `xiaozhi-server`能够专注于高效的实时AI处理任务,而 `manager-api` 和 `manager-web` 则共同提供了一个功能强大且易于使用的管理和配置平台。各组件职责清晰,有利于独立开发、测试、部署和扩展。 + +``` +xiaozhi-esp32-server + ├─ xiaozhi-server 8000 端口 Python语言开发 负责与esp32通信 + ├─ manager-web 8001 端口 Node.js+Vue开发 负责提供控制台的web界面 + ├─ manager-api 8002 端口 Java语言开发 负责提供控制台的api + └─ manager-mobile 跨平台移动应用 uni-app+Vue3开发 负责提供移动版智控台管理 +``` + +--- + +## 3. 核心组件深度剖析 + +### 3.1. `xiaozhi-server` (核心AI引擎 - Python实现) + +`xiaozhi-server` 作为系统的智能核心,全权负责处理语音交互、对接各类AI服务以及管理与ESP32设备间的通信。其设计目标是实现高效、灵活且可扩展的语音AI处理能力。 + +* **核心目标:** + * 为ESP32设备提供实时的语音指令处理服务。 + * 深度集成各类AI服务,包括:自动语音识别 (ASR)、大型语言模型 (LLM) 进行自然语言理解 (NLU)、文本转语音 (TTS)、语音活动检测 (VAD)、意图识别 (Intent Recognition) 及对话记忆 (Memory)。 + * 精细管理用户与设备间的对话流程及上下文状态。 + * 基于用户指令,通过插件化机制执行自定义函数及控制物联网 (IoT) 设备。 + * 支持通过 `manager-api`进行动态配置加载与更新。 + +* **核心技术栈:** + * **Python 3:** 作为主要编程语言,Python以其丰富的AI/ML生态库和快速开发特性被选用。 + * **Asyncio:** Python的异步编程框架,是`xiaozhi-server`高性能的关键。它被广泛用于高效处理来自大量ESP32设备的并发WebSocket连接,以及执行与外部AI服务API通信时的非阻塞I/O操作,确保服务器在高并发下的响应能力。 + * **`websockets` 库:** 提供WebSocket服务器的具体实现,支持与ESP32客户端进行全双工实时通信。 + * **HTTP客户端 (如 `aiohttp`, `httpx`):** 用于异步执行HTTP请求,主要目的是从`manager-api`获取配置信息,以及与云端AI服务的API进行交互。 + * **YAML (通常通过 PyYAML 库):** 用于解析本地的 `config.yaml` 配置文件。 + * **FFmpeg (外部依赖):** 在 `app.py` 启动时会进行检查 (`check_ffmpeg_installed()`)。FFmpeg通常用于音频处理和格式转换,例如,确保音频数据符合特定AI服务的要求或进行内部处理。 + +* **关键实现细节:** + + 1. **AI服务提供者模式 (Provider Pattern - `core/providers/`):** + * **设计思想:** 这是`xiaozhi-server`集成不同AI服务的核心设计模式,极大地增强了系统的灵活性和可扩展性。针对每一种AI服务类型(ASR, TTS, LLM, VAD, Intent, Memory, VLLM),都在其对应子目录下定义了一个抽象基类 (ABC, Abstract Base Class),例如 `core/providers/asr/base.py`。这个基类规定了该类型服务必须实现的通用接口方法(如ASR的 `async def transcribe(self, audio_chunk: bytes) -> str: pass`)。 + * **具体实现:** 各种具体的AI服务提供商或本地模型的实现,则以独立的Python类形式存在(例如 `core/providers/asr/fun_local.py` 实现了本地FunASR的逻辑,`core/providers/llm/openai.py` 实现了与OpenAI GPT模型的对接)。这些具体类继承自相应的抽象基类,并实现其定义的接口。部分提供者还使用DTOs (Data Transfer Objects, 存在于各自的 `dto/` 目录) 来结构化与外部服务交换的数据。 + * **优势:** 使得核心业务逻辑能够以统一的方式调用不同的AI服务,而无需关心其底层具体实现。用户可以通过配置文件轻松切换AI服务后端。添加对新AI服务的支持也变得相对简单,只需实现对应的Provider接口。 + * **动态加载与初始化:** `core/utils/modules_initialize.py` 脚本扮演了工厂的角色。它在服务器启动时,或在接收到配置更新指令时,会根据配置文件中 `selected_module` 及各项服务的具体provider设置,动态地导入并实例化相应的Provider类。 + + 2. **WebSocket通信与连接处理 (`app.py`, `core/websocket_server.py`, `core/connection.py`):** + * **服务器启动与入口 (`app.py`):** + * `app.py` 作为主入口,负责初始化应用环境(如检查FFmpeg、加载配置、设置日志)。 + * 它会生成或加载一个 `auth_key` (JWT密钥),用于保护特定的HTTP接口(如视觉分析接口 `/mcp/vision/explain`)。若配置中 `manager-api.secret` 为空,则会生成一个UUID作为 `auth_key`。 + * 使用 `asyncio.create_task()` 并发启动 `WebSocketServer` (监听如 `ws://0.0.0.0:8000/xiaozhi/v1/`) 和 `SimpleHttpServer` (监听如 `http://0.0.0.0:8003/xiaozhi/ota/`)。 + * 包含一个 `monitor_stdin()` 协程,用于在某些环境下保持应用存活或处理终端输入。 + * **WebSocket服务器核心 (`core/websocket_server.py`):** + * `WebSocketServer` 类使用 `websockets` 库监听来自ESP32设备的连接请求。 + * 对于每一个成功的WebSocket连接,它都会创建一个**独立的 `ConnectionHandler` 实例** (推测定义于 `core/connection.py`)。这种每个连接一个处理程序实例的设计模式,是实现多设备状态隔离和并发处理的关键,确保每个设备的对话流程和上下文信息互不干扰。 + * 该服务器还提供一个 `_http_response` 方法,允许在同一端口上对非WebSocket升级的HTTP GET请求做出简单响应(例如返回 "Server is running"),便于进行健康检查。 + * **动态配置更新:** `WebSocketServer` 包含一个 `update_config()` 异步方法。此方法使用 `config_lock` (一个 `asyncio.Lock`) 保证配置更新的原子性。它调用 `get_config_from_api()` (可能在 `config_loader.py` 中实现,通过 `manage_api_client.py` 与 `manager-api` 通信) 来获取新的配置。通过 `check_vad_update()` 和 `check_asr_update()` 等辅助函数判断是否需要重新初始化特定的AI模块,避免不必要的开销。更新后的配置会用于重新调用 `initialize_modules()`,从而实现AI服务提供者的热切换。 + + 3. **消息处理与对话流程控制 (`core/handle/` 和 `ConnectionHandler`):** + * `ConnectionHandler` (推测) 作为每个连接的控制中心,负责接收来自ESP32的消息,并根据消息类型或当前对话状态,将其分发给 `core/handle/` 目录下的相应处理模块。这种模块化的处理器设计使得 `ConnectionHandler` 逻辑更清晰,易于扩展。 + * **主要处理模块及其职责:** + * `helloHandle.py`: 处理与ESP32初次连接时的握手协议、设备认证或初始化信息交换。 + * `receiveAudioHandle.py`: 接收音频流数据,调用VAD Provider进行语音活动检测,并将有效的音频片段传递给ASR Provider进行识别。 + * `textHandle.py` / `intentHandler.py`: 获取ASR识别出的文本后,与Intent Provider (可能利用LLM进行意图识别) 和LLM Provider交互,以理解用户意图并生成初步回复或决策。 + * `functionHandler.py`: 当LLM的响应包含执行特定“函数调用”的指令时,此模块负责从插件注册表中查找并执行对应的插件函数。 + * `sendAudioHandle.py`: 将LLM最终生成的文本回复交给TTS Provider合成语音,并将音频流通过WebSocket发送回ESP32。 + * `abortHandle.py`: 处理来自ESP32的中断请求,例如停止当前的TTS播报。 + * `iotHandle.py`, `mcpHandle.py`: 处理与IoT设备控制相关的特定指令或更复杂的模块通信协议 (MCP)。 + + 4. **插件化功能扩展系统 (`plugins_func/`):** + * **设计目的:** 提供一种标准化的方式来扩展语音助手的功能和“技能”,而无需修改核心代码。 + * **实现机制:** + * 各个具体功能以独立的Python脚本形式存在于 `plugins_func/functions/` 目录中(例如 `get_weather.py`, `hass_set_state.py` 用于Home Assistant集成)。 + * `loadplugins.py` 在服务器启动时负责扫描并加载这些插件模块。 + * `register.py` (或插件模块内部的特定装饰器/函数) 可能用于定义每个插件函数的元数据,包括: + * **函数名称 (Function Name):** LLM调用时使用的标识符。 + * **功能描述 (Description):** 供LLM理解此函数的作用。 + * **参数模式 (Parameters Schema):** 通常是一个JSON Schema,详细定义了函数所需的参数、类型、是否必需以及描述。这是LLM能够正确生成函数调用参数的关键。 + * **执行流程:** 当LLM在其思考过程中决定需要调用某个外部工具或函数来获取信息或执行操作时,它会依据预先提供的函数模式生成一个结构化的“函数调用”请求。`xiaozhi-server`中的`functionHandler.py`捕获此请求,从插件注册表中找到对应的Python函数并执行,然后将执行结果返回给LLM,LLM再基于此结果生成最终给用户的自然语言回复。 + + 5. **配置管理 (`config/`):** + * **加载机制:** `config_loader.py` (通过 `settings.py` 被调用) 负责从根目录的 `config.yaml` 文件加载基础配置。 + * **远程配置与合并:** 通过 `manage_api_client.py` (使用如`aiohttp`的库与`manager-api`通信) 可以从`manager-api`服务拉取配置。远程配置通常会覆盖本地 `config.yaml` 中的同名设置,从而实现通过Web界面动态调整服务器行为。 + * **日志系统:** `logger.py` 初始化应用日志系统(可能使用 `loguru` 或对标准 `logging` 模块进行封装,支持通过 `logger.bind(tag=TAG)` 添加标签,便于追踪和过滤)。 + * **静态资源:** `config/assets/` 目录下存放了用于系统提示音的静态音频文件(如设备绑定提示音 `bind_code.wav`、错误提示音等)。 + + 6. **辅助HTTP服务 (`core/http_server.py`):** + * 与WebSocket服务并行运行一个简单的HTTP服务器,用于处理特定的HTTP请求。最主要的功能是为ESP32设备提供OTA (Over-The-Air) 固件更新的下载服务 (通过 `/xiaozhi/ota/` 端点)。此外,也可能承载其他如 `/mcp/vision/explain` (视觉分析) 等工具性HTTP接口。 + +综上所述,`xiaozhi-server` 是一个采用现代Python异步编程模型构建的、高度模块化、配置驱动的AI应用服务器。其精心设计的Provider模式和插件架构赋予了它强大的适应性和扩展性,能够灵活接入不同的AI能力并支持日益增长的功能需求。 + +--- + +### 3.2. `manager-api` (管理后端 - Java Spring Boot实现) + +`manager-api` 组件是使用Java和Spring Boot框架构建的强大后端服务,作为整个`xiaozhi-esp32-server`生态系统的中央行政管理和配置中枢。 + +* **核心目标:** + * 为`manager-web`(Vue.js前端)提供一套安全、稳定、符合RESTful规范的API接口,使得管理员能够便捷地管理用户、设备、系统配置及其他相关资源。 + * 充当`xiaozhi-server`(Python核心AI引擎)的集中化配置数据提供者,允许`xiaozhi-server`实例在启动或运行时获取其最新的操作参数。 + * 持久化存储关键数据,例如:用户账户信息、设备注册详情、AI服务提供商配置(包括API密钥、选定的服务模型等)、TTS音色参数,以及OTA固件版本信息等。 + +* **核心技术栈:** + * **Java 21:** 项目采用的JDK版本,确保了对现代Java特性的支持。 + * **Spring Boot 3:** 作为核心开发框架,极大地简化了独立、生产级别的Spring应用的创建和部署。它提供了自动配置、内嵌Web服务器(默认为Tomcat)、依赖管理等关键功能。 + * **Spring MVC:** Spring框架中用于构建Web应用和RESTful API的模块。 + * **MyBatis-Plus:** 一个对MyBatis进行功能增强的ORM(对象关系映射)框架。它简化了数据库操作,提供了强大的CRUD(增删改查)功能、条件构造器、代码生成器等,并能很好地与Spring Boot集成。 + * **MySQL:** 作为主要的后端关系型数据库,用于存储所有需要持久化的管理数据和配置信息。 + * **Druid (Alibaba Druid):** 一个功能强大的JDBC连接池实现,提供了丰富的监控功能和优秀的性能,用于高效管理数据库连接。 + * **Redis (通过 Spring Data Redis):** 一个高性能的内存数据结构存储,常用于实现数据缓存(例如缓存热点配置数据、用户会话信息),以显著提升API的响应速度。 + * **Apache Shiro:** 一个成熟且易用的Java安全框架,负责处理应用的认证(用户身份验证)和授权(API访问权限控制)需求。 + * **Liquibase:** 一个用于跟踪、管理和应用数据库 schéma(模式)变更的开源工具。它允许开发者以数据库无关的方式定义和版本化数据库结构变更。 + * **Knife4j:** 一个集成了Swagger并增强了UI的API文档生成工具,专为Java MVC框架(尤其是Spring Boot)设计。它能生成美观且易于交互的API文档界面(通常通过 `/xiaozhi/doc.html` 访问)。 + * **Maven:** 用于项目的构建自动化和依赖项管理。 + * **Lombok:** 一个Java库,通过注解自动生成构造函数、getter/setter、equals/hashCode、toString等样板代码,减少冗余。 + * **HuTool / Google Guava:** 提供大量实用工具类,简化常见编程任务。 + * **Aliyun Dysmsapi:** 阿里云短信服务SDK,用于集成发送短信功能(如验证码、通知)。 + +* **关键实现细节:** + + 1. **模块化项目结构 (`modules/` 包):** + * `manager-api` 的核心业务逻辑被清晰地划分到 `src/main/java/xiaozhi/modules/` 目录下的不同模块中。这种按功能领域划分模块的方式(例如 `sys` 负责系统管理,`agent` 负责智能体配置,`device` 负责设备管理,`config` 负责为`xiaozhi-server`提供配置,`security` 负责安全,`timbre` 负责音色管理,`ota` 负责固件升级)极大地提高了代码的可维护性和可扩展性。 + * **各模块内部结构:** 每个业务模块通常遵循经典的三层架构或其变体: + * **Controller (控制层):** 位于 `xiaozhi.modules.[模块名].controller`。 + * **Service (服务层):** 位于 `xiaozhi.modules.[模块名].service`。 + * **DAO/Mapper (数据访问层):** 位于 `xiaozhi.modules.[模块名].dao`。 + * **Entity (实体类):** 位于 `xiaozhi.modules.[模块名].entity`。 + * **DTO (数据传输对象):** 位于 `xiaozhi.modules.[模块名].dto`。 + + 2. **分层架构实现:** + * **Controller层 (`@RestController`):** 这些类使用Spring MVC注解(如 `@GetMapping`, `@PostMapping` 等)来定义API的端点(endpoints)。它们负责接收HTTP请求,将请求体中的JSON数据反序列化为DTO对象,调用相应的Service层方法处理业务逻辑,最后将Service层的返回结果序列化为JSON并作为HTTP响应返回给客户端。 + * **Service层 (`@Service`):** 这些类(通常是接口及其实现类的组合)封装了核心的业务规则和操作流程。它们可能会调用一个或多个DAO/Mapper对象来与数据库交互,并常常使用 `@Transactional` 注解来管理数据库事务的原子性。 + * **Data Access (DAO/Mapper) 层 (MyBatis-Plus Mappers):** 这些是Java接口,继承自MyBatis-Plus提供的 `BaseMapper` 接口。MyBatis-Plus会为这些接口自动提供标准的CRUD方法。对于更复杂的数据库查询,开发者可以通过在Mapper接口中定义方法并使用注解(如 `@Select`, `@Update`)或编写对应的XML映射文件来实现。例如,`UserMapper.selectById(userId)` 会被MyBatis-Plus自动实现。 + * **Entity层 (`@TableName`, `@TableId` 等MyBatis-Plus注解):** 这些POJO(Plain Old Java Objects)类直接映射到数据库中的表结构。Lombok的 `@Data` 注解常用于自动生成getter/setter等。 + * **DTO层:** 用于在各层之间,特别是Controller层与Service层之间,以及API的请求/响应体中传递数据。使用DTO有助于解耦API接口的数据结构与数据库实体的数据结构,使API更稳定。 + + 3. **通用功能与配置 (`common/` 包):** + * `src/main/java/xiaozhi/common/` 包提供了一系列跨模块共享的通用组件和配置: + * **基类:** 如 `BaseDao`, `BaseEntity`, `BaseService`, `CrudService`,为各模块的相应组件提供通用的属性或方法。 + * **全局配置:** 包括 `MybatisPlusConfig` (MyBatis-Plus的配置,如分页插件、数据权限插件等)、`RedisConfig` (Redis连接及序列化配置)、`SwaggerConfig` (Knife4j的配置)、`AsyncConfig` (异步任务执行器配置)。 + * **自定义注解:** 例如 `@LogOperation` 用于通过AOP记录操作日志,`@DataFilter` 可能用于实现数据范围过滤。 + * **AOP切面:** 如 `RedisAspect` 可能用于实现方法级别的缓存逻辑。 + * **全局异常处理:** `RenExceptionHandler` (使用 `@ControllerAdvice` 注解) 捕获应用中抛出的特定或所有异常 (如自定义的 `RenException`),并返回统一格式的JSON错误响应给客户端。`ErrorCode` 定义了标准化的错误码。 + * **工具类:** 提供了日期转换、JSON处理(Jackson)、IP地址获取、HTTP上下文操作、统一结果封装 (`Result` 类)等多种实用工具。 + * **校验工具:** `ValidatorUtils` 和 `AssertUtils` 用于简化参数校验逻辑。 + * **XSS防护:** `XssFilter` 等组件用于防止跨站脚本攻击。 + * **MyBatis-Plus自动填充:** `FieldMetaObjectHandler` 用于在执行插入或更新数据库操作时,自动填充如 `createTime`, `updateTime` 等公共字段。 + + 4. **安全机制 (Apache Shiro):** + * Shiro的配置(通常在 `modules/security/config/` 或 `common/config/` 下)定义了如何进行用户认证和授权。 + * **Realms (域):** 自定义的Shiro Realm类负责从数据库中查询用户信息(用户名、密码、盐值)进行身份验证,以及获取用户的角色和权限信息用于授权决策。 + * **Filters (过滤器):** Shiro过滤器链被应用于保护API端点,确保只有经过认证且拥有足够权限的用户才能访问特定资源。 + * **Session/Token Management:** Shiro管理用户会话。对于RESTful API,可能结合OAuth2或JWT等令牌机制实现无状态认证。 + + 5. **数据库版本控制 (Liquibase):** + * 数据库的表结构、索引、初始数据等变更,都通过Liquibase的 `changelog` 文件(通常是XML格式)进行定义和版本化管理。当应用启动时,Liquibase会自动检查并应用必要的数据库结构更新,确保开发、测试和生产环境数据库结构的一致性。 + + 6. **API文档:** + * 完整的API接口文档可通过以下地址访问: https://2662r3426b.vicp.fun/xiaozhi/doc.html + * 该文档使用Knife4j生成,提供了所有RESTful API端点的详细说明、请求/响应示例以及在线测试功能。 + +`manager-api` 通过这些精心选择的技术和设计模式,构建了一个功能全面、结构清晰、安全可靠且易于维护和扩展的Java后端服务。其模块化的设计特别适合处理具有多种管理功能需求的复杂系统。 + +--- + +### 3.3. `manager-web` (Web管理前端 - Vue.js实现) + +`manager-web` 组件是一个采用 Vue.js 2 框架构建的单页应用 (SPA - Single Page Application)。它为系统管理员提供了一个功能丰富、交互友好的图形用户界面,用于全面管理和配置 `xiaozhi-esp32-server` 生态系统。 + +* **核心目标:** + * 提供一个基于Web的集中式控制面板,供管理员进行系统操作与监控。 + * 实现对 `xiaozhi-server` 中AI服务提供商(ASR、LLM、TTS等)及其相关API密钥或许可配置的便捷管理。 + * 支持用户账户、角色及权限的精细化管理。 + * 提供ESP32设备的注册、配置及状态查看功能。 + * 允许管理员自定义TTS音色、管理OTA固件更新流程、调整系统级参数及字典数据等。 + * 作为 `manager-api` 所暴露各项功能的图形化交互前端。 + +* **核心技术栈:** + * **Vue.js 2:** 一个渐进式的JavaScript框架,用于构建用户界面。其核心特性包括声明式渲染、组件化系统、数据绑定等,非常适合构建复杂的SPA。 + * **Vue CLI (`@vue/cli-service`):** Vue.js的官方命令行工具,用于项目的快速搭建、开发服务器的运行(支持热模块替换HMR)、以及生产环境构建打包(内部集成并配置了Webpack)。 + * **Vue Router (`vue-router`):** Vue.js官方的路由管理器。它负责在SPA内部实现不同“页面”或视图组件之间的导航切换,而无需重新加载整个HTML页面,提供了流畅的用户体验。 + * **Vuex (`vuex`):** Vue.js官方的状态管理模式和库。它充当了应用中所有组件的“中央数据存储”,用于管理全局共享状态(例如当前登录用户信息、设备列表、应用配置等),特别适用于大型复杂应用。 + * **Element UI (`element-ui`):** 一个广受欢迎的基于Vue 2.0的桌面端UI组件库。它提供了大量预先设计和实现的组件(如表单、表格、对话框、导航菜单、按钮、提示等),帮助开发者快速构建出专业且一致的用户界面。 + * **JavaScript (ES6+):** 前端逻辑实现的主要编程语言,利用其现代特性进行开发。 + * **SCSS (Sassy CSS):** 一种CSS预处理器,它为CSS增加了变量、嵌套规则、混合(Mixin)、继承等高级特性,使得CSS代码更易于组织、维护和复用。 + * **HTTP客户端 (Flyio 或 Axios 通过 `vue-axios`):** 用于在浏览器端向 `manager-api` 后端发起异步HTTP(AJAX)请求,以获取数据或提交操作。 + * **Webpack:** 一个强大的模块打包工具(由Vue CLI在底层管理和配置)。它将项目中的各种资源(JavaScript文件、CSS、图片、字体等)视为模块,并将它们打包成浏览器可识别的静态文件。 + * **Workbox (通过 `workbox-webpack-plugin`):** Google开发的一个库,用于简化Service Worker的编写和PWA(Progressive Web App - 渐进式Web应用)的实现。它可以帮助生成Service Worker脚本,实现资源缓存、离线访问等功能。 + * **Opus库 (`opus-decoder`, `opus-recorder`):** 这些音频处理库表明前端可能具备一些直接在浏览器中处理Opus格式音频的能力,例如:用于测试麦克风输入、允许管理员录制自定义音频片段(可能用于TTS音色样本或语音指令测试),或播放在管理界面中预览的Opus编码音频。 + +* **关键实现细节:** + + 1. **单页应用 (SPA) 结构:** + * 整个前端应用加载一个主HTML文件 (`public/index.html`)。后续的所有页面切换和内容更新都在客户端由Vue Router动态完成,无需每次都从服务器请求新的HTML页面。这种模式能提供更快的页面加载速度和更流畅的交互体验。 + + 2. **组件化架构 (Component-Based Architecture):** + * 用户界面由一系列可复用的Vue组件 (`.vue` 单文件组件) 构成,形成一个组件树。这种方式提高了代码的模块化程度、可维护性和复用性。 + * **`src/main.js`:** 应用的入口JS文件。它负责创建和初始化根Vue实例,注册全局插件(如Vue Router, Vuex, Element UI),并把根Vue实例挂载到 `public/index.html` 中的某个DOM元素上(通常是 `#app`)。 + * **`src/App.vue`:** 应用的根组件。它通常定义了应用的基础布局结构(如包含导航栏、侧边栏、主内容区),并通过 `` 标签来显示当前路由匹配到的视图组件。 + * **视图组件 (`src/views/`):** 这些组件代表了应用中的各个“页面”或主要功能区(例如 `Login.vue` 登录页, `DeviceManagement.vue` 设备管理页, `UserManagement.vue` 用户管理页, `ModelConfig.vue` 模型配置页)。它们通常由Vue Router直接映射。 + * **可复用UI组件 (`src/components/`):** 包含了在不同视图之间共享的、更小粒度的UI组件(例如 `HeaderBar.vue` 顶部导航栏, `AddDeviceDialog.vue` 添加设备对话框, `AudioPlayer.vue` 音频播放器组件)。 + + 3. **客户端路由 (`src/router/index.js`):** + * Vue Router在此文件中进行配置,定义了应用的路由表。每个路由规则将一个特定的URL路径映射到一个视图组件。 + * 常常包含**导航守卫 (Navigation Guards)**,例如 `beforeEach` 守卫,用于在路由跳转前执行逻辑,如检查用户是否已登录,如果未登录则重定向到登录页面,从而保护需要认证才能访问的页面。 + + 4. **状态管理 (`src/store/index.js`):** + * Vuex被用来构建一个集中的状态管理中心(Store)。这个Store包含了: + * **State:** 存储应用级别的共享数据(例如,当前登录用户的详细信息、从API获取的设备列表、系统配置等)。 + * **Getters:** 类似于Vue组件中的计算属性,用于从State派生出一些状态值,方便组件使用。 + * **Mutations:** **唯一**可以同步修改State中数据的方法。它们必须是同步函数。 + * **Actions:** 用于处理异步操作(如API调用)或封装多个Mutation提交。Actions会调用API,获取数据后,通过 `commit` 一个或多个Mutation来更新State。 + * 例如,用户登录时,一个名为 `login` 的Action可能会被调用,它会向后端API发送登录请求,成功后获取到用户信息和token,然后 `commit` 一个名为 `SET_USER_INFO` 的Mutation来更新State中的用户信息和token。 + + 5. **API通信 (`src/apis/`):** + * 与 `manager-api` 后端的所有HTTP通信逻辑被封装在 `src/apis/` 目录下,通常会按照后端API的模块进行组织(例如 `src/apis/module/agent.js`, `src/apis/module/device.js`)。 + * 每个模块导出一系列函数,每个函数对应一个具体的API请求。这些函数内部使用配置好的HTTP客户端实例 (例如,在 `src/apis/api.js` 或 `src/apis/httpRequest.js` 中统一配置Axios或Flyio实例,可能包含设置请求基地址、请求/响应拦截器等)。 + * **拦截器 (Interceptors):** HTTP客户端的请求拦截器常用于在每个请求发送前自动添加认证令牌(如JWT);响应拦截器则可用于全局处理API错误(如权限不足、服务器错误)或对响应数据进行预处理。 + + 6. **样式与资源 (`src/styles/`, `src/assets/`):** + * `Element UI` 提供了基础的组件样式。 + * `src/styles/global.scss` 文件用于定义全局共享的SCSS样式、变量、混合(Mixin)等。 + * Vue单文件组件内部的 ` diff --git a/backend/main/manager-mobile/src/api/agent/agent.ts b/backend/main/manager-mobile/src/api/agent/agent.ts new file mode 100644 index 0000000..32b72ad --- /dev/null +++ b/backend/main/manager-mobile/src/api/agent/agent.ts @@ -0,0 +1,222 @@ +import type { + Agent, + AgentCreateData, + AgentDetail, + ModelOption, + RoleTemplate, +} from './types' +import { http } from '@/http/request/alova' + +// 获取智能体详情 +export function getAgentDetail(id: string) { + return http.Get(`/agent/${id}`, { + meta: { + ignoreAuth: false, + toast: false, + }, + cacheFor: { + expire: 0, + }, + }) +} + +// 获取角色模板列表 +export function getRoleTemplates() { + return http.Get('/agent/template', { + meta: { + ignoreAuth: false, + toast: false, + }, + cacheFor: { + expire: 0, + }, + }) +} + +// 获取模型选项 +export function getModelOptions(modelType: string, modelName: string = '') { + return http.Get('/models/names', { + params: { + modelType, + modelName, + }, + meta: { + ignoreAuth: false, + toast: false, + }, + cacheFor: { + expire: 0, + }, + }) +} + +// 获取智能体列表 +export function getAgentList() { + return http.Get('/agent/list', { + meta: { + ignoreAuth: false, + toast: false, + }, + cacheFor: { + expire: 0, + }, + }) +} + +// 创建智能体 +export function createAgent(data: AgentCreateData) { + return http.Post('/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) { + return http.Put(`/agent/${id}`, data, { + meta: { + ignoreAuth: false, + toast: true, + }, + cacheFor: { + expire: 0, + }, + }) +} + +// 获取插件列表 +export function getPluginFunctions() { + return http.Get(`/models/provider/plugin/names`, { + meta: { + ignoreAuth: false, + toast: false, + }, + cacheFor: { + expire: 0, + }, + }) +} + +// 获取mcp接入点 +export function getMcpAddress(agentId: string) { + return http.Get(`/agent/mcp/address/${agentId}`, { + meta: { + ignoreAuth: false, + toast: false, + isExposeError: true, + }, + }) +} + +// 获取mcp工具 +export function getMcpTools(agentId: string) { + return http.Get(`/agent/mcp/tools/${agentId}`, { + meta: { + ignoreAuth: false, + toast: false, + }, + cacheFor: { + expire: 0, + }, + }) +} + +// 获取声纹列表 +export function getVoicePrintList(agentId: string) { + return http.Get(`/agent/voice-print/list/${agentId}`, { + meta: { + ignoreAuth: false, + toast: false, + }, + cacheFor: { + expire: 0, + }, + }) +} + +// 获取语音对话记录 +export function getChatHistoryUser(agentId: string) { + return http.Get(`/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, + }, + }) +} + +// 获取智能体标签 +export function getAgentTags(agentId: string) { + return http.Get(`/agent/${agentId}/tags`, { + meta: { + ignoreAuth: false, + toast: false, + }, + cacheFor: { + expire: 0, + }, + }) +} + +// 更新智能体标签 +export function updateAgentTags(agentId: string, data) { + return http.Put(`/agent/${agentId}/tags`, data, { + meta: { + ignoreAuth: false, + isExposeError: true, + }, + }) +} + +// 获取所有语言 +export function getAllLanguage(modelId: string) { + return http.Get<{ id: string, name: string, languages: string }[]>(`/models/${modelId}/voices`, { + meta: { + ignoreAuth: false, + toast: false, + }, + cacheFor: { + expire: 0, + }, + }) +} diff --git a/backend/main/manager-mobile/src/api/agent/types.ts b/backend/main/manager-mobile/src/api/agent/types.ts new file mode 100644 index 0000000..2c61c80 --- /dev/null +++ b/backend/main/manager-mobile/src/api/agent/types.ts @@ -0,0 +1,121 @@ +// 智能体列表数据类型 +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 + tags: Record[] +} + +// 智能体创建数据类型 +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 + ttsLanguage: string + ttsVolume: number + ttsRate: number + ttsPitch: number + functions: AgentFunction[] + contextProviders: Providers[] +} + +export interface Providers { + url: string + headers: Array<{ + key: string + value: string + }> +} + +export interface AgentFunction { + id?: string + agentId?: string + pluginId: string + paramInfo: Record | 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 +} diff --git a/backend/main/manager-mobile/src/api/auth.ts b/backend/main/manager-mobile/src/api/auth.ts new file mode 100644 index 0000000..f9750a0 --- /dev/null +++ b/backend/main/manager-mobile/src/api/auth.ts @@ -0,0 +1,143 @@ +import { http } from '@/http/request/alova' + +// 登录接口数据类型 +export interface LoginData { + username: string + password: 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('/user/captcha', { + params: { uuid }, + meta: { + ignoreAuth: true, + toast: false, + }, + }) +} + +// 用户登录 +export function login(data: LoginData) { + return http.Post('/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 + sm2PublicKey: string +} + +// 获取用户信息 +export function getUserInfo() { + return http.Get('/user/info', { + meta: { + ignoreAuth: false, + toast: false, + }, + }) +} + +// 获取公共配置 +export function getPublicConfig() { + return http.Get('/user/pub-config', { + meta: { + ignoreAuth: true, + toast: false, + }, + }) +} + +// 注册数据类型 +export interface RegisterData { + username: string + password: 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, + }, + }) +} + +// 忘记密码数据类型 +export interface ForgotPasswordData { + phone: string + code: string + password: string + captchaId: string +} + +// 忘记密码(找回密码) +export function retrievePassword(data: ForgotPasswordData) { + return http.Put('/user/retrieve-password', data, { + meta: { + ignoreAuth: true, + toast: true, + }, + }) +} diff --git a/backend/main/manager-mobile/src/api/chat-history/chat-history.ts b/backend/main/manager-mobile/src/api/chat-history/chat-history.ts new file mode 100644 index 0000000..89c3f1e --- /dev/null +++ b/backend/main/manager-mobile/src/api/chat-history/chat-history.ts @@ -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(`/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(`/agent/${agentId}/chat-history/${sessionId}`, { + meta: { + ignoreAuth: false, + toast: false, + }, + }) +} + +/** + * 获取音频下载ID + * @param audioId 音频ID + */ +export function getAudioId(audioId: string) { + return http.Post(`/agent/audio/${audioId}`, {}, { + meta: { + ignoreAuth: false, + toast: false, + }, + }) +} + +/** + * 获取音频播放地址 + * @param downloadId 下载ID + */ +export function getAudioPlayUrl(downloadId: string) { + // 根据需求文档,这个是直接返回二进制的,所以我们直接构造URL + return `/agent/play/${downloadId}` +} diff --git a/backend/main/manager-mobile/src/api/chat-history/index.ts b/backend/main/manager-mobile/src/api/chat-history/index.ts new file mode 100644 index 0000000..ecf782a --- /dev/null +++ b/backend/main/manager-mobile/src/api/chat-history/index.ts @@ -0,0 +1,2 @@ +export * from './chat-history' +export * from './types' diff --git a/backend/main/manager-mobile/src/api/chat-history/types.ts b/backend/main/manager-mobile/src/api/chat-history/types.ts new file mode 100644 index 0000000..b895ed4 --- /dev/null +++ b/backend/main/manager-mobile/src/api/chat-history/types.ts @@ -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 +} diff --git a/backend/main/manager-mobile/src/api/device/device.ts b/backend/main/manager-mobile/src/api/device/device.ts new file mode 100644 index 0000000..e5a2f9c --- /dev/null +++ b/backend/main/manager-mobile/src/api/device/device.ts @@ -0,0 +1,71 @@ +import type { Device, FirmwareType } from './types' +import { http } from '@/http/request/alova' + +/** + * 获取设备类型列表 + */ +export function getFirmwareTypes() { + return http.Get('/admin/dict/data/type/FIRMWARE_TYPE') +} + +/** + * 获取绑定设备列表 + * @param agentId 智能体ID + */ +export function getBindDevices(agentId: string) { + return http.Get(`/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) +} + +/** + * 手动添加设备 + * @param agentId 智能体ID + * @param board 设备类型 + * @param appVersion 固件版本 + * @param macAddress MAC地址 + */ +export function bindDeviceManual(data: { + agentId: string + board: string + appVersion: string + macAddress: string +}) { + return http.Post('/device/manual-add', data) +} + +/** + * 设置设备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, + }) +} diff --git a/backend/main/manager-mobile/src/api/device/index.ts b/backend/main/manager-mobile/src/api/device/index.ts new file mode 100644 index 0000000..aa5f617 --- /dev/null +++ b/backend/main/manager-mobile/src/api/device/index.ts @@ -0,0 +1,2 @@ +export * from './device' +export * from './types' diff --git a/backend/main/manager-mobile/src/api/device/types.ts b/backend/main/manager-mobile/src/api/device/types.ts new file mode 100644 index 0000000..4b6165c --- /dev/null +++ b/backend/main/manager-mobile/src/api/device/types.ts @@ -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 +} diff --git a/backend/main/manager-mobile/src/api/voiceprint/index.ts b/backend/main/manager-mobile/src/api/voiceprint/index.ts new file mode 100644 index 0000000..af56e69 --- /dev/null +++ b/backend/main/manager-mobile/src/api/voiceprint/index.ts @@ -0,0 +1,2 @@ +export * from './types' +export * from './voiceprint' diff --git a/backend/main/manager-mobile/src/api/voiceprint/types.ts b/backend/main/manager-mobile/src/api/voiceprint/types.ts new file mode 100644 index 0000000..726b178 --- /dev/null +++ b/backend/main/manager-mobile/src/api/voiceprint/types.ts @@ -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 { + code: number + msg: string + data: T +} diff --git a/backend/main/manager-mobile/src/api/voiceprint/voiceprint.ts b/backend/main/manager-mobile/src/api/voiceprint/voiceprint.ts new file mode 100644 index 0000000..0726c53 --- /dev/null +++ b/backend/main/manager-mobile/src/api/voiceprint/voiceprint.ts @@ -0,0 +1,72 @@ +import type { + ChatHistory, + CreateSpeakerData, + VoicePrint, +} from './types' +import { http } from '@/http/request/alova' + +// 获取声纹列表 +export function getVoicePrintList(agentId: string) { + return http.Get(`/agent/voice-print/list/${agentId}`, { + meta: { + ignoreAuth: false, + toast: false, + }, + cacheFor: { + expire: 0, + }, + }) +} + +// 获取语音对话记录(用于选择声纹向量) +export function getChatHistory(agentId: string) { + return http.Get(`/agent/${agentId}/chat-history/user`, { + meta: { + ignoreAuth: false, + toast: false, + }, + cacheFor: { + expire: 0, + }, + }) +} + +// 新增说话人 +export function createVoicePrint(data: CreateSpeakerData) { + return http.Post('/agent/voice-print', data, { + meta: { + ignoreAuth: false, + toast: true, + }, + }) +} + +// 删除声纹 +export function deleteVoicePrint(id: string) { + return http.Delete(`/agent/voice-print/${id}`, { + meta: { + ignoreAuth: false, + toast: true, + }, + }) +} + +// 更新声纹信息 +export function updateVoicePrint(data: VoicePrint) { + return http.Put('/agent/voice-print', data, { + meta: { + ignoreAuth: false, + toast: true, + }, + }) +} + +// 获取音频下载ID +export function getAudioDownloadId(audioId: string) { + return http.Post(`/agent/audio/${audioId}`, {}, { + meta: { + ignoreAuth: false, + toast: false, + }, + }) +} diff --git a/backend/main/manager-mobile/src/components/.gitkeep b/backend/main/manager-mobile/src/components/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/backend/main/manager-mobile/src/components/custom-tabs/index.vue b/backend/main/manager-mobile/src/components/custom-tabs/index.vue new file mode 100644 index 0000000..f5ef070 --- /dev/null +++ b/backend/main/manager-mobile/src/components/custom-tabs/index.vue @@ -0,0 +1,131 @@ + + + + + diff --git a/backend/main/manager-mobile/src/env.d.ts b/backend/main/manager-mobile/src/env.d.ts new file mode 100644 index 0000000..b4a2c97 --- /dev/null +++ b/backend/main/manager-mobile/src/env.d.ts @@ -0,0 +1,34 @@ +/// +/// + +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' diff --git a/backend/main/manager-mobile/src/hooks/.gitkeep b/backend/main/manager-mobile/src/hooks/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/backend/main/manager-mobile/src/hooks/usePageAuth.ts b/backend/main/manager-mobile/src/hooks/usePageAuth.ts new file mode 100644 index 0000000..fd006c8 --- /dev/null +++ b/backend/main/manager-mobile/src/hooks/usePageAuth.ts @@ -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 }) + }) +} diff --git a/backend/main/manager-mobile/src/hooks/useRequest.ts b/backend/main/manager-mobile/src/hooks/useRequest.ts new file mode 100644 index 0000000..017a710 --- /dev/null +++ b/backend/main/manager-mobile/src/hooks/useRequest.ts @@ -0,0 +1,51 @@ +import type { Ref } from 'vue' + +interface IUseRequestOptions { + /** 是否立即执行 */ + immediate?: boolean + /** 初始化数据 */ + initialData?: T +} + +interface IUseRequestReturn { + loading: Ref + error: Ref + data: Ref + run: () => Promise +} + +/** + * 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( + func: () => Promise>, + options: IUseRequestOptions = { immediate: false }, +): IUseRequestReturn { + const loading = ref(false) + const error = ref(false) + const data = ref(options.initialData) as Ref + 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 } +} diff --git a/backend/main/manager-mobile/src/hooks/useUpload.ts b/backend/main/manager-mobile/src/hooks/useUpload.ts new file mode 100644 index 0000000..3080d5a --- /dev/null +++ b/backend/main/manager-mobile/src/hooks/useUpload.ts @@ -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 { + formData?: Record + maxSize?: number + accept?: T extends 'image' ? TImage[] : TFile[] + fileType?: T + success?: (params: any) => void + error?: (err: any) => void +} + +export default function useUpload(options: TOptions = {} as TOptions) { + const { + formData = {}, + maxSize = 5 * 1024 * 1024, + accept = ['*'], + fileType = 'image', + success, + error: onError, + } = options + + const loading = ref(false) + const error = ref(null) + const data = ref(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 + 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, + }) +} diff --git a/backend/main/manager-mobile/src/http/README.md b/backend/main/manager-mobile/src/http/README.md new file mode 100644 index 0000000..fd34fd5 --- /dev/null +++ b/backend/main/manager-mobile/src/http/README.md @@ -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('/api/path', { + params: { id: 1 }, + headers: { 'Custom-Header': 'value' }, + meta: { toast: false } // 关闭错误提示 +}) + +// POST 请求 +http.Post('/api/path', data, { + params: { query: 'param' }, + headers: { 'Content-Type': 'application/json' } +}) +``` \ No newline at end of file diff --git a/backend/main/manager-mobile/src/http/request/alova.ts b/backend/main/manager-mobile/src/http/request/alova.ts new file mode 100644 index 0000000..42243bc --- /dev/null +++ b/backend/main/manager-mobile/src/http/request/alova.ts @@ -0,0 +1,151 @@ +import type { uniappRequestAdapter } from '@alova/adapter-uniapp' +import type { IResponse } from './types' +import type { Language } from '@/store/lang' +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' + +// 语言映射, 用于设置 Accept-language 头 +const langMap: Record = { + zh_CN: 'zh-CN', + en: 'en-US', + zh_TW: 'zh-TW', + de: 'de', + vi: 'vi', + pt_BR: 'pt-BR', +} + +/** + * 创建请求实例 + */ +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) => { + // h5动态获取最新的 baseURL,确保使用用户设置的服务器地址 + const currentBaseUrl = getEnvBaseUrl() + if (currentBaseUrl !== method.baseURL) { + method.baseURL = currentBaseUrl + } + + // 检查混合内容错误(HTTPS页面请求HTTP接口) + const currentProtocol = typeof window !== 'undefined' && window.location.protocol + const requestProtocol = method.baseURL?.split(':')[0] + const currentLang = langMap[uni.getStorageSync('app_language') as Language || 'zh_CN'] + if (currentProtocol === 'https:' && requestProtocol === 'http') { + const errorMessage = '无法配置http协议地址,请检查接口地址' + throw new Error(errorMessage) + } + + // 设置默认 Content-Type + method.config.headers = { + 'Content-Type': ContentTypeEnum.JSON, + 'Accept': 'application/json, text/plain, */*', + 'Accept-language': currentLang, + ...method.config.headers, + } + + const { config } = method + const ignoreAuth = config.meta?.ignoreAuth + console.log('ignoreAuth===>', ignoreAuth) + + // 处理认证信息 + if (!ignoreAuth) { + const authInfo = JSON.parse(uni.getStorageSync('token') || '{}') + if (!authInfo.token) { + // 跳转到登录页 + uni.reLaunch({ url: '/pages/login/index' }) + throw new Error('[请求错误]:未登录') + } + // 添加 Authorization 头 + method.config.headers.Authorization = `Bearer ${authInfo.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?.isExposeError) { + return Promise.reject(msg) + } + + if (config.meta?.toast !== false) { + toast.warning(msg) + } + throw new Error(`请求错误[${code}]:${msg}`) + } + // 处理成功响应,返回业务数据 + return data + }), +}) + +export const http = alovaInstance diff --git a/backend/main/manager-mobile/src/http/request/enum.ts b/backend/main/manager-mobile/src/http/request/enum.ts new file mode 100644 index 0000000..048b561 --- /dev/null +++ b/backend/main/manager-mobile/src/http/request/enum.ts @@ -0,0 +1,70 @@ +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) + MixedContent = 600, // 混合内容错误(HTTPS页面请求HTTP接口) +} +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 + case 600: + message = '混合内容错误(600)' + break + default: + message = `连接出错(${status})!` + } + return `${message},请检查网络或联系管理员!` +} diff --git a/backend/main/manager-mobile/src/http/request/types.ts b/backend/main/manager-mobile/src/http/request/types.ts new file mode 100644 index 0000000..824aa4f --- /dev/null +++ b/backend/main/manager-mobile/src/http/request/types.ts @@ -0,0 +1,22 @@ +// 通用响应格式 +export interface IResponse { + code: number | string + data: T + msg: string + status: string | number +} + +// 分页请求参数 +export interface PageParams { + page: number + pageSize: number + [key: string]: any +} + +// 分页响应数据 +export interface PageResult { + list: T[] + total: number + page: number + pageSize: number +} diff --git a/backend/main/manager-mobile/src/i18n/de.ts b/backend/main/manager-mobile/src/i18n/de.ts new file mode 100644 index 0000000..d76a409 --- /dev/null +++ b/backend/main/manager-mobile/src/i18n/de.ts @@ -0,0 +1,500 @@ +// Deutsch Sprachpaket +export default { + // TabBar + 'tabBar.home': 'Startseite', + 'tabBar.deviceConfig': 'Netzwerkkonfig', + 'tabBar.settings': 'System', + // Einstellungsseitentitel + 'settings.title': 'Einstellungen', + // Anmeldeseite + 'login.pageTitle': 'Anmelden', + 'login.navigationTitle': 'Anmelden', + 'login.fetchConfigError': 'Konfiguration konnte nicht abgerufen werden:', + 'login.selectLanguage': 'Sprache auswählen', + 'login.selectLanguageTip': 'De', + 'login.welcomeBack': 'Willkommen zurück', + 'login.pleaseLogin': 'Bitte melden Sie sich an', + 'login.enterUsername': 'Bitte Benutzernamen eingeben', + 'login.enterPassword': 'Bitte Passwort eingeben', + 'login.enterCaptcha': 'Bitte Bestätigungscode eingeben', + 'login.loginButton': 'Anmelden', + 'login.loggingIn': 'Wird angemeldet...', + 'login.noAccount': 'Registrieren', + 'login.enterPhone': 'Bitte Handynummer eingeben', + 'login.selectCountry': 'Land/Region auswählen', + 'login.confirm': 'Bestätigen', + 'login.serverSetting': 'Server-Einstellungen', + 'login.requiredUsername': 'Benutzername darf nicht leer sein', + 'login.requiredPassword': 'Passwort darf nicht leer sein', + 'login.requiredCaptcha': 'Bestätigungscode darf nicht leer sein', + 'login.requiredMobile': 'Bitte gültige Handynummer eingeben', + 'login.captchaError': 'Grafischer Bestätigungscode Fehler', + 'login.forgotPassword': 'Passwort vergessen', + 'login.userAgreement': 'Nutzungsbedingungen', + 'login.privacyPolicy': 'Datenschutzrichtlinie', + + // Registrierungsseite + 'register.pageTitle': 'Registrieren', + 'register.createAccount': 'Konto erstellen', + 'register.enterUsername': 'Bitte Benutzernamen eingeben', + 'register.enterPassword': 'Bitte Passwort eingeben', + 'register.confirmPassword': 'Bitte Passwort bestätigen', + 'register.enterPhone': 'Bitte Handynummer eingeben', + 'register.enterCode': 'Bitte Bestätigungscode eingeben', + 'register.getCode': 'Code erhalten', + 'register.agreeTerms': 'Ich habe gelesen und stimme zu', + 'register.terms': 'Nutzungsbedingungen', + 'register.privacy': 'Datenschutzrichtlinie', + 'register.registerButton': 'Registrieren', + 'register.registering': 'Wird registriert...', + 'register.haveAccount': 'Bereits ein Konto?', + 'register.loginNow': 'Jetzt anmelden', + 'register.selectCountry': 'Land/Region auswählen', + 'register.confirm': 'Bestätigen', + 'register.captchaSendSuccess': 'Bestätigungscode erfolgreich gesendet', + + // Startseite + 'home.pageTitle': 'Startseite', + 'home.createAgent': 'Agent erstellen', + 'home.agentName': 'Agent', + 'home.modelInfo': 'Modell-Info', + 'home.lastActive': 'Zuletzt aktiv', + 'home.greeting': 'Hallo Jarvis', + 'home.subtitle': 'Lassen Sie uns', + 'home.wonderfulDay': 'einen wunderbaren Tag haben!', + 'home.emptyState': 'Keine Agenten verfügbar', + 'home.deviceManagement': 'Geräteverwaltung', + 'home.lastConversation': 'Letzte Konversation:', + 'home.delete': 'Löschen', + 'home.createFirstAgent': 'Klicken Sie auf die + Schaltfläche unten rechts, um Ihren ersten Agenten zu erstellen', + 'home.dialogTitle': 'Agent erstellen', + 'home.inputPlaceholder': 'z.B. Kundenservice-Assistent, Sprachassistent, Wissens-F&A', + 'home.createError': 'Der Name muss zwischen 1 und 64 Zeichen lang sein.', + 'home.createNow': 'Jetzt erstellen', + 'home.justNow': 'Gerade eben', + 'home.minutesAgo': 'Minuten her', + 'home.hoursAgo': 'Stunden her', + 'home.daysAgo': 'Tage her', + 'home.languageModel': 'LLM', + 'home.voiceModel': 'TTS', + + // Agentenseite + 'agent.pageTitle': 'Agent', + 'agent.roleConfig': 'Rollenkonfiguration', + 'agent.deviceManagement': 'Geräteverwaltung', + 'agent.chatHistory': 'Chat-Verlauf', + 'agent.voiceprintManagement': 'Stimmabdruckverwaltung', + 'agent.editTitle': 'Agent bearbeiten', + 'agent.toolsTitle': 'Bearbeiten', + 'agent.voiceActivityDetection': 'Sprachaktivitätserkennung', + 'agent.speechRecognition': 'Spracherkennung', + 'agent.largeLanguageModel': 'Großes Sprachmodell', + 'agent.save': 'Speichern', + 'agent.cancel': 'Abbrechen', + // Agenten-Bearbeitungsseite + 'agent.basicInfo': 'Grundinformationen', + 'agent.agentName': 'Agentenname', + 'agent.inputAgentName': 'Bitte Agenten-Namen eingeben', + 'agent.roleMode': 'Rollenmodus', + 'agent.agentTag': 'Smart Body-Etiketten', + 'agent.addAgentTag': 'Tags hinzufügen', + 'agent.inputAgentTag': 'Bitte Smart Body-Etiketten eingeben', + 'agent.contextProvider': 'Kontext', + 'agent.contextProviderSuccess': '{count} Quellen erfolgreich hinzugefügt.', + 'agent.contextProviderDocLink': 'Wie man Kontextquellen bereitstellt', + 'agent.editContextProvider': 'Quelle bearbeiten', + 'agent.roleDescription': 'Rollenbeschreibung', + 'agent.inputRoleDescription': 'Bitte Rollenbeschreibung eingeben', + 'agent.modelConfig': 'Modellkonfiguration', + 'agent.vad': 'Sprachaktivitätserkennung', + 'agent.asr': 'Spracherkennung', + 'agent.llm': 'Großes Sprachmodell', + 'agent.vllm': 'Vision-Sprachmodell', + 'agent.intent': 'Absichtserkennung', + 'agent.memory': 'Speicher', + 'agent.voiceSettings': 'Stimmeinstellungen', + 'agent.tts': 'Text-zu-Sprache', + 'agent.voiceprint': 'Agenten-Stimme', + 'agent.plugins': 'Plugins', + 'agent.editFunctions': 'Bearbeiten', + 'agent.historyMemory': 'Verlaufsspeicher', + 'agent.memoryContent': 'Speicherinhalt', + 'agent.saving': 'Wird gespeichert...', + 'agent.saveSuccess': 'Erfolgreich gespeichert', + 'agent.saveFail': 'Speichern fehlgeschlagen', + 'agent.loadFail': 'Laden fehlgeschlagen', + 'agent.pleaseInputAgentName': 'Bitte Agenten-Namen eingeben', + 'agent.pleaseInputRoleDescription': 'Bitte Rollenbeschreibung eingeben', + 'agent.pleaseSelect': 'Bitte auswählen', + 'agent.reportText': 'Text melden', + 'agent.reportTextVoice': 'Text + Sprache melden', + 'agent.reportMode': 'Meldemodus', + 'agent.language': 'Unterhaltungssprache', + 'agent.languageConfig': 'Sprachgeschwindigkeit & Tonhöhe', + 'agent.ttsVolume': 'Lautstärke', + 'agent.ttsRate': 'Sprechtempo', + 'agent.ttsPitch': 'Tonhöhe', + 'agent.volumeHint': '-100=min, 0=Standard, 100=max', + 'agent.speedHint': '-100=langsamst, 0=Standard, 100=schnellst', + 'agent.pitchHint': '-100=tiefst, 0=Standard, 100=höchst', + + // Context provider dialog related + 'contextProviderDialog.title': 'Quelle bearbeiten', + 'contextProviderDialog.noContextApi': 'Keine Kontext-API', + 'contextProviderDialog.add': 'Hinzufügen', + 'contextProviderDialog.apiUrl': 'API-URL', + 'contextProviderDialog.apiUrlPlaceholder': 'http://api.example.com/data', + 'contextProviderDialog.requestHeaders': 'Anfrage-Header', + 'contextProviderDialog.headerKeyPlaceholder': 'Schlüssel', + 'contextProviderDialog.headerValuePlaceholder': 'Wert', + 'contextProviderDialog.noHeaders': 'Keine Headers', + 'contextProviderDialog.addHeader': 'Header hinzufügen', + 'contextProviderDialog.cancel': 'Abbrechen', + 'contextProviderDialog.confirm': 'Bestätigen', + + // Manual add device dialog related + 'manualAddDeviceDialog.title': 'Manuell Gerät hinzufügen', + 'manualAddDeviceDialog.deviceType': 'Gerätetyp', + 'manualAddDeviceDialog.deviceTypePlaceholder': 'Bitte Gerätetyp auswählen', + 'manualAddDeviceDialog.firmwareVersion': 'Firmware-Version', + 'manualAddDeviceDialog.firmwareVersionPlaceholder': 'Bitte Firmware-Version eingeben', + 'manualAddDeviceDialog.macAddress': 'Mac-Adresse', + 'manualAddDeviceDialog.macAddressPlaceholder': 'Bitte Mac-Adresse eingeben', + 'manualAddDeviceDialog.confirm': 'Bestätigen', + 'manualAddDeviceDialog.cancel': 'Abbrechen', + 'manualAddDeviceDialog.requiredMacAddress': 'Bitte Mac-Adresse eingeben', + 'manualAddDeviceDialog.invalidMacAddress': 'Bitte korrektes Mac-Adressformat eingeben, z.B.: 00:1A:2B:3C:4D:5E', + 'manualAddDeviceDialog.requiredDeviceType': 'Bitte Gerätetyp auswählen', + 'manualAddDeviceDialog.requiredFirmwareVersion': 'Bitte Firmware-Version eingeben', + 'manualAddDeviceDialog.getFirmwareTypeFailed': 'Firmware-Typ konnte nicht abgerufen werden', + 'manualAddDeviceDialog.addSuccess': 'Gerät erfolgreich hinzugefügt', + 'manualAddDeviceDialog.addFailed': 'Hinzufügen fehlgeschlagen', + 'manualAddDeviceDialog.bindWithCode': 'Mit 6-stelligem Code binden', + + // Chat-Verlauf Seite + 'chatHistory.getChatSessions': 'Chat-Sitzungsliste abrufen', + 'chatHistory.noSelectedAgent': 'Kein Agent ausgewählt', + 'chatHistory.getChatSessionsFailed': 'Chat-Sitzungsliste konnte nicht abgerufen werden:', + 'chatHistory.unknownTime': 'Unbekannte Zeit', + 'chatHistory.justNow': 'Gerade eben', + 'chatHistory.minutesAgo': 'Vor {minutes} Minuten', + 'chatHistory.hoursAgo': 'Vor {hours} Stunden', + 'chatHistory.daysAgo': 'Vor {days} Tagen', + 'chatHistory.conversationRecord': 'Konversationsaufzeichnung', + 'chatHistory.totalChats': 'Insgesamt {count} Chats', + 'chatHistory.loading': 'Lädt...', + 'chatHistory.noMoreData': 'Keine weiteren Daten', + 'chatHistory.noChatRecords': 'Keine Chat-Aufzeichnungen', + 'chatHistory.chatRecordsDescription': 'Konversationsaufzeichnungen mit Agenten werden hier angezeigt', + // Chat-Verlauf Detailseite + 'chatHistory.pageTitle': 'Chat-Details', + 'chatHistory.assistantName': 'Intelligenter Assistent', + 'chatHistory.userName': 'Benutzer', + 'chatHistory.aiAssistantName': 'KI-Assistent', + 'chatHistory.loadFailed': 'Chat-Verlauf konnte nicht geladen werden', + 'chatHistory.parameterError': 'Seitenparameter Fehler', + 'chatHistory.invalidAudioId': 'Ungültige Audio-ID', + 'chatHistory.audioPlayFailed': 'Audio-Wiedergabe fehlgeschlagen', + 'chatHistory.playAudioFailed': 'Audio konnte nicht abgespielt werden', + + // Geräteverwaltungsseite + 'device.pageTitle': 'Geräteverwaltung', + 'device.noDevices': 'Keine Geräte verfügbar', + 'device.macAddress': 'MAC-Adresse', + 'device.firmwareVersion': 'Firmware-Version', + 'device.lastConnected': 'Letzte Konversation', + 'device.otaUpdate': 'OTA-Update', + 'device.unbind': 'Entbinden', + 'device.confirmUnbind': 'Bestätigen', + 'device.bindDevice': 'Neues Gerät binden', + 'device.deviceType': 'Gerätetyp', + 'device.loading': 'Lädt...', + 'device.neverConnected': 'Nie verbunden', + 'device.justNow': 'Gerade eben', + 'device.minutesAgo': 'Vor {minutes} Minuten', + 'device.hoursAgo': 'Vor {hours} Stunden', + 'device.daysAgo': 'Vor {days} Tagen', + 'device.otaAutoUpdateEnabled': 'OTA Auto-Update aktiviert', + 'device.otaAutoUpdateDisabled': 'OTA Auto-Update deaktiviert', + 'device.operationFailed': 'Operation fehlgeschlagen, bitte erneut versuchen', + 'device.deviceUnbound': 'Gerät entbunden', + 'device.unbindFailed': 'Entbinden fehlgeschlagen, bitte erneut versuchen', + 'device.unbindDevice': 'Gerät entbinden', + 'device.confirmUnbindDevice': 'Sind Sie sicher, dass Sie Gerät "{macAddress}" entbinden möchten?', + 'device.cancel': 'Abbrechen', + 'device.noDevice': 'Kein Gerät', + 'device.pleaseSelectAgent': 'Bitte wählen Sie zuerst einen Agenten aus', + 'device.deviceBindSuccess': 'Gerät erfolgreich gebunden!', + 'device.bindFailed': 'Binden fehlgeschlagen, bitte prüfen Sie ob der Bestätigungscode korrekt ist', + 'device.enterDeviceCode': 'Bitte Geräte-Bestätigungscode eingeben', + 'device.bindNow': 'Jetzt binden', + 'device.lastConnection': 'Letzte Verbindung', + 'device.clickToBindFirstDevice': 'Klicken Sie auf die + Schaltfläche unten rechts, um Ihr erstes Gerät zu binden', + + // Allgemein + 'common.success': 'Erfolg', + 'common.fail': 'Fehlgeschlagen', + 'common.loading': 'Lädt...', + 'common.confirm': 'Bestätigen', + 'common.cancel': 'Abbrechen', + 'common.delete': 'Löschen', + 'common.edit': 'Bearbeiten', + 'common.add': 'Hinzufügen', + 'common.pleaseSelect': 'Bitte auswählen', + 'common.unknownError': 'Unbekannter Fehler', + 'common.networkError': 'Netzwerkfehler', + + // Passwort-Wiederherstellungsseite + 'retrievePassword.title': 'Passwort zurücksetzen', + 'retrievePassword.subtitle': 'Stellen Sie Ihr Kontopasswort über Handynummer wieder her', + 'retrievePassword.mobileRequired': 'Bitte Handynummer eingeben', + 'retrievePassword.inputCorrectMobile': 'Bitte gültige Handynummer eingeben', + 'retrievePassword.captchaRequired': 'Bitte grafischen Bestätigungscode eingeben', + 'retrievePassword.mobileCaptchaRequired': 'Bitte SMS-Bestätigungscode eingeben', + 'retrievePassword.newPasswordRequired': 'Bitte neues Passwort eingeben', + 'retrievePassword.confirmNewPasswordRequired': 'Bitte neues Passwort bestätigen', + 'retrievePassword.passwordsNotMatch': 'Passwörter stimmen nicht überein', + 'retrievePassword.mobilePlaceholder': 'Bitte Handynummer eingeben', + 'retrievePassword.captchaPlaceholder': 'Bitte grafischen Bestätigungscode eingeben', + 'retrievePassword.mobileCaptchaPlaceholder': 'Bitte SMS-Bestätigungscode eingeben', + 'retrievePassword.newPasswordPlaceholder': 'Bitte neues Passwort eingeben', + 'retrievePassword.confirmNewPasswordPlaceholder': 'Bitte neues Passwort bestätigen', + 'retrievePassword.getMobileCaptcha': 'Code erhalten', + 'retrievePassword.captchaSendSuccess': 'Bestätigungscode erfolgreich gesendet', + 'retrievePassword.passwordUpdateSuccess': 'Passwort erfolgreich zurückgesetzt', + 'retrievePassword.resetButton': 'Passwort zurücksetzen', + 'retrievePassword.goToLogin': 'Zurück zur Anmeldung', + + // SM2-Verschlüsselungsbezogene Fehlermeldungen + 'sm2.publicKeyNotConfigured': 'SM2 öffentlicher Schlüssel nicht konfiguriert, bitte Administrator kontaktieren', + 'sm2.encryptionFailed': 'Passwortverschlüsselung fehlgeschlagen', + 'sm2.keyGenerationFailed': 'Schlüsselpaar-Generierung fehlgeschlagen', + 'sm2.invalidPublicKey': 'Ungültiges öffentliches Schlüsselformat', + 'sm2.encryptionError': 'Fehler bei der Verschlüsselung aufgetreten', + 'sm2.publicKeyRetry': 'Öffentlichen Schlüssel erneut abrufen...', + 'sm2.publicKeyRetryFailed': 'Wiederholter Abruf des öffentlichen Schlüssels fehlgeschlagen', + + // Stimmabdruckseite + 'voiceprint.noSelectedAgent': 'Kein Agent ausgewählt', + 'voiceprint.pleaseSelectAgent': 'Bitte wählen Sie zuerst einen Agenten aus', + 'voiceprint.fetchHistoryFailed': 'Chat-Verlauf konnte nicht abgerufen werden', + 'voiceprint.clickToSelectVector': 'Klicken zum Auswählen des Stimmabdruck-Vektors', + 'voiceprint.pleaseInputName': 'Bitte Namen eingeben', + 'voiceprint.pleaseSelectVector': 'Bitte Stimmabdruck-Vektor auswählen', + 'voiceprint.addSuccess': 'Erfolgreich hinzugefügt', + 'voiceprint.addFailed': 'Hinzufügen des Sprechers fehlgeschlagen', + 'voiceprint.editSuccess': 'Erfolgreich bearbeitet', + 'voiceprint.editFailed': 'Bearbeiten des Sprechers fehlgeschlagen', + 'voiceprint.deleteConfirmMsg': 'Sind Sie sicher, dass Sie diesen Sprecher löschen möchten?', + 'voiceprint.deleteConfirmTitle': 'Löschen bestätigen', + 'voiceprint.deleteSuccess': 'Erfolgreich gelöscht', + 'voiceprint.loading': 'Lädt...', + 'voiceprint.delete': 'Löschen', + 'voiceprint.emptyTitle': 'Keine Stimmabdruck-Daten', + 'voiceprint.emptyDesc': 'Klicken Sie auf die + Schaltfläche unten rechts, um Ihren ersten Sprecher hinzuzufügen', + 'voiceprint.addSpeaker': 'Sprecher hinzufügen', + 'voiceprint.voiceVector': 'Stimmabdruck-Vektor', + 'voiceprint.name': 'Name', + 'voiceprint.description': 'Beschreibung', + 'voiceprint.pleaseInputDescription': 'Bitte Beschreibung eingeben', + 'voiceprint.cancel': 'Abbrechen', + 'voiceprint.save': 'Speichern', + 'voiceprint.editSpeaker': 'Sprecher bearbeiten', + 'voiceprint.selectVector': 'Stimmabdruck-Vektor auswählen', + 'voiceprint.voiceprintInterfaceNotConfigured': 'Stimmabdruck-Schnittstelle nicht konfiguriert', + + // Einstellungsseite + 'settings.pageTitle': 'Einstellungen', + 'settings.navigationTitle': 'Einstellungen', + 'settings.networkSettings': 'Netzwerkeinstellungen', + 'settings.serverApiUrl': 'Server-API-URL', + 'settings.validServerUrl': 'Bitte gültige Serveradresse eingeben (beginnt mit http oder https und endet mit /xiaozhi)', + 'settings.saveSettings': 'Einstellungen speichern', + 'settings.resetDefault': 'Auf Standard zurücksetzen', + 'settings.restartApp': 'App neu starten', + 'settings.restartNow': 'Jetzt neu starten', + 'settings.restartLater': 'Später', + // Über uns + 'settings.aboutApp': 'Über XiaoZhi Konsole', + 'settings.aboutContent': 'XiaoZhi Konsole\n\nEine plattformübergreifende mobile Management-App, erstellt mit Vue.js 3 + uni-app, bietet Geräteverwaltung, Agentenkonfiguration und andere Funktionen für xiaozhi ESP32 Smart Hardware.\n\n© 2025 xiaozhi-esp32-server {version}', + 'settings.restartSuccess': 'Gespeichert, Sie können die App später manuell neu starten', + 'settings.serverUrlSavedAndCacheCleared': 'Server-URL gespeichert und Cache geleert', + 'settings.resetToDefaultAndCacheCleared': 'Auf Standard zurückgesetzt und Cache geleert', + 'settings.resetSuccess': 'Zurücksetzen erfolgreich', + 'settings.enterServerUrl': 'Bitte Server-URL eingeben', + 'settings.clearCacheFailed': 'Cache konnte nicht geleert werden', + 'settings.cacheManagement': 'Cache-Verwaltung', + 'settings.totalCacheSize': 'Gesamte Cache-Größe', + 'settings.appDataSize': 'Gesamte App-Datengröße', + 'settings.cacheClear': 'Cache leeren', + 'settings.clearAllCache': 'Alle Cache-Daten löschen', + 'settings.clearCache': 'Cache leeren', + 'settings.modifyWillClearCache': 'Änderungen werden Cache leeren', + 'settings.appInfo': 'App-Info', + 'settings.aboutUs': 'Über uns', + 'settings.appVersion': 'App-Version & Team-Info', + 'settings.confirmClear': 'Löschen bestätigen', + 'settings.confirmClearMessage': 'Sind Sie sicher, dass Sie den gesamten Cache löschen möchten? Dies löscht alle Daten einschließlich Anmeldestatus und erfordert erneute Anmeldung.', + 'settings.cacheCleared': 'Cache erfolgreich geleert, leite zur Anmeldeseite weiter', + 'settings.languageSettings': 'Spracheinstellungen', + 'settings.language': 'Sprache', + 'settings.selectLanguage': 'Sprache auswählen', + 'settings.languageChanged': 'Sprache erfolgreich geändert', + + // Nachrichten + 'message.loginSuccess': 'Anmeldung erfolgreich!', + 'message.loginFail': 'Anmeldung fehlgeschlagen', + 'message.registerSuccess': 'Registrierung erfolgreich', + 'message.registerFail': 'Registrierung fehlgeschlagen', + 'message.saveSuccess': 'Erfolgreich gespeichert', + 'message.saveFail': 'Speichern fehlgeschlagen', + 'message.deleteSuccess': 'Erfolgreich gelöscht', + 'message.deleteFail': 'Löschen fehlgeschlagen', + 'message.bindSuccess': 'Binden erfolgreich', + 'message.bindFail': 'Binden fehlgeschlagen', + 'message.unbindSuccess': 'Entbinden erfolgreich', + 'message.unbindFail': 'Entbinden fehlgeschlagen', + 'message.networkError': 'Netzwerkfehler, bitte Verbindung prüfen', + 'message.serverError': 'Serverfehler, bitte später erneut versuchen', + 'message.invalidAddress': 'Die Adresse kann ungültig sein. Bitte überprüfen Sie, ob der Server gestartet ist oder ob die Netzwerkverbindung funktioniert. Es kann auch sein, dass die Anfrage aufgrund eines Problems mit dem HTTPS-Protokoll nicht gesendet werden kann.', + 'message.languageChanged': 'Sprache geändert', + 'message.passwordError': 'Konto oder Passwort Fehler', + 'message.phoneRegistered': 'Diese Handynummer wurde bereits registriert', + + // Agenten-Werkzeuge Seite + 'agent.tools.pageTitle': 'Agenten-Werkzeuge', + 'agent.tools.unselected': 'Nicht ausgewählt', + 'agent.tools.selected': 'Ausgewählt', + 'agent.tools.noMorePlugins': 'Keine weiteren Plugins', + 'agent.tools.pleaseSelectPlugin': 'Bitte Plugin-Funktion auswählen', + 'agent.tools.builtInPlugins': 'Eingebaute Plugins', + 'agent.tools.mcpAccessPoint': 'MCP-Zugangspunkt', + 'agent.tools.copy': 'Kopieren', + 'agent.tools.noTools': 'Keine Werkzeuge verfügbar', + 'agent.tools.parameterConfig': 'Konfig', + 'agent.tools.noParamsNeeded': 'Keine Parameter benötigt', + 'agent.tools.pleaseInput': 'Bitte eingeben', + 'agent.tools.inputOneItemPerLine': 'Ein Element pro Zeile eingeben', + 'agent.tools.pleaseInputValidJson': 'Bitte gültiges JSON-Format eingeben', + 'agent.tools.enableFunction': 'Funktion aktivieren', + 'agent.tools.toggleFunction': 'Diese Funktion ein- oder ausschalten', + 'agent.tools.jsonFormatError': 'JSON-Format Fehler', + 'agent.tools.noMcpAddressToCopy': 'Keine MCP-Adresse zum Kopieren', + 'agent.tools.mcpAddressCopied': 'MCP-Adresse in Zwischenablage kopiert', + 'agent.tools.copyFailed': 'Kopieren fehlgeschlagen, bitte erneut versuchen', + 'agent.tools.defaultValue': 'Standardwert', + 'agent.tools.notSelected': 'Nicht ausgewählt', + 'agent.tools.clickToConfigure': 'Klicken zum Konfigurieren', + 'agent.tools.mcpEndpoint': 'MCP-Endpunkt', + 'agent.tools.eachLineOneItem': 'Ein Element pro Zeile eingeben', + + // Gerätekonfigurationsseite + 'deviceConfig.pageTitle': 'Gerätekonfiguration', + 'deviceConfig.wifiConfig': 'WiFi-Konfiguration', + 'deviceConfig.ultrasonicConfig': 'Ultraschall-Konfiguration', + 'deviceConfig.selectConfigMethod': 'Konfigurationsmethode auswählen', + 'deviceConfig.networkConfig': 'Netzwerkkonfiguration', + 'deviceConfig.selectedNetwork': 'Ausgewähltes Netzwerk', + 'deviceConfig.signal': 'Signal', + 'deviceConfig.openNetwork': 'Offenes Netzwerk', + 'deviceConfig.encryptedNetwork': 'Verschlüsseltes Netzwerk', + 'deviceConfig.password': 'Passwort', + 'deviceConfig.pleaseEnterPassword': 'Bitte WiFi-Passwort eingeben', + 'deviceConfig.startConfig': 'Konfiguration starten', + 'deviceConfig.connectToXiaozhiHotspot': 'Bitte verbinden Sie sich zuerst mit dem xiaozhi Hotspot', + 'deviceConfig.detecting': 'Erkennen...', + 'deviceConfig.reDetect': 'Erneut erkennen', + 'deviceConfig.alreadyConnected': 'Mit xiaozhi Hotspot verbunden', + 'deviceConfig.refreshStatus': 'Status aktualisieren', + 'deviceConfig.wifiNetworks': 'WiFi-Netzwerke', + 'deviceConfig.selectWifiNetwork': 'WiFi-Netzwerk auswählen', + 'deviceConfig.refreshScan': 'Scan aktualisieren', + 'deviceConfig.noWifiNetworks': 'Keine WiFi-Netzwerke verfügbar', + 'deviceConfig.clickToRefreshScan': 'Bitte Scan aktualisieren klicken', + 'deviceConfig.signalStrong': 'Starkes Signal', + 'deviceConfig.signalGood': 'Gutes Signal', + 'deviceConfig.signalFair': 'Mittleres Signal', + 'deviceConfig.signalWeak': 'Schwaches Signal', + 'deviceConfig.channel': 'Kanal', + 'deviceConfig.about': 'ungefähr', + 'deviceConfig.seconds': 'Sekunden', + 'deviceConfig.generating': 'Wird generiert...', + 'deviceConfig.playing': 'Wird abgespielt...', + 'deviceConfig.generateAndPlaySoundWave': 'Schallwelle generieren und abspielen', + 'deviceConfig.playSoundWave': 'Schallwelle abspielen', + 'deviceConfig.stopPlaying': 'Abspielen stoppen', + 'deviceConfig.autoLoopPlaySoundWave': 'Schallwelle automatisch wiederholt abspielen', + 'deviceConfig.configAudioFile': 'Konfigurations-Audio-Datei', + 'deviceConfig.duration': 'Dauer', + 'deviceConfig.ultrasonicConfigInstructions': 'Ultraschall-Konfigurationsanleitung', + 'deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered': 'Stellen Sie sicher, dass WiFi-Netzwerk ausgewählt und Passwort eingegeben ist', + 'deviceConfig.clickGenerateAndPlaySoundWave': 'Klicken Sie auf Schallwelle generieren und abspielen, das System kodiert Konfigurationsinformationen in Audio', + 'deviceConfig.bringPhoneCloseToXiaozhiDevice': 'Bringen Sie das Telefon in die Nähe des xiaozhi Geräts (1-2 Meter Entfernung)', + 'deviceConfig.duringAudioPlaybackXiaozhiWillReceive': 'Während der Audio-Wiedergabe empfängt xiaozhi und dekodiert Konfigurationsinformationen', + 'deviceConfig.afterConfigSuccessDeviceWillConnect': 'Nach erfolgreicher Konfiguration verbindet sich das Gerät automatisch mit dem WiFi-Netzwerk', + 'deviceConfig.usesAfskModulation': 'Verwendet AFSK-Modulationstechnologie, überträgt Daten durch 1800Hz und 1500Hz Frequenzen', + 'deviceConfig.ensureModeratePhoneVolume': 'Bitte stellen Sie sicher, dass die Telefonlautstärke moderat ist, um Umgebungsgeräuschstörungen zu vermeiden', + 'deviceConfig.generatingUltrasonicConfigAudio': 'Ultraschall-Konfigurationsaudio wird generiert', + 'deviceConfig.configData': 'Konfigurationsdaten', + 'deviceConfig.dataBytesLength': 'Datenbytes-Länge', + 'deviceConfig.bitStreamLength': 'Bitstrom-Länge', + 'deviceConfig.base64Length': 'Base64-Länge', + 'deviceConfig.audioFileTooLarge': 'Audio-Datei zu groß, bitte SSID oder Passwortlänge kürzen', + 'deviceConfig.audioGenerationSuccess': 'Audio-Generierung erfolgreich', + 'deviceConfig.samplePoints': 'Abtastpunkte', + 'deviceConfig.soundWaveGenerationSuccess': 'Schallwellen-Generierung erfolgreich', + 'deviceConfig.audioGenerationFailed': 'Audio-Generierung fehlgeschlagen', + 'deviceConfig.soundWaveGenerationFailed': 'Schallwellen-Generierung fehlgeschlagen', + 'deviceConfig.pleaseGenerateAudioFirst': 'Bitte generieren Sie zuerst Audio', + 'deviceConfig.startPlayingUltrasonicConfigAudio': 'Ultraschall-Konfigurationsaudio wird abgespielt', + 'deviceConfig.ultrasonicAudioStartedPlaying': 'Ultraschall-Audio wurde gestartet', + 'deviceConfig.startPlayingConfigSoundWave': 'Konfigurations-Schallwelle wurde gestartet', + 'deviceConfig.ultrasonicAudioPlaybackEnded': 'Ultraschall-Audio-Wiedergabe beendet', + 'deviceConfig.audioPlaybackFailed': 'Audio-Wiedergabe fehlgeschlagen', + 'deviceConfig.audioResourceBusy': 'Audio-Ressource beschäftigt, bitte später erneut versuchen', + 'deviceConfig.audioFormatNotSupported': 'Audio-Format nicht unterstützt, möglicherweise ein Data-URI-Problem', + 'deviceConfig.audioFileError': 'Audio-Datei-Fehler', + 'deviceConfig.cleaningUpAudioContext': 'Audio-Kontext wird bereinigt', + 'deviceConfig.cleaningUpAudioContextFailed': 'Audio-Kontext-Bereinigung fehlgeschlagen', + 'deviceConfig.stoppedPlayingUltrasonicAudio': 'Ultraschall-Audio-Wiedergabe gestoppt', + 'deviceConfig.stoppedPlaying': 'Wiedergabe gestoppt', + 'deviceConfig.configMethod': 'Konfigurationsmethode', + 'deviceConfig.enterWifiPassword': 'Bitte WiFi-Passwort eingeben', + 'deviceConfig.xiaozhi': 'xiaozhi', + 'deviceConfig.connectXiaozhiHotspot': 'Bitte verbinden Sie sich mit dem xiaozhi Hotspot', + 'deviceConfig.wifiScanResponse': 'WiFi-Scan-Antwort', + 'deviceConfig.scanSuccess': 'Scan erfolgreich', + 'deviceConfig.networks': 'Netzwerke', + 'deviceConfig.wifiScanFailed': 'WiFi-Scan fehlgeschlagen', + 'deviceConfig.scanFailedCheckConnection': 'Scan fehlgeschlagen, bitte Verbindung prüfen', + 'deviceConfig.checking': 'Wird geprüft', + 'deviceConfig.reCheck': 'Erneut prüfen', + 'deviceConfig.connectedXiaozhiHotspot': 'Mit xiaozhi Hotspot verbunden', + 'deviceConfig.wifiNetwork': 'WiFi-Netzwerk', + 'deviceConfig.scanning': 'Wird gescannt', + 'deviceConfig.cancel': 'Abbrechen', + 'deviceConfig.clickRefreshScan': 'Bitte Scan aktualisieren klicken', + 'deviceConfig.esp32ConnectionCheckFailed': 'ESP32-Verbindungsprüfung fehlgeschlagen', + 'deviceConfig.startWifiConfig': 'WiFi-Konfiguration wird gestartet', + 'deviceConfig.configSuccess': 'Konfiguration erfolgreich', + 'deviceConfig.deviceWillConnectTo': 'Gerät wird sich verbinden mit', + 'deviceConfig.deviceWillRestart': 'Gerät wird neu starten', + 'deviceConfig.pleaseDisconnectXiaozhiHotspot': 'Bitte trennen Sie sich vom xiaozhi Hotspot', + 'deviceConfig.configFailed': 'Konfiguration fehlgeschlagen', + 'deviceConfig.wifiConfigFailed': 'WiFi-Konfiguration fehlgeschlagen', + 'deviceConfig.pleaseCheckNetworkConnection': 'Bitte Netzwerkverbindung prüfen', + 'deviceConfig.startWifiConfigButton': 'Konfiguration starten', + 'deviceConfig.wifiConfigInstructions': 'WiFi-Konfigurationsanleitung', + 'deviceConfig.phoneConnectXiaozhiHotspot': 'Telefon mit xiaozhi Hotspot verbinden', + 'deviceConfig.selectTargetWifiNetwork': 'Ziel-WiFi-Netzwerk auswählen', + 'deviceConfig.enterWifiPasswordIfNeeded': 'WiFi-Passwort eingeben falls benötigt', + 'deviceConfig.clickStartConfigAndWait': 'Konfiguration starten klicken und warten', + 'deviceConfig.afterConfigSuccessDeviceWillRestart': 'Nach erfolgreicher Konfiguration startet Gerät automatisch neu', + 'deviceConfig.audioPlaybackError': 'Audio-Wiedergabe-Fehler', + 'deviceConfig.playbackFailed': 'Wiedergabe fehlgeschlagen', + + // Voiceprint page + 'voiceprint.audioNotExist': 'Audio existiert nicht', + 'voiceprint.getAudioFailed': 'Audio konnte nicht abgerufen werden', + 'voiceprint.audioPlayFailed': 'Audio-Wiedergabe fehlgeschlagen', +} diff --git a/backend/main/manager-mobile/src/i18n/en.ts b/backend/main/manager-mobile/src/i18n/en.ts new file mode 100644 index 0000000..0066b0f --- /dev/null +++ b/backend/main/manager-mobile/src/i18n/en.ts @@ -0,0 +1,500 @@ +// English language pack +export default { + // TabBar + 'tabBar.home': 'Home', + 'tabBar.deviceConfig': 'Network Config', + 'tabBar.settings': 'System', + // Settings page title + 'settings.title': 'Settings', + // Login page + 'login.pageTitle': 'Login', + 'login.navigationTitle': 'Login', + 'login.fetchConfigError': 'Failed to fetch configuration:', + 'login.selectLanguage': 'Select Language', + 'login.selectLanguageTip': 'En', + 'login.welcomeBack': 'Welcome Back', + 'login.pleaseLogin': 'Please log in to your account', + 'login.enterUsername': 'Please enter username', + 'login.enterPassword': 'Please enter password', + 'login.enterCaptcha': 'Please enter verification code', + 'login.loginButton': 'Login', + 'login.loggingIn': 'Logging in...', + 'login.noAccount': 'Sign Up', + 'login.enterPhone': 'Please enter phone number', + 'login.selectCountry': 'Select Country/Region', + 'login.confirm': 'Confirm', + 'login.serverSetting': 'Server Settings', + 'login.requiredUsername': 'Username cannot be empty', + 'login.requiredPassword': 'Password cannot be empty', + 'login.requiredCaptcha': 'Verification code cannot be empty', + 'login.requiredMobile': 'Please enter a valid phone number', + 'login.captchaError': 'Graphic verification code error', + 'login.forgotPassword': 'Forgot Password', + 'login.userAgreement': 'User Agreement', + 'login.privacyPolicy': 'Privacy Policy', + + // Register page + 'register.pageTitle': 'Register', + 'register.createAccount': 'Create Account', + 'register.enterUsername': 'Please enter username', + 'register.enterPassword': 'Please enter password', + 'register.confirmPassword': 'Please confirm password', + 'register.enterPhone': 'Please enter phone number', + 'register.enterCode': 'Please enter verification code', + 'register.getCode': 'Get Code', + 'register.agreeTerms': 'I have read and agree to the', + 'register.terms': 'User Agreement', + 'register.privacy': 'Privacy Policy', + 'register.registerButton': 'Register', + 'register.registering': 'Registering...', + 'register.haveAccount': 'Already have an account?', + 'register.loginNow': 'Login Now', + 'register.selectCountry': 'Select Country/Region', + 'register.confirm': 'Confirm', + 'register.captchaSendSuccess': 'Verification code sent successfully', + + // Home page + 'home.pageTitle': 'Home', + 'home.createAgent': 'Create Agent', + 'home.agentName': 'Agent', + 'home.modelInfo': 'Model Info', + 'home.lastActive': 'Last Active', + 'home.greeting': 'Hi Jarvis', + 'home.subtitle': 'Let\'s have', + 'home.wonderfulDay': 'a wonderful day!', + 'home.emptyState': 'No agents available', + 'home.deviceManagement': 'Device Management', + 'home.lastConversation': 'Last Conversation:', + 'home.delete': 'Delete', + 'home.createFirstAgent': 'Click the + button in the lower right corner to create your first agent', + 'home.dialogTitle': 'Create Agent', + 'home.inputPlaceholder': 'e.g. Customer Service Assistant, Voice Assistant, Knowledge Q&A', + 'home.createError': 'The name length must be between 1 and 64 characters', + 'home.createNow': 'Create Now', + 'home.justNow': 'Just now', + 'home.minutesAgo': 'minutes ago', + 'home.hoursAgo': 'hours ago', + 'home.daysAgo': 'days ago', + 'home.languageModel': 'LLM', + 'home.voiceModel': 'TTS', + + // Agent page + 'agent.pageTitle': 'Agent', + 'agent.roleConfig': 'Role Configuration', + 'agent.deviceManagement': 'Device Management', + 'agent.chatHistory': 'Chat History', + 'agent.voiceprintManagement': 'Voiceprint Management', + 'agent.editTitle': 'Edit Agent', + 'agent.toolsTitle': 'Edit Features', + 'agent.voiceActivityDetection': 'Voice Activity Detection', + 'agent.speechRecognition': 'Speech Recognition', + 'agent.largeLanguageModel': 'Large Language Model', + 'agent.save': 'Save', + 'agent.cancel': 'Cancel', + // Agent Edit Page + 'agent.basicInfo': 'Basic Information', + 'agent.agentName': 'Agent Name', + 'agent.inputAgentName': 'Please input agent name', + 'agent.roleMode': 'Role Mode', + 'agent.agentTag': 'Intelligent agent label', + 'agent.addAgentTag': 'Add label', + 'agent.inputAgentTag': 'Please input agent label', + 'agent.contextProvider': 'Context', + 'agent.contextProviderSuccess': 'Successfully added {count} sources.', + 'agent.contextProviderDocLink': 'How to deploy context provider', + 'agent.editContextProvider': 'Edit Source', + 'agent.roleDescription': 'Role Description', + 'agent.inputRoleDescription': 'Please input role description', + 'agent.modelConfig': 'Model Configuration', + 'agent.vad': 'Voice Activity Detection', + 'agent.asr': 'Speech Recognition', + 'agent.llm': 'Large Language Model', + 'agent.vllm': 'Vision Language Model', + 'agent.intent': 'Intent Recognition', + 'agent.memory': 'Memory', + 'agent.voiceSettings': 'Voice Settings', + 'agent.tts': 'Text-to-Speech', + 'agent.voiceprint': 'Agent Voice', + 'agent.plugins': 'Plugins', + 'agent.editFunctions': 'Edit Functions', + 'agent.historyMemory': 'History Memory', + 'agent.memoryContent': 'Memory content', + 'agent.saving': 'Saving...', + 'agent.saveSuccess': 'Save successful', + 'agent.saveFail': 'Save failed', + 'agent.loadFail': 'Load failed', + 'agent.pleaseInputAgentName': 'Please input agent name', + 'agent.pleaseInputRoleDescription': 'Please input role description', + 'agent.pleaseSelect': 'Please select', + 'agent.reportText': 'Report Text', + 'agent.reportTextVoice': 'Report Text+Voice', + 'agent.reportMode': 'Report Mode', + 'agent.language': 'Conversation Language', + 'agent.languageConfig': 'Speech Rate&Tone', + 'agent.ttsVolume': 'Volume', + 'agent.ttsRate': 'Speech Rate', + 'agent.ttsPitch': 'Tone', + 'agent.volumeHint': '-100=Minimum, 0=Standard, 100=Maximum', + 'agent.speedHint': '-100=Slower, 0=Standard, 100=Faster', + 'agent.pitchHint': '-100=Lowest, 0=Standard, 100=Highest', + + // Context provider dialog related + 'contextProviderDialog.title': 'Edit Source', + 'contextProviderDialog.noContextApi': 'No Context API', + 'contextProviderDialog.add': 'Add', + 'contextProviderDialog.apiUrl': 'API URL', + 'contextProviderDialog.apiUrlPlaceholder': 'http://api.example.com/data', + 'contextProviderDialog.requestHeaders': 'Request Headers', + 'contextProviderDialog.headerKeyPlaceholder': 'Key', + 'contextProviderDialog.headerValuePlaceholder': 'Value', + 'contextProviderDialog.noHeaders': 'No Headers', + 'contextProviderDialog.addHeader': 'Add Header', + 'contextProviderDialog.cancel': 'Cancel', + 'contextProviderDialog.confirm': 'Confirm', + + // Manual add device dialog related + 'manualAddDeviceDialog.title': 'Manual Add Device', + 'manualAddDeviceDialog.deviceType': 'Device Type', + 'manualAddDeviceDialog.deviceTypePlaceholder': 'Please select device type', + 'manualAddDeviceDialog.firmwareVersion': 'Firmware Version', + 'manualAddDeviceDialog.firmwareVersionPlaceholder': 'Please enter firmware version', + 'manualAddDeviceDialog.macAddress': 'Mac Address', + 'manualAddDeviceDialog.macAddressPlaceholder': 'Please enter Mac address', + 'manualAddDeviceDialog.confirm': 'Confirm', + 'manualAddDeviceDialog.cancel': 'Cancel', + 'manualAddDeviceDialog.requiredMacAddress': 'Please enter Mac address', + 'manualAddDeviceDialog.invalidMacAddress': 'Please enter correct Mac address format, e.g.: 00:1A:2B:3C:4D:5E', + 'manualAddDeviceDialog.requiredDeviceType': 'Please select device type', + 'manualAddDeviceDialog.requiredFirmwareVersion': 'Please enter firmware version', + 'manualAddDeviceDialog.getFirmwareTypeFailed': 'Failed to get firmware type', + 'manualAddDeviceDialog.addSuccess': 'Device added successfully', + 'manualAddDeviceDialog.addFailed': 'Failed to add', + 'manualAddDeviceDialog.bindWithCode': 'Bind with 6-digit code', + + // Chat History Page + 'chatHistory.getChatSessions': 'Get chat session list', + 'chatHistory.noSelectedAgent': 'No agent selected', + 'chatHistory.getChatSessionsFailed': 'Failed to get chat session list:', + 'chatHistory.unknownTime': 'Unknown time', + 'chatHistory.justNow': 'Just now', + 'chatHistory.minutesAgo': '{minutes} minutes ago', + 'chatHistory.hoursAgo': '{hours} hours ago', + 'chatHistory.daysAgo': '{days} days ago', + 'chatHistory.conversationRecord': 'Conversation Record', + 'chatHistory.totalChats': '{count} chats in total', + 'chatHistory.loading': 'Loading...', + 'chatHistory.noMoreData': 'No more data', + 'chatHistory.noChatRecords': 'No chat records', + 'chatHistory.chatRecordsDescription': 'Conversation records with agents will be displayed here', + // Chat History Detail Page + 'chatHistory.pageTitle': 'Chat Detail', + 'chatHistory.assistantName': 'Intelligent Assistant', + 'chatHistory.userName': 'User', + 'chatHistory.aiAssistantName': 'AI Assistant', + 'chatHistory.loadFailed': 'Failed to load chat history', + 'chatHistory.parameterError': 'Page parameter error', + 'chatHistory.invalidAudioId': 'Invalid audio ID', + 'chatHistory.audioPlayFailed': 'Audio playback failed', + 'chatHistory.playAudioFailed': 'Failed to play audio', + + // Device management page + 'device.pageTitle': 'Device Management', + 'device.noDevices': 'No devices available', + 'device.macAddress': 'MAC Address', + 'device.firmwareVersion': 'Firmware Version', + 'device.lastConnected': 'Last Conversation', + 'device.otaUpdate': 'OTA Update', + 'device.unbind': 'Unbind', + 'device.confirmUnbind': 'Sure', + 'device.bindDevice': 'Bind New Device', + 'device.deviceType': 'Device Type', + 'device.loading': 'Loading...', + 'device.neverConnected': 'Never connected', + 'device.justNow': 'Just now', + 'device.minutesAgo': '{minutes} minutes ago', + 'device.hoursAgo': '{hours} hours ago', + 'device.daysAgo': '{days} days ago', + 'device.otaAutoUpdateEnabled': 'OTA auto update enabled', + 'device.otaAutoUpdateDisabled': 'OTA auto update disabled', + 'device.operationFailed': 'Operation failed, please retry', + 'device.deviceUnbound': 'Device unbound', + 'device.unbindFailed': 'Unbind failed, please retry', + 'device.unbindDevice': 'Unbind Device', + 'device.confirmUnbindDevice': 'Are you sure you want to unbind device "{macAddress}"?', + 'device.cancel': 'Cancel', + 'device.noDevice': 'No Device', + 'device.pleaseSelectAgent': 'Please select an agent first', + 'device.deviceBindSuccess': 'Device bound successfully!', + 'device.bindFailed': 'Bind failed, please check if the verification code is correct', + 'device.enterDeviceCode': 'Please enter device verification code', + 'device.bindNow': 'Bind Now', + 'device.lastConnection': 'Last Connection', + 'device.clickToBindFirstDevice': 'Click the + button in the lower right corner to bind your first device', + + // Common + 'common.success': 'Success', + 'common.fail': 'Failed', + 'common.loading': 'Loading...', + 'common.confirm': 'Confirm', + 'common.cancel': 'Cancel', + 'common.delete': 'Delete', + 'common.edit': 'Edit', + 'common.add': 'Add', + 'common.pleaseSelect': 'Please select', + 'common.unknownError': 'Unknown error', + 'common.networkError': 'Network error', + + // Retrieve Password page + 'retrievePassword.title': 'Reset Password', + 'retrievePassword.subtitle': 'Recover your account password via mobile number', + 'retrievePassword.mobileRequired': 'Please enter mobile number', + 'retrievePassword.inputCorrectMobile': 'Please enter a valid mobile number', + 'retrievePassword.captchaRequired': 'Please enter graphic verification code', + 'retrievePassword.mobileCaptchaRequired': 'Please enter SMS verification code', + 'retrievePassword.newPasswordRequired': 'Please enter new password', + 'retrievePassword.confirmNewPasswordRequired': 'Please confirm new password', + 'retrievePassword.passwordsNotMatch': 'Passwords do not match', + 'retrievePassword.mobilePlaceholder': 'Please enter mobile number', + 'retrievePassword.captchaPlaceholder': 'Please enter graphic verification code', + 'retrievePassword.mobileCaptchaPlaceholder': 'Please enter SMS verification code', + 'retrievePassword.newPasswordPlaceholder': 'Please enter new password', + 'retrievePassword.confirmNewPasswordPlaceholder': 'Please confirm new password', + 'retrievePassword.getMobileCaptcha': 'Get Code', + 'retrievePassword.captchaSendSuccess': 'Verification code sent successfully', + 'retrievePassword.passwordUpdateSuccess': 'Password reset successfully', + 'retrievePassword.resetButton': 'Reset Password', + 'retrievePassword.goToLogin': 'Back to Login', + + // SM2 encryption related error messages + 'sm2.publicKeyNotConfigured': 'SM2 public key not configured, please contact administrator', + 'sm2.encryptionFailed': 'Password encryption failed', + 'sm2.keyGenerationFailed': 'Key pair generation failed', + 'sm2.invalidPublicKey': 'Invalid public key format', + 'sm2.encryptionError': 'Error occurred during encryption', + 'sm2.publicKeyRetry': 'Retrying to get public key...', + 'sm2.publicKeyRetryFailed': 'Public key retrieval retry failed', + + // Voiceprint page + 'voiceprint.noSelectedAgent': 'No agent selected', + 'voiceprint.pleaseSelectAgent': 'Please select an agent first', + 'voiceprint.fetchHistoryFailed': 'Failed to fetch chat history', + 'voiceprint.clickToSelectVector': 'Click to select voiceprint vector', + 'voiceprint.pleaseInputName': 'Please input name', + 'voiceprint.pleaseSelectVector': 'Please select voiceprint vector', + 'voiceprint.addSuccess': 'Add success', + 'voiceprint.addFailed': 'Failed to add speaker', + 'voiceprint.editSuccess': 'Edit success', + 'voiceprint.editFailed': 'Failed to edit speaker', + 'voiceprint.deleteConfirmMsg': 'Are you sure to delete this speaker?', + 'voiceprint.deleteConfirmTitle': 'Confirm Delete', + 'voiceprint.deleteSuccess': 'Delete success', + 'voiceprint.loading': 'Loading...', + 'voiceprint.delete': 'Delete', + 'voiceprint.emptyTitle': 'No voiceprint data', + 'voiceprint.emptyDesc': 'Click the + button at the bottom right to add your first speaker', + 'voiceprint.addSpeaker': 'Add Speaker', + 'voiceprint.voiceVector': 'Voiceprint Vector', + 'voiceprint.name': 'Name', + 'voiceprint.description': 'Description', + 'voiceprint.pleaseInputDescription': 'Please input description', + 'voiceprint.cancel': 'Cancel', + 'voiceprint.save': 'Save', + 'voiceprint.editSpeaker': 'Edit Speaker', + 'voiceprint.selectVector': 'Select Voiceprint Vector', + 'voiceprint.voiceprintInterfaceNotConfigured': 'Voiceprint interface not configured', + + // Settings page + 'settings.pageTitle': 'Settings', + 'settings.navigationTitle': 'Settings', + 'settings.networkSettings': 'Network Settings', + 'settings.serverApiUrl': 'Server API URL', + 'settings.validServerUrl': 'Please enter a valid server address (starting with http or https and ending with /xiaozhi)', + 'settings.saveSettings': 'Save Settings', + 'settings.resetDefault': 'Reset Default', + 'settings.restartApp': 'Restart App', + 'settings.restartNow': 'Restart Now', + 'settings.restartLater': 'Later', + // About us + 'settings.aboutApp': 'About XiaoZhi Console', + 'settings.aboutContent': 'XiaoZhi Console\n\nA cross-platform mobile management app built with Vue.js 3 + uni-app, providing device management, agent configuration and other functions for xiaozhi ESP32 smart hardware.\n\n© 2025 xiaozhi-esp32-server {version}', + 'settings.restartSuccess': 'Saved, you can manually restart the app later', + 'settings.serverUrlSavedAndCacheCleared': 'Server URL saved and cache cleared', + 'settings.resetToDefaultAndCacheCleared': 'Reset to default and cache cleared', + 'settings.resetSuccess': 'Reset successful', + 'settings.enterServerUrl': 'Please enter server URL', + 'settings.clearCacheFailed': 'Failed to clear cache', + 'settings.cacheManagement': 'Cache Management', + 'settings.totalCacheSize': 'Total Cache Size', + 'settings.appDataSize': 'Total App Data Size', + 'settings.cacheClear': 'Cache Clear', + 'settings.clearAllCache': 'Clear all cache data', + 'settings.clearCache': 'Clear Cache', + 'settings.modifyWillClearCache': 'Modifications will clear cache', + 'settings.appInfo': 'App Info', + 'settings.aboutUs': 'About Us', + 'settings.appVersion': 'App Version & Team Info', + 'settings.confirmClear': 'Confirm Clear', + 'settings.confirmClearMessage': 'Are you sure you want to clear all cache? This will delete all data including login status and require re-login.', + 'settings.cacheCleared': 'Cache cleared successfully, redirecting to login page', + 'settings.languageSettings': 'Language Settings', + 'settings.language': 'Language', + 'settings.selectLanguage': 'Select Language', + 'settings.languageChanged': 'Language changed successfully', + + // Messages + 'message.loginSuccess': 'Login successful!', + 'message.loginFail': 'Login failed', + 'message.registerSuccess': 'Registration successful', + 'message.registerFail': 'Registration failed', + 'message.saveSuccess': 'Save successful', + 'message.saveFail': 'Save failed', + 'message.deleteSuccess': 'Delete successful', + 'message.deleteFail': 'Delete failed', + 'message.bindSuccess': 'Binding successful', + 'message.bindFail': 'Binding failed', + 'message.unbindSuccess': 'Unbinding successful', + 'message.unbindFail': 'Unbinding failed', + 'message.networkError': 'Network error, please check your connection', + 'message.serverError': 'Server error, please try again later', + 'message.invalidAddress': 'The address may be invalid. Please check if the server is started or if the network connection is normal; It is also possible that requests cannot be sent due to HTTPS protocol issues', + 'message.languageChanged': 'Language changed', + 'message.passwordError': 'Account or password error', + 'message.phoneRegistered': 'This phone number has been registered', + + // Agent Tools Page + 'agent.tools.pageTitle': 'Agent Tools', + 'agent.tools.unselected': 'Unselected', + 'agent.tools.selected': 'Selected', + 'agent.tools.noMorePlugins': 'No more plugins', + 'agent.tools.pleaseSelectPlugin': 'Please select plugin function', + 'agent.tools.builtInPlugins': 'Built-in Plugins', + 'agent.tools.mcpAccessPoint': 'MCP Access Point', + 'agent.tools.copy': 'Copy', + 'agent.tools.noTools': 'No tools available', + 'agent.tools.parameterConfig': 'Param Config', + 'agent.tools.noParamsNeeded': 'No parameters needed', + 'agent.tools.pleaseInput': 'Please input', + 'agent.tools.inputOneItemPerLine': 'Input one item per line', + 'agent.tools.pleaseInputValidJson': 'Please input valid JSON format', + 'agent.tools.enableFunction': 'Enable Function', + 'agent.tools.toggleFunction': 'Turn on or off this function', + 'agent.tools.jsonFormatError': 'JSON format error', + 'agent.tools.noMcpAddressToCopy': 'No MCP address to copy', + 'agent.tools.mcpAddressCopied': 'MCP address copied to clipboard', + 'agent.tools.copyFailed': 'Copy failed, please try again', + 'agent.tools.defaultValue': 'Default value', + 'agent.tools.notSelected': 'Unselected', + 'agent.tools.clickToConfigure': 'Click to configure', + 'agent.tools.mcpEndpoint': 'MCP Endpoint', + 'agent.tools.eachLineOneItem': 'Input one item per line', + + // Device Config page + 'deviceConfig.pageTitle': 'Device Configuration', + 'deviceConfig.wifiConfig': 'WiFi Configuration', + 'deviceConfig.ultrasonicConfig': 'Ultrasonic Configuration', + 'deviceConfig.selectConfigMethod': 'Select Configuration Method', + 'deviceConfig.networkConfig': 'Network Configuration', + 'deviceConfig.selectedNetwork': 'Selected Network', + 'deviceConfig.signal': 'Signal', + 'deviceConfig.openNetwork': 'Open Network', + 'deviceConfig.encryptedNetwork': 'Encrypted Network', + 'deviceConfig.password': 'Password', + 'deviceConfig.pleaseEnterPassword': 'Please enter WiFi password', + 'deviceConfig.startConfig': 'Start Configuration', + 'deviceConfig.connectToXiaozhiHotspot': 'Please connect to xiaozhi hotspot first', + 'deviceConfig.detecting': 'Detecting...', + 'deviceConfig.reDetect': 'Re-detect', + 'deviceConfig.alreadyConnected': 'Connected to xiaozhi hotspot', + 'deviceConfig.refreshStatus': 'Refresh Status', + 'deviceConfig.wifiNetworks': 'WiFi Networks', + 'deviceConfig.selectWifiNetwork': 'Select WiFi Network', + 'deviceConfig.refreshScan': 'Refresh Scan', + 'deviceConfig.noWifiNetworks': 'No WiFi networks available', + 'deviceConfig.clickToRefreshScan': 'Please click Refresh Scan', + 'deviceConfig.signalStrong': 'Strong Signal', + 'deviceConfig.signalGood': 'Good Signal', + 'deviceConfig.signalFair': 'Fair Signal', + 'deviceConfig.signalWeak': 'Weak Signal', + 'deviceConfig.channel': 'Channel', + 'deviceConfig.about': 'about', + 'deviceConfig.seconds': 'seconds', + 'deviceConfig.generating': 'Generating...', + 'deviceConfig.playing': 'Playing...', + 'deviceConfig.generateAndPlaySoundWave': 'Generate and Play Sound Wave', + 'deviceConfig.playSoundWave': 'Play Sound Wave', + 'deviceConfig.stopPlaying': 'Stop Playing', + 'deviceConfig.autoLoopPlaySoundWave': 'Auto Loop Play Sound Wave', + 'deviceConfig.configAudioFile': 'Configuration Audio File', + 'deviceConfig.duration': 'Duration', + 'deviceConfig.ultrasonicConfigInstructions': 'Ultrasonic Configuration Instructions', + 'deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered': 'Ensure WiFi network is selected and password is entered', + 'deviceConfig.clickGenerateAndPlaySoundWave': 'Click Generate and Play Sound Wave, the system will encode configuration information into audio', + 'deviceConfig.bringPhoneCloseToXiaozhiDevice': 'Bring phone close to xiaozhi device (1-2 meters distance)', + 'deviceConfig.duringAudioPlaybackXiaozhiWillReceive': 'During audio playback, xiaozhi will receive and decode configuration information', + 'deviceConfig.afterConfigSuccessDeviceWillConnect': 'After successful configuration, the device will automatically connect to WiFi network', + 'deviceConfig.usesAfskModulation': 'Uses AFSK modulation technology, transmitting data through 1800Hz and 1500Hz frequencies', + 'deviceConfig.ensureModeratePhoneVolume': 'Please ensure phone volume is moderate to avoid environmental noise interference', + 'deviceConfig.generatingUltrasonicConfigAudio': 'Generating ultrasonic configuration audio', + 'deviceConfig.configData': 'Configuration data', + 'deviceConfig.dataBytesLength': 'Data bytes length', + 'deviceConfig.bitStreamLength': 'Bit stream length', + 'deviceConfig.base64Length': 'Base64 length', + 'deviceConfig.audioFileTooLarge': 'Audio file too large, please shorten SSID or password length', + 'deviceConfig.audioGenerationSuccess': 'Audio generation successful', + 'deviceConfig.samplePoints': 'Sample points', + 'deviceConfig.soundWaveGenerationSuccess': 'Sound wave generation successful', + 'deviceConfig.audioGenerationFailed': 'Audio generation failed', + 'deviceConfig.soundWaveGenerationFailed': 'Sound wave generation failed', + 'deviceConfig.pleaseGenerateAudioFirst': 'Please generate audio first', + 'deviceConfig.startPlayingUltrasonicConfigAudio': 'Starting to play ultrasonic configuration audio', + 'deviceConfig.ultrasonicAudioStartedPlaying': 'Ultrasonic audio started playing', + 'deviceConfig.startPlayingConfigSoundWave': 'Started playing configuration sound wave', + 'deviceConfig.ultrasonicAudioPlaybackEnded': 'Ultrasonic audio playback ended', + 'deviceConfig.audioPlaybackFailed': 'Audio playback failed', + 'deviceConfig.audioResourceBusy': 'Audio resource busy, please try again later', + 'deviceConfig.audioFormatNotSupported': 'Audio format not supported, may be a data URI issue', + 'deviceConfig.audioFileError': 'Audio file error', + 'deviceConfig.cleaningUpAudioContext': 'Cleaning up audio context', + 'deviceConfig.cleaningUpAudioContextFailed': 'Failed to clean up audio context', + 'deviceConfig.stoppedPlayingUltrasonicAudio': 'Stopped playing ultrasonic audio', + 'deviceConfig.stoppedPlaying': 'Stopped playing', + 'deviceConfig.configMethod': 'Configuration Method', + 'deviceConfig.enterWifiPassword': 'Please enter WiFi password', + 'deviceConfig.xiaozhi': 'xiaozhi', + 'deviceConfig.connectXiaozhiHotspot': 'Please connect to xiaozhi hotspot', + 'deviceConfig.wifiScanResponse': 'WiFi scan response', + 'deviceConfig.scanSuccess': 'Scan successful', + 'deviceConfig.networks': 'networks', + 'deviceConfig.wifiScanFailed': 'WiFi scan failed', + 'deviceConfig.scanFailedCheckConnection': 'Scan failed, please check connection', + 'deviceConfig.checking': 'Checking', + 'deviceConfig.reCheck': 'Re-check', + 'deviceConfig.connectedXiaozhiHotspot': 'Connected to xiaozhi hotspot', + 'deviceConfig.wifiNetwork': 'WiFi Network', + 'deviceConfig.scanning': 'Scanning', + 'deviceConfig.cancel': 'Cancel', + 'deviceConfig.clickRefreshScan': 'Please click Refresh Scan', + 'deviceConfig.esp32ConnectionCheckFailed': 'ESP32 connection check failed', + 'deviceConfig.startWifiConfig': 'Starting WiFi configuration', + 'deviceConfig.configSuccess': 'Configuration successful', + 'deviceConfig.deviceWillConnectTo': 'Device will connect to', + 'deviceConfig.deviceWillRestart': 'Device will restart', + 'deviceConfig.pleaseDisconnectXiaozhiHotspot': 'Please disconnect from xiaozhi hotspot', + 'deviceConfig.configFailed': 'Configuration failed', + 'deviceConfig.wifiConfigFailed': 'WiFi configuration failed', + 'deviceConfig.pleaseCheckNetworkConnection': 'Please check network connection', + 'deviceConfig.startWifiConfigButton': 'Start Configuration', + 'deviceConfig.wifiConfigInstructions': 'WiFi Configuration Instructions', + 'deviceConfig.phoneConnectXiaozhiHotspot': 'Phone connect to xiaozhi hotspot', + 'deviceConfig.selectTargetWifiNetwork': 'Select target WiFi network', + 'deviceConfig.enterWifiPasswordIfNeeded': 'Enter WiFi password if needed', + 'deviceConfig.clickStartConfigAndWait': 'Click Start Configuration and wait', + 'deviceConfig.afterConfigSuccessDeviceWillRestart': 'After successful configuration, device will automatically restart', + 'deviceConfig.audioPlaybackError': 'Audio playback error', + 'deviceConfig.playbackFailed': 'Playback failed', + + // Voiceprint page + 'voiceprint.audioNotExist': 'Audio does not exist', + 'voiceprint.getAudioFailed': 'Failed to get audio', + 'voiceprint.audioPlayFailed': 'Audio playback failed', +} diff --git a/backend/main/manager-mobile/src/i18n/index.ts b/backend/main/manager-mobile/src/i18n/index.ts new file mode 100644 index 0000000..e8a606d --- /dev/null +++ b/backend/main/manager-mobile/src/i18n/index.ts @@ -0,0 +1,79 @@ +import { ref } from 'vue' +import { useLangStore } from '@/store/lang' +import type { Language } from '@/store/lang' + +// 导入各个语言的翻译文件 +import zh_CN from './zh_CN' +import en from './en' +import zh_TW from './zh_TW' +import de from './de' +import vi from './vi' +import pt_BR from './pt_BR' + +// 语言包映射 +const messages = { + zh_CN: zh_CN, + en, + zh_TW: zh_TW, + de, + vi, + pt_BR: pt_BR, +} + +// 当前使用的语言 +const currentLang = ref('zh_CN') + +// 初始化语言 +export function initI18n() { + const langStore = useLangStore() + currentLang.value = langStore.currentLang +} + +// 切换语言 +export function changeLanguage(lang: Language) { + currentLang.value = lang + const langStore = useLangStore() + langStore.changeLang(lang) +} + +// 获取翻译文本 +export function t(key: string, params?: Record): string { + const langMessages = messages[currentLang.value] + + // 直接查找扁平键名 + if (langMessages && typeof langMessages === 'object' && key in langMessages) { + let value = langMessages[key] + if (typeof value === 'string') { + // 处理参数替换 + if (params) { + let result = value + Object.entries(params).forEach(([paramKey, paramValue]) => { + const regex = new RegExp(`\{${paramKey}\}`, 'g') + result = result.replace(regex, String(paramValue)) + }) + return result + } + return value + } + return key + } + + return key // 如果找不到对应的翻译,返回key本身 +} + +// 获取当前语言 +export function getCurrentLanguage(): Language { + return currentLang.value +} + +// 获取支持的语言列表 +export function getSupportedLanguages(): { code: Language, name: string }[] { + return [ + { code: 'zh_CN', name: '简体中文' }, + { code: 'en', name: 'English' }, + { code: 'zh_TW', name: '繁體中文' }, + { code: 'de', name: 'Deutsch' }, + { code: 'vi', name: 'Tiếng Việt' }, + { code: 'pt_BR', name: 'Português (Brasil)' }, + ] +} \ No newline at end of file diff --git a/backend/main/manager-mobile/src/i18n/pt_BR.ts b/backend/main/manager-mobile/src/i18n/pt_BR.ts new file mode 100644 index 0000000..416b1f8 --- /dev/null +++ b/backend/main/manager-mobile/src/i18n/pt_BR.ts @@ -0,0 +1,500 @@ +// Pacote de idioma Português Brasileiro +export default { + // TabBar + 'tabBar.home': 'Início', + 'tabBar.deviceConfig': 'Config. de Rede', + 'tabBar.settings': 'Sistema', + // Settings page title + 'settings.title': 'Configurações', + // Login page + 'login.pageTitle': 'Entrar', + 'login.navigationTitle': 'Entrar', + 'login.fetchConfigError': 'Falha ao buscar configuração:', + 'login.selectLanguage': 'Selecionar Idioma', + 'login.selectLanguageTip': 'Pt', + 'login.welcomeBack': 'Bem-vindo de Volta', + 'login.pleaseLogin': 'Por favor, entre na sua conta', + 'login.enterUsername': 'Por favor, insira o nome de usuário', + 'login.enterPassword': 'Por favor, insira a senha', + 'login.enterCaptcha': 'Por favor, insira o código de verificação', + 'login.loginButton': 'Entrar', + 'login.loggingIn': 'Entrando...', + 'login.noAccount': 'Cadastrar', + 'login.enterPhone': 'Por favor, insira o número de telefone', + 'login.selectCountry': 'Selecionar País/Região', + 'login.confirm': 'Confirmar', + 'login.serverSetting': 'Configurações do Servidor', + 'login.requiredUsername': 'O nome de usuário não pode estar vazio', + 'login.requiredPassword': 'A senha não pode estar vazia', + 'login.requiredCaptcha': 'O código de verificação não pode estar vazio', + 'login.requiredMobile': 'Por favor, insira um número de telefone válido', + 'login.captchaError': 'Erro no código de verificação gráfico', + 'login.forgotPassword': 'Esqueceu a Senha', + 'login.userAgreement': 'Termos de Uso', + 'login.privacyPolicy': 'Política de Privacidade', + + // Register page + 'register.pageTitle': 'Cadastro', + 'register.createAccount': 'Criar Conta', + 'register.enterUsername': 'Por favor, insira o nome de usuário', + 'register.enterPassword': 'Por favor, insira a senha', + 'register.confirmPassword': 'Por favor, confirme a senha', + 'register.enterPhone': 'Por favor, insira o número de telefone', + 'register.enterCode': 'Por favor, insira o código de verificação', + 'register.getCode': 'Obter Código', + 'register.agreeTerms': 'Li e concordo com os', + 'register.terms': 'Termos de Uso', + 'register.privacy': 'Política de Privacidade', + 'register.registerButton': 'Cadastrar', + 'register.registering': 'Cadastrando...', + 'register.haveAccount': 'Já tem uma conta?', + 'register.loginNow': 'Entrar Agora', + 'register.selectCountry': 'Selecionar País/Região', + 'register.confirm': 'Confirmar', + 'register.captchaSendSuccess': 'Código de verificação enviado com sucesso', + + // Home page + 'home.pageTitle': 'Início', + 'home.createAgent': 'Criar Agente', + 'home.agentName': 'Agente', + 'home.modelInfo': 'Info do Modelo', + 'home.lastActive': 'Última Atividade', + 'home.greeting': 'Olá Jarvis', + 'home.subtitle': 'Vamos ter', + 'home.wonderfulDay': 'um dia maravilhoso!', + 'home.emptyState': 'Nenhum agente disponível', + 'home.deviceManagement': 'Gerenciamento de Dispositivos', + 'home.lastConversation': 'Última Conversa:', + 'home.delete': 'Excluir', + 'home.createFirstAgent': 'Clique no botão + no canto inferior direito para criar seu primeiro agente', + 'home.dialogTitle': 'Criar Agente', + 'home.inputPlaceholder': 'ex: Assistente de Atendimento, Assistente de Voz, Perguntas e Respostas', + 'home.createError': 'O comprimento do nome deve estar entre 1 e 64 caracteres', + 'home.createNow': 'Criar Agora', + 'home.justNow': 'Agora mesmo', + 'home.minutesAgo': 'minutos atrás', + 'home.hoursAgo': 'horas atrás', + 'home.daysAgo': 'dias atrás', + 'home.languageModel': 'LLM', + 'home.voiceModel': 'TTS', + + // Agent page + 'agent.pageTitle': 'Agente', + 'agent.roleConfig': 'Configuração de Papel', + 'agent.deviceManagement': 'Gerenciamento de Dispositivos', + 'agent.chatHistory': 'Histórico de Conversas', + 'agent.voiceprintManagement': 'Gerenciamento de Impressão Vocal', + 'agent.editTitle': 'Editar Agente', + 'agent.toolsTitle': 'Editar Funcionalidades', + 'agent.voiceActivityDetection': 'Detecção de Atividade de Voz', + 'agent.speechRecognition': 'Reconhecimento de Fala', + 'agent.largeLanguageModel': 'Modelo de Linguagem Grande', + 'agent.save': 'Salvar', + 'agent.cancel': 'Cancelar', + // Agent Edit Page + 'agent.basicInfo': 'Informações Básicas', + 'agent.agentName': 'Nome do Agente', + 'agent.inputAgentName': 'Por favor, insira o nome do agente', + 'agent.roleMode': 'Modo de Papel', + 'agent.agentTag': 'Etiquetas de corpo inteligente', + 'agent.addAgentTag': 'Adicionar etiqueta', + 'agent.inputAgentTag': 'Por favor, insira o rótulo do corpo inteligente', + 'agent.contextProvider': 'Contexto', + 'agent.contextProviderSuccess': '{count} fontes adicionadas com sucesso.', + 'agent.contextProviderDocLink': 'Como implantar provedor de contexto', + 'agent.editContextProvider': 'Editar Fonte', + 'agent.roleDescription': 'Descrição do Papel', + 'agent.inputRoleDescription': 'Por favor, insira a descrição do papel', + 'agent.modelConfig': 'Configuração do Modelo', + 'agent.vad': 'Detecção de Atividade de Voz', + 'agent.asr': 'Reconhecimento de Fala', + 'agent.llm': 'Modelo de Linguagem Grande', + 'agent.vllm': 'Modelo de Linguagem Visual', + 'agent.intent': 'Reconhecimento de Intenção', + 'agent.memory': 'Memória', + 'agent.voiceSettings': 'Configurações de Voz', + 'agent.tts': 'Texto para Fala', + 'agent.voiceprint': 'Voz do Agente', + 'agent.plugins': 'Plugins', + 'agent.editFunctions': 'Editar Funções', + 'agent.historyMemory': 'Memória de Histórico', + 'agent.memoryContent': 'Conteúdo da memória', + 'agent.saving': 'Salvando...', + 'agent.saveSuccess': 'Salvo com sucesso', + 'agent.saveFail': 'Falha ao salvar', + 'agent.loadFail': 'Falha ao carregar', + 'agent.pleaseInputAgentName': 'Por favor, insira o nome do agente', + 'agent.pleaseInputRoleDescription': 'Por favor, insira a descrição do papel', + 'agent.pleaseSelect': 'Por favor, selecione', + 'agent.reportText': 'Enviar Texto', + 'agent.reportTextVoice': 'Enviar Texto+Voz', + 'agent.reportMode': 'Modo de Envio', + 'agent.language': 'Idioma de Conversa', + 'agent.languageConfig': 'Configuração de Voz', + 'agent.ttsVolume': 'Volume', + 'agent.ttsRate': 'Taxa de Fala', + 'agent.ttsPitch': 'Tonalidade', + 'agent.volumeHint': '-100=Mínimo, 0=Padrão, 100=Máximo', + 'agent.speedHint': '-100=Slower, 0=Standard, 100=Faster', + 'agent.pitchHint': '-100=Lowest, 0=Standard, 100=Highest', + + // Diálogo de provedor de contexto + 'contextProviderDialog.title': 'Editar Fonte', + 'contextProviderDialog.noContextApi': 'Sem API de Contexto', + 'contextProviderDialog.add': 'Adicionar', + 'contextProviderDialog.apiUrl': 'URL da API', + 'contextProviderDialog.apiUrlPlaceholder': 'http://api.example.com/data', + 'contextProviderDialog.requestHeaders': 'Cabeçalhos da Requisição', + 'contextProviderDialog.headerKeyPlaceholder': 'Chave', + 'contextProviderDialog.headerValuePlaceholder': 'Valor', + 'contextProviderDialog.noHeaders': 'Sem Cabeçalhos', + 'contextProviderDialog.addHeader': 'Adicionar Cabeçalho', + 'contextProviderDialog.cancel': 'Cancelar', + 'contextProviderDialog.confirm': 'Confirmar', + + // Diálogo de adição manual de dispositivo + 'manualAddDeviceDialog.title': 'Adicionar Dispositivo Manualmente', + 'manualAddDeviceDialog.deviceType': 'Tipo de Dispositivo', + 'manualAddDeviceDialog.deviceTypePlaceholder': 'Por favor, selecione o tipo de dispositivo', + 'manualAddDeviceDialog.firmwareVersion': 'Versão do Firmware', + 'manualAddDeviceDialog.firmwareVersionPlaceholder': 'Por favor, insira a versão do firmware', + 'manualAddDeviceDialog.macAddress': 'Endereço MAC', + 'manualAddDeviceDialog.macAddressPlaceholder': 'Por favor, insira o endereço MAC', + 'manualAddDeviceDialog.confirm': 'Confirmar', + 'manualAddDeviceDialog.cancel': 'Cancelar', + 'manualAddDeviceDialog.requiredMacAddress': 'Por favor, insira o endereço MAC', + 'manualAddDeviceDialog.invalidMacAddress': 'Por favor, insira o formato correto de endereço MAC, ex.: 00:1A:2B:3C:4D:5E', + 'manualAddDeviceDialog.requiredDeviceType': 'Por favor, selecione o tipo de dispositivo', + 'manualAddDeviceDialog.requiredFirmwareVersion': 'Por favor, insira a versão do firmware', + 'manualAddDeviceDialog.getFirmwareTypeFailed': 'Falha ao obter tipo de firmware', + 'manualAddDeviceDialog.addSuccess': 'Dispositivo adicionado com sucesso', + 'manualAddDeviceDialog.addFailed': 'Falha ao adicionar', + 'manualAddDeviceDialog.bindWithCode': 'Vincular com Código de 6 Dígitos', + + // Chat History Page + 'chatHistory.getChatSessions': 'Obter lista de sessões de conversa', + 'chatHistory.noSelectedAgent': 'Nenhum agente selecionado', + 'chatHistory.getChatSessionsFailed': 'Falha ao obter lista de sessões de conversa:', + 'chatHistory.unknownTime': 'Hora desconhecida', + 'chatHistory.justNow': 'Agora mesmo', + 'chatHistory.minutesAgo': '{minutes} minutos atrás', + 'chatHistory.hoursAgo': '{hours} horas atrás', + 'chatHistory.daysAgo': '{days} dias atrás', + 'chatHistory.conversationRecord': 'Registro de Conversas', + 'chatHistory.totalChats': '{count} conversas no total', + 'chatHistory.loading': 'Carregando...', + 'chatHistory.noMoreData': 'Não há mais dados', + 'chatHistory.noChatRecords': 'Nenhum registro de conversa', + 'chatHistory.chatRecordsDescription': 'Os registros de conversas com agentes serão exibidos aqui', + // Chat History Detail Page + 'chatHistory.pageTitle': 'Detalhe da Conversa', + 'chatHistory.assistantName': 'Assistente Inteligente', + 'chatHistory.userName': 'Usuário', + 'chatHistory.aiAssistantName': 'Assistente IA', + 'chatHistory.loadFailed': 'Falha ao carregar histórico de conversas', + 'chatHistory.parameterError': 'Erro de parâmetro da página', + 'chatHistory.invalidAudioId': 'ID de áudio inválido', + 'chatHistory.audioPlayFailed': 'Falha na reprodução de áudio', + 'chatHistory.playAudioFailed': 'Falha ao reproduzir áudio', + + // Device management page + 'device.pageTitle': 'Gerenciamento de Dispositivos', + 'device.noDevices': 'Nenhum dispositivo disponível', + 'device.macAddress': 'Endereço MAC', + 'device.firmwareVersion': 'Versão do Firmware', + 'device.lastConnected': 'Última Conversa', + 'device.otaUpdate': 'Atualização OTA', + 'device.unbind': 'Desvincular', + 'device.confirmUnbind': 'Confirmar', + 'device.bindDevice': 'Vincular Novo Dispositivo', + 'device.deviceType': 'Tipo de Dispositivo', + 'device.loading': 'Carregando...', + 'device.neverConnected': 'Nunca conectado', + 'device.justNow': 'Agora mesmo', + 'device.minutesAgo': '{minutes} minutos atrás', + 'device.hoursAgo': '{hours} horas atrás', + 'device.daysAgo': '{days} dias atrás', + 'device.otaAutoUpdateEnabled': 'Atualização automática OTA ativada', + 'device.otaAutoUpdateDisabled': 'Atualização automática OTA desativada', + 'device.operationFailed': 'Operação falhou, por favor tente novamente', + 'device.deviceUnbound': 'Dispositivo desvinculado', + 'device.unbindFailed': 'Falha ao desvincular, por favor tente novamente', + 'device.unbindDevice': 'Desvincular Dispositivo', + 'device.confirmUnbindDevice': 'Tem certeza que deseja desvincular o dispositivo "{macAddress}"?', + 'device.cancel': 'Cancelar', + 'device.noDevice': 'Nenhum Dispositivo', + 'device.pleaseSelectAgent': 'Por favor, selecione um agente primeiro', + 'device.deviceBindSuccess': 'Dispositivo vinculado com sucesso!', + 'device.bindFailed': 'Falha ao vincular, por favor verifique se o código de verificação está correto', + 'device.enterDeviceCode': 'Por favor, insira o código de verificação do dispositivo', + 'device.bindNow': 'Vincular Agora', + 'device.lastConnection': 'Última Conexão', + 'device.clickToBindFirstDevice': 'Clique no botão + no canto inferior direito para vincular seu primeiro dispositivo', + + // Common + 'common.success': 'Sucesso', + 'common.fail': 'Falhou', + 'common.loading': 'Carregando...', + 'common.confirm': 'Confirmar', + 'common.cancel': 'Cancelar', + 'common.delete': 'Excluir', + 'common.edit': 'Editar', + 'common.add': 'Adicionar', + 'common.pleaseSelect': 'Por favor, selecione', + 'common.unknownError': 'Erro desconhecido', + 'common.networkError': 'Erro de rede', + + // Retrieve Password page + 'retrievePassword.title': 'Redefinir Senha', + 'retrievePassword.subtitle': 'Recupere a senha da sua conta pelo número de celular', + 'retrievePassword.mobileRequired': 'Por favor, insira o número de celular', + 'retrievePassword.inputCorrectMobile': 'Por favor, insira um número de celular válido', + 'retrievePassword.captchaRequired': 'Por favor, insira o código de verificação gráfico', + 'retrievePassword.mobileCaptchaRequired': 'Por favor, insira o código de verificação por SMS', + 'retrievePassword.newPasswordRequired': 'Por favor, insira a nova senha', + 'retrievePassword.confirmNewPasswordRequired': 'Por favor, confirme a nova senha', + 'retrievePassword.passwordsNotMatch': 'As senhas não coincidem', + 'retrievePassword.mobilePlaceholder': 'Por favor, insira o número de celular', + 'retrievePassword.captchaPlaceholder': 'Por favor, insira o código de verificação gráfico', + 'retrievePassword.mobileCaptchaPlaceholder': 'Por favor, insira o código de verificação por SMS', + 'retrievePassword.newPasswordPlaceholder': 'Por favor, insira a nova senha', + 'retrievePassword.confirmNewPasswordPlaceholder': 'Por favor, confirme a nova senha', + 'retrievePassword.getMobileCaptcha': 'Obter Código', + 'retrievePassword.captchaSendSuccess': 'Código de verificação enviado com sucesso', + 'retrievePassword.passwordUpdateSuccess': 'Senha redefinida com sucesso', + 'retrievePassword.resetButton': 'Redefinir Senha', + 'retrievePassword.goToLogin': 'Voltar ao Login', + + // SM2 encryption related error messages + 'sm2.publicKeyNotConfigured': 'Chave pública SM2 não configurada, por favor entre em contato com o administrador', + 'sm2.encryptionFailed': 'Falha na criptografia da senha', + 'sm2.keyGenerationFailed': 'Falha na geração do par de chaves', + 'sm2.invalidPublicKey': 'Formato de chave pública inválido', + 'sm2.encryptionError': 'Ocorreu um erro durante a criptografia', + 'sm2.publicKeyRetry': 'Tentando obter a chave pública novamente...', + 'sm2.publicKeyRetryFailed': 'Falha na nova tentativa de obter a chave pública', + + // Voiceprint page + 'voiceprint.noSelectedAgent': 'Nenhum agente selecionado', + 'voiceprint.pleaseSelectAgent': 'Por favor, selecione um agente primeiro', + 'voiceprint.fetchHistoryFailed': 'Falha ao buscar histórico de conversas', + 'voiceprint.clickToSelectVector': 'Clique para selecionar vetor de impressão vocal', + 'voiceprint.pleaseInputName': 'Por favor, insira o nome', + 'voiceprint.pleaseSelectVector': 'Por favor, selecione o vetor de impressão vocal', + 'voiceprint.addSuccess': 'Adicionado com sucesso', + 'voiceprint.addFailed': 'Falha ao adicionar locutor', + 'voiceprint.editSuccess': 'Editado com sucesso', + 'voiceprint.editFailed': 'Falha ao editar locutor', + 'voiceprint.deleteConfirmMsg': 'Tem certeza que deseja excluir este locutor?', + 'voiceprint.deleteConfirmTitle': 'Confirmar Exclusão', + 'voiceprint.deleteSuccess': 'Excluído com sucesso', + 'voiceprint.loading': 'Carregando...', + 'voiceprint.delete': 'Excluir', + 'voiceprint.emptyTitle': 'Nenhum dado de impressão vocal', + 'voiceprint.emptyDesc': 'Clique no botão + no canto inferior direito para adicionar seu primeiro locutor', + 'voiceprint.addSpeaker': 'Adicionar Locutor', + 'voiceprint.voiceVector': 'Vetor de Impressão Vocal', + 'voiceprint.name': 'Nome', + 'voiceprint.description': 'Descrição', + 'voiceprint.pleaseInputDescription': 'Por favor, insira a descrição', + 'voiceprint.cancel': 'Cancelar', + 'voiceprint.save': 'Salvar', + 'voiceprint.editSpeaker': 'Editar Locutor', + 'voiceprint.selectVector': 'Selecionar Vetor de Impressão Vocal', + 'voiceprint.voiceprintInterfaceNotConfigured': 'Interface de impressão vocal não configurada', + + // Settings page + 'settings.pageTitle': 'Configurações', + 'settings.navigationTitle': 'Configurações', + 'settings.networkSettings': 'Configurações de Rede', + 'settings.serverApiUrl': 'URL da API do Servidor', + 'settings.validServerUrl': 'Por favor, insira um endereço de servidor válido (começando com http ou https e terminando com /xiaozhi)', + 'settings.saveSettings': 'Salvar Configurações', + 'settings.resetDefault': 'Restaurar Padrão', + 'settings.restartApp': 'Reiniciar App', + 'settings.restartNow': 'Reiniciar Agora', + 'settings.restartLater': 'Depois', + // About us + 'settings.aboutApp': 'Sobre o Console XiaoZhi', + 'settings.aboutContent': 'Console XiaoZhi\n\nUm aplicativo móvel de gerenciamento multiplataforma construído com Vue.js 3 + uni-app, oferecendo gerenciamento de dispositivos, configuração de agentes e outras funcionalidades para o hardware inteligente xiaozhi ESP32.\n\n© 2025 xiaozhi-esp32-server {version}', + 'settings.restartSuccess': 'Salvo, você pode reiniciar o app manualmente depois', + 'settings.serverUrlSavedAndCacheCleared': 'URL do servidor salva e cache limpo', + 'settings.resetToDefaultAndCacheCleared': 'Restaurado ao padrão e cache limpo', + 'settings.resetSuccess': 'Restauração bem-sucedida', + 'settings.enterServerUrl': 'Por favor, insira a URL do servidor', + 'settings.clearCacheFailed': 'Falha ao limpar o cache', + 'settings.cacheManagement': 'Gerenciamento de Cache', + 'settings.totalCacheSize': 'Tamanho Total do Cache', + 'settings.appDataSize': 'Tamanho Total dos Dados do App', + 'settings.cacheClear': 'Limpar Cache', + 'settings.clearAllCache': 'Limpar todos os dados de cache', + 'settings.clearCache': 'Limpar Cache', + 'settings.modifyWillClearCache': 'Modificações irão limpar o cache', + 'settings.appInfo': 'Informações do App', + 'settings.aboutUs': 'Sobre Nós', + 'settings.appVersion': 'Versão do App e Info da Equipe', + 'settings.confirmClear': 'Confirmar Limpeza', + 'settings.confirmClearMessage': 'Tem certeza que deseja limpar todo o cache? Isso excluirá todos os dados, incluindo o status de login, e exigirá novo login.', + 'settings.cacheCleared': 'Cache limpo com sucesso, redirecionando para a página de login', + 'settings.languageSettings': 'Configurações de Idioma', + 'settings.language': 'Idioma', + 'settings.selectLanguage': 'Selecionar Idioma', + 'settings.languageChanged': 'Idioma alterado com sucesso', + + // Messages + 'message.loginSuccess': 'Login realizado com sucesso!', + 'message.loginFail': 'Falha no login', + 'message.registerSuccess': 'Cadastro realizado com sucesso', + 'message.registerFail': 'Falha no cadastro', + 'message.saveSuccess': 'Salvo com sucesso', + 'message.saveFail': 'Falha ao salvar', + 'message.deleteSuccess': 'Excluído com sucesso', + 'message.deleteFail': 'Falha ao excluir', + 'message.bindSuccess': 'Vinculação realizada com sucesso', + 'message.bindFail': 'Falha na vinculação', + 'message.unbindSuccess': 'Desvinculação realizada com sucesso', + 'message.unbindFail': 'Falha na desvinculação', + 'message.networkError': 'Erro de rede, por favor verifique sua conexão', + 'message.serverError': 'Erro no servidor, por favor tente novamente mais tarde', + 'message.invalidAddress': 'O endereço pode ser inválido, verifique se o servidor está iniciado ou se a conexão de rede está correta; Também pode ser impossível enviar solicitações devido a problemas com o protocolo HTTPS', + 'message.languageChanged': 'Idioma alterado', + 'message.passwordError': 'Conta ou senha incorretos', + 'message.phoneRegistered': 'Este número de telefone já está cadastrado', + + // Agent Tools Page + 'agent.tools.pageTitle': 'Ferramentas do Agente', + 'agent.tools.unselected': 'Não selecionado', + 'agent.tools.selected': 'Selecionado', + 'agent.tools.noMorePlugins': 'Não há mais plugins', + 'agent.tools.pleaseSelectPlugin': 'Por favor, selecione a função do plugin', + 'agent.tools.builtInPlugins': 'Plugins Integrados', + 'agent.tools.mcpAccessPoint': 'Ponto de Acesso MCP', + 'agent.tools.copy': 'Copiar', + 'agent.tools.noTools': 'Nenhuma ferramenta disponível', + 'agent.tools.parameterConfig': 'Configuração', + 'agent.tools.noParamsNeeded': 'Nenhum parâmetro necessário', + 'agent.tools.pleaseInput': 'Por favor, insira', + 'agent.tools.inputOneItemPerLine': 'Insira um item por linha', + 'agent.tools.pleaseInputValidJson': 'Por favor, insira um formato JSON válido', + 'agent.tools.enableFunction': 'Ativar Função', + 'agent.tools.toggleFunction': 'Ativar ou desativar esta função', + 'agent.tools.jsonFormatError': 'Erro no formato JSON', + 'agent.tools.noMcpAddressToCopy': 'Nenhum endereço MCP para copiar', + 'agent.tools.mcpAddressCopied': 'Endereço MCP copiado para a área de transferência', + 'agent.tools.copyFailed': 'Falha ao copiar, por favor tente novamente', + 'agent.tools.defaultValue': 'Valor padrão', + 'agent.tools.notSelected': 'Não selecionado', + 'agent.tools.clickToConfigure': 'Clique para configurar', + 'agent.tools.mcpEndpoint': 'Endpoint MCP', + 'agent.tools.eachLineOneItem': 'Insira um item por linha', + + // Device Config page + 'deviceConfig.pageTitle': 'Configuração do Dispositivo', + 'deviceConfig.wifiConfig': 'Configuração WiFi', + 'deviceConfig.ultrasonicConfig': 'Configuração Ultrassônica', + 'deviceConfig.selectConfigMethod': 'Selecionar Método de Configuração', + 'deviceConfig.networkConfig': 'Configuração de Rede', + 'deviceConfig.selectedNetwork': 'Rede Selecionada', + 'deviceConfig.signal': 'Sinal', + 'deviceConfig.openNetwork': 'Rede Aberta', + 'deviceConfig.encryptedNetwork': 'Rede Criptografada', + 'deviceConfig.password': 'Senha', + 'deviceConfig.pleaseEnterPassword': 'Por favor, insira a senha do WiFi', + 'deviceConfig.startConfig': 'Iniciar Configuração', + 'deviceConfig.connectToXiaozhiHotspot': 'Por favor, conecte-se ao hotspot xiaozhi primeiro', + 'deviceConfig.detecting': 'Detectando...', + 'deviceConfig.reDetect': 'Detectar Novamente', + 'deviceConfig.alreadyConnected': 'Conectado ao hotspot xiaozhi', + 'deviceConfig.refreshStatus': 'Atualizar Status', + 'deviceConfig.wifiNetworks': 'Redes WiFi', + 'deviceConfig.selectWifiNetwork': 'Selecionar Rede WiFi', + 'deviceConfig.refreshScan': 'Atualizar Busca', + 'deviceConfig.noWifiNetworks': 'Nenhuma rede WiFi disponível', + 'deviceConfig.clickToRefreshScan': 'Por favor, clique em Atualizar Busca', + 'deviceConfig.signalStrong': 'Sinal Forte', + 'deviceConfig.signalGood': 'Sinal Bom', + 'deviceConfig.signalFair': 'Sinal Regular', + 'deviceConfig.signalWeak': 'Sinal Fraco', + 'deviceConfig.channel': 'Canal', + 'deviceConfig.about': 'aproximadamente', + 'deviceConfig.seconds': 'segundos', + 'deviceConfig.generating': 'Gerando...', + 'deviceConfig.playing': 'Reproduzindo...', + 'deviceConfig.generateAndPlaySoundWave': 'Gerar e Reproduzir Onda Sonora', + 'deviceConfig.playSoundWave': 'Reproduzir Onda Sonora', + 'deviceConfig.stopPlaying': 'Parar Reprodução', + 'deviceConfig.autoLoopPlaySoundWave': 'Reproduzir Onda Sonora em Loop Automático', + 'deviceConfig.configAudioFile': 'Arquivo de Áudio de Configuração', + 'deviceConfig.duration': 'Duração', + 'deviceConfig.ultrasonicConfigInstructions': 'Instruções de Configuração Ultrassônica', + 'deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered': 'Certifique-se de que a rede WiFi foi selecionada e a senha foi inserida', + 'deviceConfig.clickGenerateAndPlaySoundWave': 'Clique em Gerar e Reproduzir Onda Sonora, o sistema codificará as informações de configuração em áudio', + 'deviceConfig.bringPhoneCloseToXiaozhiDevice': 'Aproxime o celular do dispositivo xiaozhi (distância de 1-2 metros)', + 'deviceConfig.duringAudioPlaybackXiaozhiWillReceive': 'Durante a reprodução do áudio, o xiaozhi receberá e decodificará as informações de configuração', + 'deviceConfig.afterConfigSuccessDeviceWillConnect': 'Após a configuração bem-sucedida, o dispositivo se conectará automaticamente à rede WiFi', + 'deviceConfig.usesAfskModulation': 'Utiliza tecnologia de modulação AFSK, transmitindo dados pelas frequências de 1800Hz e 1500Hz', + 'deviceConfig.ensureModeratePhoneVolume': 'Por favor, certifique-se de que o volume do celular está moderado para evitar interferência de ruídos ambientais', + 'deviceConfig.generatingUltrasonicConfigAudio': 'Gerando áudio de configuração ultrassônica', + 'deviceConfig.configData': 'Dados de configuração', + 'deviceConfig.dataBytesLength': 'Comprimento dos bytes de dados', + 'deviceConfig.bitStreamLength': 'Comprimento do fluxo de bits', + 'deviceConfig.base64Length': 'Comprimento Base64', + 'deviceConfig.audioFileTooLarge': 'Arquivo de áudio muito grande, por favor reduza o tamanho do SSID ou da senha', + 'deviceConfig.audioGenerationSuccess': 'Áudio gerado com sucesso', + 'deviceConfig.samplePoints': 'Pontos de amostra', + 'deviceConfig.soundWaveGenerationSuccess': 'Onda sonora gerada com sucesso', + 'deviceConfig.audioGenerationFailed': 'Falha na geração do áudio', + 'deviceConfig.soundWaveGenerationFailed': 'Falha na geração da onda sonora', + 'deviceConfig.pleaseGenerateAudioFirst': 'Por favor, gere o áudio primeiro', + 'deviceConfig.startPlayingUltrasonicConfigAudio': 'Iniciando reprodução do áudio de configuração ultrassônica', + 'deviceConfig.ultrasonicAudioStartedPlaying': 'Reprodução do áudio ultrassônico iniciada', + 'deviceConfig.startPlayingConfigSoundWave': 'Reprodução da onda sonora de configuração iniciada', + 'deviceConfig.ultrasonicAudioPlaybackEnded': 'Reprodução do áudio ultrassônico finalizada', + 'deviceConfig.audioPlaybackFailed': 'Falha na reprodução do áudio', + 'deviceConfig.audioResourceBusy': 'Recurso de áudio ocupado, por favor tente novamente mais tarde', + 'deviceConfig.audioFormatNotSupported': 'Formato de áudio não suportado, pode ser um problema de URI de dados', + 'deviceConfig.audioFileError': 'Erro no arquivo de áudio', + 'deviceConfig.cleaningUpAudioContext': 'Limpando contexto de áudio', + 'deviceConfig.cleaningUpAudioContextFailed': 'Falha ao limpar contexto de áudio', + 'deviceConfig.stoppedPlayingUltrasonicAudio': 'Reprodução do áudio ultrassônico interrompida', + 'deviceConfig.stoppedPlaying': 'Reprodução interrompida', + 'deviceConfig.configMethod': 'Método de Configuração', + 'deviceConfig.enterWifiPassword': 'Por favor, insira a senha do WiFi', + 'deviceConfig.xiaozhi': 'xiaozhi', + 'deviceConfig.connectXiaozhiHotspot': 'Por favor, conecte-se ao hotspot xiaozhi', + 'deviceConfig.wifiScanResponse': 'Resposta da busca WiFi', + 'deviceConfig.scanSuccess': 'Busca bem-sucedida', + 'deviceConfig.networks': 'redes', + 'deviceConfig.wifiScanFailed': 'Falha na busca WiFi', + 'deviceConfig.scanFailedCheckConnection': 'Falha na busca, por favor verifique a conexão', + 'deviceConfig.checking': 'Verificando', + 'deviceConfig.reCheck': 'Verificar Novamente', + 'deviceConfig.connectedXiaozhiHotspot': 'Conectado ao hotspot xiaozhi', + 'deviceConfig.wifiNetwork': 'Rede WiFi', + 'deviceConfig.scanning': 'Buscando', + 'deviceConfig.cancel': 'Cancelar', + 'deviceConfig.clickRefreshScan': 'Por favor, clique em Atualizar Busca', + 'deviceConfig.esp32ConnectionCheckFailed': 'Falha na verificação de conexão ESP32', + 'deviceConfig.startWifiConfig': 'Iniciando configuração WiFi', + 'deviceConfig.configSuccess': 'Configuração bem-sucedida', + 'deviceConfig.deviceWillConnectTo': 'O dispositivo se conectará a', + 'deviceConfig.deviceWillRestart': 'O dispositivo será reiniciado', + 'deviceConfig.pleaseDisconnectXiaozhiHotspot': 'Por favor, desconecte-se do hotspot xiaozhi', + 'deviceConfig.configFailed': 'Falha na configuração', + 'deviceConfig.wifiConfigFailed': 'Falha na configuração WiFi', + 'deviceConfig.pleaseCheckNetworkConnection': 'Por favor, verifique a conexão de rede', + 'deviceConfig.startWifiConfigButton': 'Iniciar Configuração', + 'deviceConfig.wifiConfigInstructions': 'Instruções de Configuração WiFi', + 'deviceConfig.phoneConnectXiaozhiHotspot': 'Conecte o celular ao hotspot xiaozhi', + 'deviceConfig.selectTargetWifiNetwork': 'Selecione a rede WiFi de destino', + 'deviceConfig.enterWifiPasswordIfNeeded': 'Insira a senha do WiFi se necessário', + 'deviceConfig.clickStartConfigAndWait': 'Clique em Iniciar Configuração e aguarde', + 'deviceConfig.afterConfigSuccessDeviceWillRestart': 'Após a configuração bem-sucedida, o dispositivo reiniciará automaticamente', + 'deviceConfig.audioPlaybackError': 'Erro na reprodução de áudio', + 'deviceConfig.playbackFailed': 'Falha na reprodução', + + // Voiceprint page + 'voiceprint.audioNotExist': 'O áudio não existe', + 'voiceprint.getAudioFailed': 'Falha ao obter áudio', + 'voiceprint.audioPlayFailed': 'Falha na reprodução de áudio', +} diff --git a/backend/main/manager-mobile/src/i18n/vi.ts b/backend/main/manager-mobile/src/i18n/vi.ts new file mode 100644 index 0000000..8ee1a35 --- /dev/null +++ b/backend/main/manager-mobile/src/i18n/vi.ts @@ -0,0 +1,500 @@ +// Gói ngôn ngữ tiếng Việt +export default { + // TabBar + 'tabBar.home': 'Trang chủ', + 'tabBar.deviceConfig': 'Cấu hình mạng', + 'tabBar.settings': 'Hệ thống', + // Tiêu đề trang cài đặt + 'settings.title': 'Cài đặt', + // Trang đăng nhập + 'login.pageTitle': 'Đăng nhập', + 'login.navigationTitle': 'Đăng nhập', + 'login.fetchConfigError': 'Không thể tải cấu hình:', + 'login.selectLanguage': 'Chọn ngôn ngữ', + 'login.selectLanguageTip': 'Vi', + 'login.welcomeBack': 'Chào mừng trở lại', + 'login.pleaseLogin': 'Vui lòng đăng nhập vào tài khoản của bạn', + 'login.enterUsername': 'Vui lòng nhập tên đăng nhập', + 'login.enterPassword': 'Vui lòng nhập mật khẩu', + 'login.enterCaptcha': 'Vui lòng nhập mã xác minh', + 'login.loginButton': 'Đăng nhập', + 'login.loggingIn': 'Đang đăng nhập...', + 'login.noAccount': 'Đăng ký', + 'login.enterPhone': 'Vui lòng nhập số điện thoại', + 'login.selectCountry': 'Chọn quốc gia/vùng', + 'login.confirm': 'Xác nhận', + 'login.serverSetting': 'Cài đặt máy chủ', + 'login.requiredUsername': 'Tên đăng nhập không thể để trống', + 'login.requiredPassword': 'Mật khẩu không thể để trống', + 'login.requiredCaptcha': 'Mã xác minh không thể để trống', + 'login.requiredMobile': 'Vui lòng nhập số điện thoại hợp lệ', + 'login.captchaError': 'Lỗi mã xác minh đồ họa', + 'login.forgotPassword': 'Quên mật khẩu', + 'login.userAgreement': 'Thỏa thuận người dùng', + 'login.privacyPolicy': 'Chính sách bảo mật', + + // Trang đăng ký + 'register.pageTitle': 'Đăng ký', + 'register.createAccount': 'Tạo tài khoản', + 'register.enterUsername': 'Vui lòng nhập tên đăng nhập', + 'register.enterPassword': 'Vui lòng nhập mật khẩu', + 'register.confirmPassword': 'Vui lòng xác nhận mật khẩu', + 'register.enterPhone': 'Vui lòng nhập số điện thoại', + 'register.enterCode': 'Vui lòng nhập mã xác minh', + 'register.getCode': 'Lấy mã', + 'register.agreeTerms': 'Tôi đã đọc và đồng ý với', + 'register.terms': 'Thỏa thuận người dùng', + 'register.privacy': 'Chính sách bảo mật', + 'register.registerButton': 'Đăng ký', + 'register.registering': 'Đang đăng ký...', + 'register.haveAccount': 'Đã có tài khoản?', + 'register.loginNow': 'Đăng nhập ngay', + 'register.selectCountry': 'Chọn quốc gia/vùng', + 'register.confirm': 'Xác nhận', + 'register.captchaSendSuccess': 'Đã gửi mã xác minh thành công', + + // Trang chủ + 'home.pageTitle': 'Trang chủ', + 'home.createAgent': 'Tạo đại lý', + 'home.agentName': 'Đại lý', + 'home.modelInfo': 'Thông tin mô hình', + 'home.lastActive': 'Hoạt động lần cuối', + 'home.greeting': 'Xin chào Jarvis', + 'home.subtitle': 'Hãy cùng có', + 'home.wonderfulDay': 'một ngày tuyệt vời!', + 'home.emptyState': 'Không có đại lý nào', + 'home.deviceManagement': 'Quản lý thiết bị', + 'home.lastConversation': 'Cuộc trò chuyện cuối:', + 'home.delete': 'Xóa', + 'home.createFirstAgent': 'Nhấp vào nút + ở góc dưới bên phải để tạo đại lý đầu tiên của bạn', + 'home.dialogTitle': 'Tạo đại lý', + 'home.inputPlaceholder': 'ví dụ: Trợ lý chăm sóc khách hàng, Trợ lý giọng nói, Hỏi đáp kiến thức', + 'home.createError': 'Độ dài tên phải từ 1 đến 64 ký tự', + 'home.createNow': 'Tạo ngay', + 'home.justNow': 'Vừa xong', + 'home.minutesAgo': 'phút trước', + 'home.hoursAgo': 'giờ trước', + 'home.daysAgo': 'ngày trước', + 'home.languageModel': 'LLM', + 'home.voiceModel': 'TTS', + + // Trang đại lý + 'agent.pageTitle': 'Đại lý', + 'agent.roleConfig': 'Cấu hình vai trò', + 'agent.deviceManagement': 'Quản lý thiết bị', + 'agent.chatHistory': 'Lịch sử trò chuyện', + 'agent.voiceprintManagement': 'Quản lý dấu giọng nói', + 'agent.editTitle': 'Chỉnh sửa đại lý', + 'agent.toolsTitle': 'Chỉnh sửa tính năng', + 'agent.voiceActivityDetection': 'Phát hiện hoạt động giọng nói', + 'agent.speechRecognition': 'Nhận dạng giọng nói', + 'agent.largeLanguageModel': 'Mô hình ngôn ngữ lớn', + 'agent.save': 'Lưu', + 'agent.cancel': 'Hủy', + // Trang chỉnh sửa đại lý + 'agent.basicInfo': 'Thông tin cơ bản', + 'agent.agentName': 'Tên đại lý', + 'agent.inputAgentName': 'Vui lòng nhập tên đại lý', + 'agent.roleMode': 'Chế độ vai trò', + 'agent.agentTag': 'Nhãn cơ thể thông minh', + 'agent.addAgentTag': 'Thêm thẻ', + 'agent.inputAgentTag': 'Vui lòng nhập thẻ cơ thể thông minh', + 'agent.contextProvider': 'Bối cảnh', + 'agent.contextProviderSuccess': 'Đã thêm thành công {count} nguồn.', + 'agent.contextProviderDocLink': 'Cách triển khai nguồn ngữ cảnh', + 'agent.editContextProvider': 'Chỉnh sửa nguồn', + 'agent.roleDescription': 'Mô tả vai trò', + 'agent.inputRoleDescription': 'Vui lòng nhập mô tả vai trò', + 'agent.modelConfig': 'Cấu hình mô hình', + 'agent.vad': 'Phát hiện hoạt động giọng nói', + 'agent.asr': 'Nhận dạng giọng nói', + 'agent.llm': 'Mô hình ngôn ngữ lớn', + 'agent.vllm': 'Mô hình ngôn ngữ thị giác', + 'agent.intent': 'Nhận dạng ý định', + 'agent.memory': 'Bộ nhớ', + 'agent.voiceSettings': 'Cài đặt giọng nói', + 'agent.tts': 'Văn bản thành giọng nói', + 'agent.voiceprint': 'Giọng nói đại lý', + 'agent.plugins': 'Plugin', + 'agent.editFunctions': 'Chỉnh sửa tính năng', + 'agent.historyMemory': 'Bộ nhớ lịch sử', + 'agent.memoryContent': 'Nội dung bộ nhớ', + 'agent.saving': 'Đang lưu...', + 'agent.saveSuccess': 'Lưu thành công', + 'agent.saveFail': 'Lưu thất bại', + 'agent.loadFail': 'Tải thất bại', + 'agent.pleaseInputAgentName': 'Vui lòng nhập tên đại lý', + 'agent.pleaseInputRoleDescription': 'Vui lòng nhập mô tả vai trò', + 'agent.pleaseSelect': 'Vui lòng chọn', + 'agent.reportText': 'Gửi văn bản', + 'agent.reportTextVoice': 'Gửi văn bản+giọng nói', + 'agent.reportMode': 'Chế độ gửi', + 'agent.language': 'Ngôn ngữ', + 'agent.languageConfig': 'Giọng nói', + 'agent.ttsVolume': 'Âm lượng', + 'agent.ttsRate': 'Tốc độ', + 'agent.ttsPitch': 'Tone', + 'agent.volumeHint': '-100=Minimum, 0=Standard, 100=Maximum', + 'agent.speedHint': '-100=Slowest, 0=Standard, 100=Fastest', + 'agent.pitchHint': '-100=Lowest, 0=Standard, 100=Highest', + + // Context provider dialog related + 'contextProviderDialog.title': 'Chỉnh sửa nguồn', + 'contextProviderDialog.noContextApi': 'Không có API ngữ cảnh', + 'contextProviderDialog.add': 'Thêm', + 'contextProviderDialog.apiUrl': 'Địa chỉ API', + 'contextProviderDialog.apiUrlPlaceholder': 'http://api.example.com/data', + 'contextProviderDialog.requestHeaders': 'Header yêu cầu', + 'contextProviderDialog.headerKeyPlaceholder': 'Khóa', + 'contextProviderDialog.headerValuePlaceholder': 'Giá trị', + 'contextProviderDialog.noHeaders': 'Không có Headers', + 'contextProviderDialog.addHeader': 'Thêm Header', + 'contextProviderDialog.cancel': 'Hủy bỏ', + 'contextProviderDialog.confirm': 'Xác nhận', + + // Manual add device dialog related + 'manualAddDeviceDialog.title': 'Thêm thiết bị thủ công', + 'manualAddDeviceDialog.deviceType': 'Loại thiết bị', + 'manualAddDeviceDialog.deviceTypePlaceholder': 'Vui lòng chọn loại thiết bị', + 'manualAddDeviceDialog.firmwareVersion': 'Phiên bản firmware', + 'manualAddDeviceDialog.firmwareVersionPlaceholder': 'Vui lòng nhập phiên bản firmware', + 'manualAddDeviceDialog.macAddress': 'Địa chỉ Mac', + 'manualAddDeviceDialog.macAddressPlaceholder': 'Vui lòng nhập địa chỉ Mac', + 'manualAddDeviceDialog.confirm': 'Xác nhận', + 'manualAddDeviceDialog.cancel': 'Hủy bỏ', + 'manualAddDeviceDialog.requiredMacAddress': 'Vui lòng nhập địa chỉ Mac', + 'manualAddDeviceDialog.invalidMacAddress': 'Vui lòng nhập đúng định dạng địa chỉ Mac, ví dụ: 00:1A:2B:3C:4D:5E', + 'manualAddDeviceDialog.requiredDeviceType': 'Vui lòng chọn loại thiết bị', + 'manualAddDeviceDialog.requiredFirmwareVersion': 'Vui lòng nhập phiên bản firmware', + 'manualAddDeviceDialog.getFirmwareTypeFailed': 'Không thể lấy loại firmware', + 'manualAddDeviceDialog.addSuccess': 'Đã thêm thiết bị thành công', + 'manualAddDeviceDialog.addFailed': 'Thêm thất bại', + 'manualAddDeviceDialog.bindWithCode': 'Liên kết bằng mã xác minh 6 chữ số', + + // Trang lịch sử trò chuyện + 'chatHistory.getChatSessions': 'Lấy danh sách phiên trò chuyện', + 'chatHistory.noSelectedAgent': 'Chưa chọn đại lý', + 'chatHistory.getChatSessionsFailed': 'Không thể lấy danh sách phiên trò chuyện:', + 'chatHistory.unknownTime': 'Thời gian không xác định', + 'chatHistory.justNow': 'Vừa xong', + 'chatHistory.minutesAgo': '{minutes} phút trước', + 'chatHistory.hoursAgo': '{hours} giờ trước', + 'chatHistory.daysAgo': '{days} ngày trước', + 'chatHistory.conversationRecord': 'Bản ghi trò chuyện', + 'chatHistory.totalChats': 'Tổng cộng {count} cuộc trò chuyện', + 'chatHistory.loading': 'Đang tải...', + 'chatHistory.noMoreData': 'Không còn dữ liệu', + 'chatHistory.noChatRecords': 'Không có bản ghi trò chuyện', + 'chatHistory.chatRecordsDescription': 'Bản ghi trò chuyện với đại lý sẽ hiển thị ở đây', + // Trang chi tiết lịch sử trò chuyện + 'chatHistory.pageTitle': 'Chi tiết trò chuyện', + 'chatHistory.assistantName': 'Trợ lý thông minh', + 'chatHistory.userName': 'Người dùng', + 'chatHistory.aiAssistantName': 'Trợ lý AI', + 'chatHistory.loadFailed': 'Không thể tải lịch sử trò chuyện', + 'chatHistory.parameterError': 'Lỗi tham số trang', + 'chatHistory.invalidAudioId': 'ID âm thanh không hợp lệ', + 'chatHistory.audioPlayFailed': 'Phát âm thanh thất bại', + 'chatHistory.playAudioFailed': 'Không thể phát âm thanh', + + // Trang quản lý thiết bị + 'device.pageTitle': 'Quản lý thiết bị', + 'device.noDevices': 'Không có thiết bị nào', + 'device.macAddress': 'Địa chỉ MAC', + 'device.firmwareVersion': 'Phiên bản firmware', + 'device.lastConnected': 'Cuộc trò chuyện cuối', + 'device.otaUpdate': 'Cập nhật OTA', + 'device.unbind': 'Hủy liên kết', + 'device.confirmUnbind': 'Xác nhận', + 'device.bindDevice': 'Liên kết thiết bị mới', + 'device.deviceType': 'Loại thiết bị', + 'device.loading': 'Đang tải...', + 'device.neverConnected': 'Chưa kết nối', + 'device.justNow': 'Vừa xong', + 'device.minutesAgo': '{minutes} phút trước', + 'device.hoursAgo': '{hours} giờ trước', + 'device.daysAgo': '{days} ngày trước', + 'device.otaAutoUpdateEnabled': 'Đã bật cập nhật OTA tự động', + 'device.otaAutoUpdateDisabled': 'Đã tắt cập nhật OTA tự động', + 'device.operationFailed': 'Thao tác thất bại, vui lòng thử lại', + 'device.deviceUnbound': 'Đã hủy liên kết thiết bị', + 'device.unbindFailed': 'Hủy liên kết thất bại, vui lòng thử lại', + 'device.unbindDevice': 'Hủy liên kết thiết bị', + 'device.confirmUnbindDevice': 'Bạn có chắc chắn muốn hủy liên kết thiết bị "{macAddress}"?', + 'device.cancel': 'Hủy', + 'device.noDevice': 'Không có thiết bị', + 'device.pleaseSelectAgent': 'Vui lòng chọn một đại lý trước', + 'device.deviceBindSuccess': 'Liên kết thiết bị thành công!', + 'device.bindFailed': 'Liên kết thất bại, vui lòng kiểm tra mã xác minh có đúng không', + 'device.enterDeviceCode': 'Vui lòng nhập mã xác minh thiết bị', + 'device.bindNow': 'Liên kết ngay', + 'device.lastConnection': 'Kết nối cuối', + 'device.clickToBindFirstDevice': 'Nhấp vào nút + ở góc dưới bên phải để liên kết thiết bị đầu tiên của bạn', + + // Chung + 'common.success': 'Thành công', + 'common.fail': 'Thất bại', + 'common.loading': 'Đang tải...', + 'common.confirm': 'Xác nhận', + 'common.cancel': 'Hủy', + 'common.delete': 'Xóa', + 'common.edit': 'Chỉnh sửa', + 'common.add': 'Thêm', + 'common.pleaseSelect': 'Vui lòng chọn', + 'common.unknownError': 'Lỗi không xác định', + 'common.networkError': 'Lỗi mạng', + + // Trang khôi phục mật khẩu + 'retrievePassword.title': 'Đặt lại mật khẩu', + 'retrievePassword.subtitle': 'Khôi phục mật khẩu tài khoản qua số điện thoại', + 'retrievePassword.mobileRequired': 'Vui lòng nhập số điện thoại', + 'retrievePassword.inputCorrectMobile': 'Vui lòng nhập số điện thoại hợp lệ', + 'retrievePassword.captchaRequired': 'Vui lòng nhập mã xác minh đồ họa', + 'retrievePassword.mobileCaptchaRequired': 'Vui lòng nhập mã xác minh SMS', + 'retrievePassword.newPasswordRequired': 'Vui lòng nhập mật khẩu mới', + 'retrievePassword.confirmNewPasswordRequired': 'Vui lòng xác nhận mật khẩu mới', + 'retrievePassword.passwordsNotMatch': 'Mật khẩu không khớp', + 'retrievePassword.mobilePlaceholder': 'Vui lòng nhập số điện thoại', + 'retrievePassword.captchaPlaceholder': 'Vui lòng nhập mã xác minh đồ họa', + 'retrievePassword.mobileCaptchaPlaceholder': 'Vui lòng nhập mã xác minh SMS', + 'retrievePassword.newPasswordPlaceholder': 'Vui lòng nhập mật khẩu mới', + 'retrievePassword.confirmNewPasswordPlaceholder': 'Vui lòng xác nhận mật khẩu mới', + 'retrievePassword.getMobileCaptcha': 'Lấy mã', + 'retrievePassword.captchaSendSuccess': 'Đã gửi mã xác minh thành công', + 'retrievePassword.passwordUpdateSuccess': 'Đặt lại mật khẩu thành công', + 'retrievePassword.resetButton': 'Đặt lại mật khẩu', + 'retrievePassword.goToLogin': 'Quay lại đăng nhập', + + // Thông báo lỗi liên quan đến mã hóa SM2 + 'sm2.publicKeyNotConfigured': 'Khóa công khai SM2 chưa được cấu hình, vui lòng liên hệ quản trị viên', + 'sm2.encryptionFailed': 'Mã hóa mật khẩu thất bại', + 'sm2.keyGenerationFailed': 'Tạo cặp khóa thất bại', + 'sm2.invalidPublicKey': 'Định dạng khóa công khai không hợp lệ', + 'sm2.encryptionError': 'Đã xảy ra lỗi khi mã hóa', + 'sm2.publicKeyRetry': 'Đang thử lấy lại khóa công khai...', + 'sm2.publicKeyRetryFailed': 'Thử lấy lại khóa công khai thất bại', + + // Trang dấu giọng nói + 'voiceprint.noSelectedAgent': 'Chưa chọn đại lý', + 'voiceprint.pleaseSelectAgent': 'Vui lòng chọn một đại lý trước', + 'voiceprint.fetchHistoryFailed': 'Không thể tải lịch sử trò chuyện', + 'voiceprint.clickToSelectVector': 'Nhấp để chọn vector dấu giọng nói', + 'voiceprint.pleaseInputName': 'Vui lòng nhập tên', + 'voiceprint.pleaseSelectVector': 'Vui lòng chọn vector dấu giọng nói', + 'voiceprint.addSuccess': 'Thêm thành công', + 'voiceprint.addFailed': 'Thêm người nói thất bại', + 'voiceprint.editSuccess': 'Chỉnh sửa thành công', + 'voiceprint.editFailed': 'Chỉnh sửa người nói thất bại', + 'voiceprint.deleteConfirmMsg': 'Bạn có chắc chắn muốn xóa người nói này?', + 'voiceprint.deleteConfirmTitle': 'Xác nhận xóa', + 'voiceprint.deleteSuccess': 'Xóa thành công', + 'voiceprint.loading': 'Đang tải...', + 'voiceprint.delete': 'Xóa', + 'voiceprint.emptyTitle': 'Không có dữ liệu dấu giọng nói', + 'voiceprint.emptyDesc': 'Nhấp vào nút + ở góc dưới bên phải để thêm người nói đầu tiên của bạn', + 'voiceprint.addSpeaker': 'Thêm người nói', + 'voiceprint.voiceVector': 'Vector dấu giọng nói', + 'voiceprint.name': 'Tên', + 'voiceprint.description': 'Mô tả', + 'voiceprint.pleaseInputDescription': 'Vui lòng nhập mô tả', + 'voiceprint.cancel': 'Hủy', + 'voiceprint.save': 'Lưu', + 'voiceprint.editSpeaker': 'Chỉnh sửa người nói', + 'voiceprint.selectVector': 'Chọn vector dấu giọng nói', + 'voiceprint.voiceprintInterfaceNotConfigured': 'Giao diện dấu giọng nói chưa được cấu hình', + + // Trang cài đặt + 'settings.pageTitle': 'Cài đặt', + 'settings.navigationTitle': 'Cài đặt', + 'settings.networkSettings': 'Cài đặt mạng', + 'settings.serverApiUrl': 'URL API máy chủ', + 'settings.validServerUrl': 'Vui lòng nhập địa chỉ máy chủ hợp lệ (bắt đầu bằng http hoặc https và kết thúc bằng /xiaozhi)', + 'settings.saveSettings': 'Lưu cài đặt', + 'settings.resetDefault': 'Đặt lại mặc định', + 'settings.restartApp': 'Khởi động lại ứng dụng', + 'settings.restartNow': 'Khởi động lại ngay', + 'settings.restartLater': 'Để sau', + // Về chúng tôi + 'settings.aboutApp': 'Về Bảng điều khiển XiaoZhi', + 'settings.aboutContent': 'Bảng điều khiển XiaoZhi\n\nỨng dụng quản lý di động đa nền tảng được xây dựng với Vue.js 3 + uni-app, cung cấp quản lý thiết bị, cấu hình đại lý và các chức năng khác cho phần cứng thông minh xiaozhi ESP32.\n\n© 2025 xiaozhi-esp32-server {version}', + 'settings.restartSuccess': 'Đã lưu, bạn có thể tự khởi động lại ứng dụng sau', + 'settings.serverUrlSavedAndCacheCleared': 'Đã lưu URL máy chủ và xóa bộ nhớ cache', + 'settings.resetToDefaultAndCacheCleared': 'Đã đặt lại mặc định và xóa bộ nhớ cache', + 'settings.resetSuccess': 'Đặt lại thành công', + 'settings.enterServerUrl': 'Vui lòng nhập URL máy chủ', + 'settings.clearCacheFailed': 'Không thể xóa bộ nhớ cache', + 'settings.cacheManagement': 'Quản lý bộ nhớ cache', + 'settings.totalCacheSize': 'Tổng kích thước bộ nhớ cache', + 'settings.appDataSize': 'Tổng kích thước dữ liệu ứng dụng', + 'settings.cacheClear': 'Xóa bộ nhớ cache', + 'settings.clearAllCache': 'Xóa tất cả dữ liệu bộ nhớ cache', + 'settings.clearCache': 'Xóa bộ nhớ cache', + 'settings.modifyWillClearCache': 'Thay đổi sẽ xóa bộ nhớ cache', + 'settings.appInfo': 'Thông tin ứng dụng', + 'settings.aboutUs': 'Về chúng tôi', + 'settings.appVersion': 'Phiên bản ứng dụng & Thông tin nhóm', + 'settings.confirmClear': 'Xác nhận xóa', + 'settings.confirmClearMessage': 'Bạn có chắc chắn muốn xóa toàn bộ bộ nhớ cache? Điều này sẽ xóa tất cả dữ liệu bao gồm trạng thái đăng nhập và yêu cầu đăng nhập lại.', + 'settings.cacheCleared': 'Đã xóa bộ nhớ cache thành công, đang chuyển hướng đến trang đăng nhập', + 'settings.languageSettings': 'Cài đặt ngôn ngữ', + 'settings.language': 'Ngôn ngữ', + 'settings.selectLanguage': 'Chọn ngôn ngữ', + 'settings.languageChanged': 'Đã thay đổi ngôn ngữ thành công', + + // Thông báo + 'message.loginSuccess': 'Đăng nhập thành công!', + 'message.loginFail': 'Đăng nhập thất bại', + 'message.registerSuccess': 'Đăng ký thành công', + 'message.registerFail': 'Đăng ký thất bại', + 'message.saveSuccess': 'Lưu thành công', + 'message.saveFail': 'Lưu thất bại', + 'message.deleteSuccess': 'Xóa thành công', + 'message.deleteFail': 'Xóa thất bại', + 'message.bindSuccess': 'Liên kết thành công', + 'message.bindFail': 'Liên kết thất bại', + 'message.unbindSuccess': 'Hủy liên kết thành công', + 'message.unbindFail': 'Hủy liên kết thất bại', + 'message.networkError': 'Lỗi mạng, vui lòng kiểm tra kết nối', + 'message.serverError': 'Lỗi máy chủ, vui lòng thử lại sau', + 'message.invalidAddress': 'Địa chỉ có thể không hợp lệ. Vui lòng kiểm tra xem máy chủ đã khởi động hay kết nối mạng chưa; Có thể không gửi được yêu cầu do lỗi giao thức HTTPS', + 'message.languageChanged': 'Đã thay đổi ngôn ngữ', + 'message.passwordError': 'Lỗi tài khoản hoặc mật khẩu', + 'message.phoneRegistered': 'Số điện thoại này đã được đăng ký', + + // Trang công cụ đại lý + 'agent.tools.pageTitle': 'Công cụ đại lý', + 'agent.tools.unselected': 'Chưa chọn', + 'agent.tools.selected': 'Đã chọn', + 'agent.tools.noMorePlugins': 'Không còn plugin', + 'agent.tools.pleaseSelectPlugin': 'Vui lòng chọn chức năng plugin', + 'agent.tools.builtInPlugins': 'Plugin tích hợp', + 'agent.tools.mcpAccessPoint': 'Điểm truy cập MCP', + 'agent.tools.copy': 'Sao chép', + 'agent.tools.noTools': 'Không có công cụ nào', + 'agent.tools.parameterConfig': 'Cấu hình', + 'agent.tools.noParamsNeeded': 'Không cần tham số', + 'agent.tools.pleaseInput': 'Vui lòng nhập', + 'agent.tools.inputOneItemPerLine': 'Nhập một mục mỗi dòng', + 'agent.tools.pleaseInputValidJson': 'Vui lòng nhập định dạng JSON hợp lệ', + 'agent.tools.enableFunction': 'Bật chức năng', + 'agent.tools.toggleFunction': 'Bật hoặc tắt chức năng này', + 'agent.tools.jsonFormatError': 'Lỗi định dạng JSON', + 'agent.tools.noMcpAddressToCopy': 'Không có địa chỉ MCP để sao chép', + 'agent.tools.mcpAddressCopied': 'Đã sao chép địa chỉ MCP vào bộ nhớ tạm', + 'agent.tools.copyFailed': 'Sao chép thất bại, vui lòng thử lại', + 'agent.tools.defaultValue': 'Giá trị mặc định', + 'agent.tools.notSelected': 'Chưa chọn', + 'agent.tools.clickToConfigure': 'Nhấp để cấu hình', + 'agent.tools.mcpEndpoint': 'Điểm cuối MCP', + 'agent.tools.eachLineOneItem': 'Nhập một mục mỗi dòng', + + // Trang cấu hình thiết bị + 'deviceConfig.pageTitle': 'Cấu hình thiết bị', + 'deviceConfig.wifiConfig': 'Cấu hình WiFi', + 'deviceConfig.ultrasonicConfig': 'Cấu hình siêu âm', + 'deviceConfig.selectConfigMethod': 'Chọn phương pháp cấu hình', + 'deviceConfig.networkConfig': 'Cấu hình mạng', + 'deviceConfig.selectedNetwork': 'Mạng đã chọn', + 'deviceConfig.signal': 'Tín hiệu', + 'deviceConfig.openNetwork': 'Mạng mở', + 'deviceConfig.encryptedNetwork': 'Mạng mã hóa', + 'deviceConfig.password': 'Mật khẩu', + 'deviceConfig.pleaseEnterPassword': 'Vui lòng nhập mật khẩu WiFi', + 'deviceConfig.startConfig': 'Bắt đầu cấu hình', + 'deviceConfig.connectToXiaozhiHotspot': 'Vui lòng kết nối với điểm phát sóng xiaozhi trước', + 'deviceConfig.detecting': 'Đang phát hiện...', + 'deviceConfig.reDetect': 'Phát hiện lại', + 'deviceConfig.alreadyConnected': 'Đã kết nối với điểm phát sóng xiaozhi', + 'deviceConfig.refreshStatus': 'Làm mới trạng thái', + 'deviceConfig.wifiNetworks': 'Mạng WiFi', + 'deviceConfig.selectWifiNetwork': 'Chọn mạng WiFi', + 'deviceConfig.refreshScan': 'Làm mới quét', + 'deviceConfig.noWifiNetworks': 'Không có mạng WiFi nào', + 'deviceConfig.clickToRefreshScan': 'Vui lòng nhấp Làm mới quét', + 'deviceConfig.signalStrong': 'Tín hiệu mạnh', + 'deviceConfig.signalGood': 'Tín hiệu tốt', + 'deviceConfig.signalFair': 'Tín hiệu trung bình', + 'deviceConfig.signalWeak': 'Tín hiệu yếu', + 'deviceConfig.channel': 'Kênh', + 'deviceConfig.about': 'khoảng', + 'deviceConfig.seconds': 'giây', + 'deviceConfig.generating': 'Đang tạo...', + 'deviceConfig.playing': 'Đang phát...', + 'deviceConfig.generateAndPlaySoundWave': 'Tạo và phát sóng âm', + 'deviceConfig.playSoundWave': 'Phát sóng âm', + 'deviceConfig.stopPlaying': 'Dừng phát', + 'deviceConfig.autoLoopPlaySoundWave': 'Tự động lặp phát sóng âm', + 'deviceConfig.configAudioFile': 'Tệp âm thanh cấu hình', + 'deviceConfig.duration': 'Thời lượng', + 'deviceConfig.ultrasonicConfigInstructions': 'Hướng dẫn cấu hình siêu âm', + 'deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered': 'Đảm bảo mạng WiFi được chọn và mật khẩu đã nhập', + 'deviceConfig.clickGenerateAndPlaySoundWave': 'Nhấp Tạo và phát sóng âm, hệ thống sẽ mã hóa thông tin cấu hình thành âm thanh', + 'deviceConfig.bringPhoneCloseToXiaozhiDevice': 'Đưa điện thoại lại gần thiết bị xiaozhi (khoảng cách 1-2 mét)', + 'deviceConfig.duringAudioPlaybackXiaozhiWillReceive': 'Trong khi phát âm thanh, xiaozhi sẽ nhận và giải mã thông tin cấu hình', + 'deviceConfig.afterConfigSuccessDeviceWillConnect': 'Sau khi cấu hình thành công, thiết bị sẽ tự động kết nối với mạng WiFi', + 'deviceConfig.usesAfskModulation': 'Sử dụng công nghệ điều chế AFSK, truyền dữ liệu qua tần số 1800Hz và 1500Hz', + 'deviceConfig.ensureModeratePhoneVolume': 'Vui lòng đảm bảo âm lượng điện thoại vừa phải để tránh nhiễu tiếng ồn môi trường', + 'deviceConfig.generatingUltrasonicConfigAudio': 'Đang tạo âm thanh cấu hình siêu âm', + 'deviceConfig.configData': 'Dữ liệu cấu hình', + 'deviceConfig.dataBytesLength': 'Độ dài byte dữ liệu', + 'deviceConfig.bitStreamLength': 'Độ dài luồng bit', + 'deviceConfig.base64Length': 'Độ dài base64', + 'deviceConfig.audioFileTooLarge': 'Tệp âm thanh quá lớn, vui lòng rút ngắn SSID hoặc độ dài mật khẩu', + 'deviceConfig.audioGenerationSuccess': 'Tạo âm thanh thành công', + 'deviceConfig.samplePoints': 'Điểm mẫu', + 'deviceConfig.soundWaveGenerationSuccess': 'Tạo sóng âm thành công', + 'deviceConfig.audioGenerationFailed': 'Tạo âm thanh thất bại', + 'deviceConfig.soundWaveGenerationFailed': 'Tạo sóng âm thất bại', + 'deviceConfig.pleaseGenerateAudioFirst': 'Vui lòng tạo âm thanh trước', + 'deviceConfig.startPlayingUltrasonicConfigAudio': 'Bắt đầu phát âm thanh cấu hình siêu âm', + 'deviceConfig.ultrasonicAudioStartedPlaying': 'Đã bắt đầu phát âm thanh siêu âm', + 'deviceConfig.startPlayingConfigSoundWave': 'Đã bắt đầu phát sóng âm cấu hình', + 'deviceConfig.ultrasonicAudioPlaybackEnded': 'Kết thúc phát âm thanh siêu âm', + 'deviceConfig.audioPlaybackFailed': 'Phát âm thanh thất bại', + 'deviceConfig.audioResourceBusy': 'Tài nguyên âm thanh bận, vui lòng thử lại sau', + 'deviceConfig.audioFormatNotSupported': 'Định dạng âm thanh không được hỗ trợ, có thể là vấn đề URI dữ liệu', + 'deviceConfig.audioFileError': 'Lỗi tệp âm thanh', + 'deviceConfig.cleaningUpAudioContext': 'Đang dọn dẹp ngữ cảnh âm thanh', + 'deviceConfig.cleaningUpAudioContextFailed': 'Không thể dọn dẹp ngữ cảnh âm thanh', + 'deviceConfig.stoppedPlayingUltrasonicAudio': 'Đã dừng phát âm thanh siêu âm', + 'deviceConfig.stoppedPlaying': 'Đã dừng phát', + 'deviceConfig.configMethod': 'Phương pháp cấu hình', + 'deviceConfig.enterWifiPassword': 'Vui lòng nhập mật khẩu WiFi', + 'deviceConfig.xiaozhi': 'xiaozhi', + 'deviceConfig.connectXiaozhiHotspot': 'Vui lòng kết nối với điểm phát sóng xiaozhi', + 'deviceConfig.wifiScanResponse': 'Phản hồi quét WiFi', + 'deviceConfig.scanSuccess': 'Quét thành công', + 'deviceConfig.networks': 'mạng', + 'deviceConfig.wifiScanFailed': 'Quét WiFi thất bại', + 'deviceConfig.scanFailedCheckConnection': 'Quét thất bại, vui lòng kiểm tra kết nối', + 'deviceConfig.checking': 'Đang kiểm tra', + 'deviceConfig.reCheck': 'Kiểm tra lại', + 'deviceConfig.connectedXiaozhiHotspot': 'Đã kết nối với điểm phát sóng xiaozhi', + 'deviceConfig.wifiNetwork': 'Mạng WiFi', + 'deviceConfig.scanning': 'Đang quét', + 'deviceConfig.cancel': 'Hủy', + 'deviceConfig.clickRefreshScan': 'Vui lòng nhấp Làm mới quét', + 'deviceConfig.esp32ConnectionCheckFailed': 'Kiểm tra kết nối ESP32 thất bại', + 'deviceConfig.startWifiConfig': 'Đang bắt đầu cấu hình WiFi', + 'deviceConfig.configSuccess': 'Cấu hình thành công', + 'deviceConfig.deviceWillConnectTo': 'Thiết bị sẽ kết nối với', + 'deviceConfig.deviceWillRestart': 'Thiết bị sẽ khởi động lại', + 'deviceConfig.pleaseDisconnectXiaozhiHotspot': 'Vui lòng ngắt kết nối khỏi điểm phát sóng xiaozhi', + 'deviceConfig.configFailed': 'Cấu hình thất bại', + 'deviceConfig.wifiConfigFailed': 'Cấu hình WiFi thất bại', + 'deviceConfig.pleaseCheckNetworkConnection': 'Vui lòng kiểm tra kết nối mạng', + 'deviceConfig.startWifiConfigButton': 'Bắt đầu cấu hình', + 'deviceConfig.wifiConfigInstructions': 'Hướng dẫn cấu hình WiFi', + 'deviceConfig.phoneConnectXiaozhiHotspot': 'Điện thoại kết nối với điểm phát sóng xiaozhi', + 'deviceConfig.selectTargetWifiNetwork': 'Chọn mạng WiFi mục tiêu', + 'deviceConfig.enterWifiPasswordIfNeeded': 'Nhập mật khẩu WiFi nếu cần', + 'deviceConfig.clickStartConfigAndWait': 'Nhấp Bắt đầu cấu hình và chờ', + 'deviceConfig.afterConfigSuccessDeviceWillRestart': 'Sau khi cấu hình thành công, thiết bị sẽ tự động khởi động lại', + 'deviceConfig.audioPlaybackError': 'Lỗi phát âm thanh', + 'deviceConfig.playbackFailed': 'Phát thất bại', + + // Voiceprint page + 'voiceprint.audioNotExist': 'Âm thanh không tồn tại', + 'voiceprint.getAudioFailed': 'Không thể lấy âm thanh', + 'voiceprint.audioPlayFailed': 'Phát âm thanh thất bại', +} \ No newline at end of file diff --git a/backend/main/manager-mobile/src/i18n/zh_CN.ts b/backend/main/manager-mobile/src/i18n/zh_CN.ts new file mode 100644 index 0000000..a5dec89 --- /dev/null +++ b/backend/main/manager-mobile/src/i18n/zh_CN.ts @@ -0,0 +1,500 @@ +// 简体中文语言包 +export default { + // TabBar + 'tabBar.home': '首页', + 'tabBar.deviceConfig': '配网', + 'tabBar.settings': '系统', + // 设置页面标题 + 'settings.title': '设置', + // 登录页面 + 'login.pageTitle': '登录', + 'login.navigationTitle': '登录', + 'login.fetchConfigError': '获取配置失败:', + 'login.selectLanguage': '选择语言', + 'login.selectLanguageTip': '中文', + 'login.welcomeBack': '欢迎回来', + 'login.pleaseLogin': '请登录您的账户', + 'login.enterUsername': '请输入用户名', + 'login.enterPassword': '请输入密码', + 'login.enterCaptcha': '请输入验证码', + 'login.loginButton': '登录', + 'login.loggingIn': '登录中...', + 'login.noAccount': '新用户注册', + 'login.enterPhone': '请输入手机号码', + 'login.selectCountry': '选择国家/地区', + 'login.confirm': '确认', + 'login.serverSetting': '服务端设置', + 'login.requiredUsername': '用户名不能为空', + 'login.requiredPassword': '密码不能为空', + 'login.requiredCaptcha': '验证码不能为空', + 'login.requiredMobile': '请输入正确的手机号码', + 'login.captchaError': '图形验证码错误', + 'login.forgotPassword': '忘记密码', + 'login.userAgreement': '用户协议', + 'login.privacyPolicy': '隐私政策', + + // 注册页面 + 'register.pageTitle': '注册', + 'register.createAccount': '创建账户', + 'register.enterUsername': '请输入用户名', + 'register.enterPassword': '请输入密码', + 'register.confirmPassword': '请确认密码', + 'register.enterPhone': '请输入手机号码', + 'register.enterCode': '请输入验证码', + 'register.getCode': '获取验证码', + 'register.agreeTerms': '我已阅读并同意', + 'register.terms': '《用户协议》', + 'register.privacy': '《隐私政策》', + 'register.registerButton': '注册', + 'register.registering': '注册中...', + 'register.haveAccount': '已有账户?', + 'register.loginNow': '立即登录', + 'register.selectCountry': '选择国家/地区', + 'register.confirm': '确认', + 'register.captchaSendSuccess': '验证码发送成功', + + // 首页 + 'home.pageTitle': '首页', + 'home.createAgent': '创建智能体', + 'home.agentName': '智能体', + 'home.modelInfo': '模型信息', + 'home.lastActive': '最近活跃', + 'home.greeting': '你好,小智', + 'home.subtitle': '让我们度过', + 'home.wonderfulDay': '美好的一天!', + 'home.emptyState': '暂无智能体', + 'home.deviceManagement': '设备管理', + 'home.lastConversation': '最近对话:', + 'home.delete': '删除', + 'home.createFirstAgent': '点击右下角 + 号创建您的第一个智能体', + 'home.dialogTitle': '创建智能体', + 'home.inputPlaceholder': '例如:客服助手、语音助理、知识问答', + 'home.createError': '名称长度必须在 1 到 64 个字符之间', + 'home.createNow': '立即创建', + 'home.justNow': '刚刚', + 'home.minutesAgo': '分钟前', + 'home.hoursAgo': '小时前', + 'home.daysAgo': '天前', + 'home.languageModel': '语言模型', + 'home.voiceModel': '音色模型', + + // Agent页面 + 'agent.pageTitle': '智能体', + 'agent.roleConfig': '角色配置', + 'agent.deviceManagement': '设备管理', + 'agent.chatHistory': '聊天记录', + 'agent.voiceprintManagement': '声纹管理', + 'agent.editTitle': '编辑智能体', + 'agent.toolsTitle': '编辑功能', + 'agent.voiceActivityDetection': '语音活动检测', + 'agent.speechRecognition': '语音识别', + 'agent.largeLanguageModel': '大语言模型', + 'agent.save': '保存', + 'agent.cancel': '取消', + // Agent编辑页面 + 'agent.basicInfo': '基础信息', + 'agent.agentName': '助手昵称', + 'agent.inputAgentName': '请输入助手昵称', + 'agent.roleMode': '角色模式', + 'agent.agentTag': '智能体标签', + 'agent.addAgentTag': '添加标签', + 'agent.inputAgentTag': '请输入智能体标签', + 'agent.contextProvider': '上下文源', + 'agent.contextProviderSuccess': '已成功添加 {count} 个源。', + 'agent.contextProviderDocLink': '如何部署上下文源', + 'agent.editContextProvider': '编辑源', + 'agent.roleDescription': '角色介绍', + 'agent.inputRoleDescription': '请输入角色介绍', + 'agent.modelConfig': '模型配置', + 'agent.vad': '语音活动检测', + 'agent.asr': '语音识别', + 'agent.llm': '大语言模型', + 'agent.vllm': '视觉大模型', + 'agent.intent': '意图识别', + 'agent.memory': '记忆', + 'agent.voiceSettings': '语音设置', + 'agent.tts': '语音合成', + 'agent.voiceprint': '角色音色', + 'agent.plugins': '插件', + 'agent.editFunctions': '编辑功能', + 'agent.historyMemory': '历史记忆', + 'agent.memoryContent': '记忆内容', + 'agent.saving': '保存中...', + 'agent.saveSuccess': '保存成功', + 'agent.saveFail': '保存失败', + 'agent.loadFail': '加载失败', + 'agent.pleaseInputAgentName': '请输入智能体名称', + 'agent.pleaseInputRoleDescription': '请输入角色介绍', + 'agent.pleaseSelect': '请选择', + 'agent.reportText': '上报文字', + 'agent.reportTextVoice': '上报文字+语音', + 'agent.reportMode': '上报模式', + 'agent.language': '对话语言', + 'agent.languageConfig': '语速音调', + 'agent.ttsVolume': '音量', + 'agent.ttsRate': '语速', + 'agent.ttsPitch': '音调', + 'agent.volumeHint': '-100=最小, 0=标准, 100=最大', + 'agent.speedHint': '-100=最慢, 0=标准, 100=最快', + 'agent.pitchHint': '-100=最低, 0=标准, 100=最高', + + // 上下文源对话框相关 + 'contextProviderDialog.title': '编辑源', + 'contextProviderDialog.noContextApi': '暂无上下文API', + 'contextProviderDialog.add': '添加', + 'contextProviderDialog.apiUrl': '接口地址', + 'contextProviderDialog.apiUrlPlaceholder': 'http://api.example.com/data', + 'contextProviderDialog.requestHeaders': '请求头', + 'contextProviderDialog.headerKeyPlaceholder': 'Key', + 'contextProviderDialog.headerValuePlaceholder': 'Value', + 'contextProviderDialog.noHeaders': '暂无 Headers', + 'contextProviderDialog.addHeader': '添加 Header', + 'contextProviderDialog.cancel': '取消', + 'contextProviderDialog.confirm': '确定', + + // 手動添加設備對話框相關 + 'manualAddDeviceDialog.title': '手动添加设备', + 'manualAddDeviceDialog.deviceType': '设备型号', + 'manualAddDeviceDialog.deviceTypePlaceholder': '请选择设备型号', + 'manualAddDeviceDialog.firmwareVersion': '固件版本', + 'manualAddDeviceDialog.firmwareVersionPlaceholder': '请输入固件版本', + 'manualAddDeviceDialog.macAddress': 'Mac地址', + 'manualAddDeviceDialog.macAddressPlaceholder': '请输入Mac地址', + 'manualAddDeviceDialog.confirm': '确定', + 'manualAddDeviceDialog.cancel': '取消', + 'manualAddDeviceDialog.requiredMacAddress': '请输入Mac地址', + 'manualAddDeviceDialog.invalidMacAddress': '请输入正确的Mac地址格式,例如:00:1A:2B:3C:4D:5E', + 'manualAddDeviceDialog.requiredDeviceType': '请选择设备型号', + 'manualAddDeviceDialog.requiredFirmwareVersion': '请输入固件版本', + 'manualAddDeviceDialog.getFirmwareTypeFailed': '获取固件类型失败', + 'manualAddDeviceDialog.addSuccess': '设备添加成功', + 'manualAddDeviceDialog.addFailed': '添加失败', + 'manualAddDeviceDialog.bindWithCode': '6位验证码绑定', + + // 聊天历史页面 + 'chatHistory.getChatSessions': '获取聊天会话列表', + 'chatHistory.noSelectedAgent': '没有选中的智能体', + 'chatHistory.getChatSessionsFailed': '获取聊天会话列表失败:', + 'chatHistory.unknownTime': '未知时间', + 'chatHistory.justNow': '刚刚', + 'chatHistory.minutesAgo': '{minutes}分钟前', + 'chatHistory.hoursAgo': '{hours}小时前', + 'chatHistory.daysAgo': '{days}天前', + 'chatHistory.conversationRecord': '对话记录', + 'chatHistory.totalChats': '共 {count} 条对话', + 'chatHistory.loading': '加载中...', + 'chatHistory.noMoreData': '没有更多数据了', + 'chatHistory.noChatRecords': '暂无聊天记录', + 'chatHistory.chatRecordsDescription': '与智能体的对话记录会显示在这里', + // 聊天详情页面 + 'chatHistory.pageTitle': '聊天详情', + 'chatHistory.assistantName': '智能助手', + 'chatHistory.userName': '用户', + 'chatHistory.aiAssistantName': 'AI助手', + 'chatHistory.loadFailed': '获取聊天记录失败', + 'chatHistory.parameterError': '页面参数错误', + 'chatHistory.invalidAudioId': '音频ID无效', + 'chatHistory.audioPlayFailed': '音频播放失败', + 'chatHistory.playAudioFailed': '播放音频失败', + + // 设备管理页面 + 'device.pageTitle': '设备管理', + 'device.noDevices': '暂无设备', + 'device.macAddress': 'MAC地址', + 'device.firmwareVersion': '固件版本', + 'device.lastConnected': '最近对话', + 'device.otaUpdate': 'OTA升级', + 'device.unbind': '解绑', + 'device.confirmUnbind': '确定要解绑设备', + 'device.bindDevice': '绑定新设备', + 'device.deviceType': '设备类型', + 'device.loading': '加载中...', + 'device.neverConnected': '从未连接', + 'device.justNow': '刚刚', + 'device.minutesAgo': '{minutes}分钟前', + 'device.hoursAgo': '{hours}小时前', + 'device.daysAgo': '{days}天前', + 'device.otaAutoUpdateEnabled': 'OTA自动升级已开启', + 'device.otaAutoUpdateDisabled': 'OTA自动升级已关闭', + 'device.operationFailed': '操作失败,请重试', + 'device.deviceUnbound': '设备已解绑', + 'device.unbindFailed': '解绑失败,请重试', + 'device.unbindDevice': '解绑设备', + 'device.confirmUnbindDevice': '确定要解绑设备 "{macAddress}" 吗?', + 'device.cancel': '取消', + 'device.noDevice': '暂无设备', + 'device.pleaseSelectAgent': '请先选择智能体', + 'device.deviceBindSuccess': '设备绑定成功!', + 'device.bindFailed': '绑定失败,请检查验证码是否正确', + 'device.enterDeviceCode': '请输入设备验证码', + 'device.bindNow': '立即绑定', + 'device.lastConnection': '最近对话', + 'device.clickToBindFirstDevice': '点击右下角 + 号绑定您的第一个设备', + + // 通用 + 'common.success': '成功', + 'common.fail': '失败', + 'common.loading': '加载中...', + 'common.confirm': '确认', + 'common.cancel': '取消', + 'common.delete': '删除', + 'common.edit': '编辑', + 'common.add': '添加', + 'common.pleaseSelect': '请选择', + 'common.unknownError': '未知错误', + 'common.networkError': '网络错误', + + // SM2加密相关错误消息 + 'sm2.publicKeyNotConfigured': 'SM2公钥未配置,请联系管理员', + 'sm2.encryptionFailed': '密码加密失败', + 'sm2.keyGenerationFailed': '密钥对生成失败', + 'sm2.invalidPublicKey': '无效的公钥格式', + 'sm2.encryptionError': '加密过程中发生错误', + 'sm2.publicKeyRetry': '正在重试获取公钥...', + 'sm2.publicKeyRetryFailed': '公钥获取重试失败', + + // Voiceprint page + 'voiceprint.noSelectedAgent': '没有选中的智能体', + 'voiceprint.pleaseSelectAgent': '请先选择智能体', + 'voiceprint.fetchHistoryFailed': '获取对话记录失败', + 'voiceprint.clickToSelectVector': '点击选择声纹向量', + 'voiceprint.pleaseInputName': '请输入姓名', + 'voiceprint.pleaseSelectVector': '请选择声纹向量', + 'voiceprint.addSuccess': '添加成功', + 'voiceprint.addFailed': '添加说话人失败', + 'voiceprint.editSuccess': '编辑成功', + 'voiceprint.editFailed': '编辑说话人失败', + 'voiceprint.deleteConfirmMsg': '确定要删除这个说话人吗?', + 'voiceprint.deleteConfirmTitle': '确认删除', + 'voiceprint.deleteSuccess': '删除成功', + 'voiceprint.loading': '加载中...', + 'voiceprint.delete': '删除', + 'voiceprint.emptyTitle': '暂无声纹数据', + 'voiceprint.emptyDesc': '点击右下角 + 号添加您的第一个说话人', + 'voiceprint.addSpeaker': '添加说话人', + 'voiceprint.voiceVector': '声纹向量', + 'voiceprint.name': '姓名', + 'voiceprint.description': '描述', + 'voiceprint.pleaseInputDescription': '请输入描述', + 'voiceprint.cancel': '取消', + 'voiceprint.save': '保存', + 'voiceprint.editSpeaker': '编辑说话人', + 'voiceprint.selectVector': '选择声纹向量', + 'voiceprint.voiceprintInterfaceNotConfigured': '声纹接口未配置', + + // 设置页面 + 'settings.pageTitle': '设置', + 'settings.navigationTitle': '设置', + 'settings.networkSettings': '网络设置', + 'settings.serverApiUrl': '服务端接口地址', + 'settings.validServerUrl': '请输入有效的服务端地址(以 http 或 https 开头,并以 /xiaozhi 结尾)', + 'settings.saveSettings': '保存设置', + 'settings.resetDefault': '恢复默认', + 'settings.restartApp': '重启应用', + 'settings.restartNow': '立即重启', + 'settings.restartLater': '稍后', + // 关于我们 + 'settings.aboutApp': '关于小智智控台', + 'settings.aboutContent': '小智智控台\n\n基于 Vue.js 3 + uni-app 构建的跨平台移动端管理应用,为小智ESP32智能硬件提供设备管理、智能体配置等功能。\n\n© 2025 xiaozhi-esp32-server {version}', + 'settings.restartSuccess': '已保存,可稍后手动重启应用', + 'settings.serverUrlSavedAndCacheCleared': '服务端地址已保存,缓存已清除', + 'settings.resetToDefaultAndCacheCleared': '已恢复默认设置,缓存已清除', + 'settings.resetSuccess': '重置成功', + 'settings.enterServerUrl': '请输入服务端地址', + 'settings.clearCacheFailed': '清除缓存失败', + 'settings.cacheManagement': '缓存管理', + 'settings.totalCacheSize': '总缓存大小', + 'settings.appDataSize': '应用数据总大小', + 'settings.cacheClear': '缓存清理', + 'settings.clearAllCache': '清空所有缓存数据', + 'settings.clearCache': '清除缓存', + 'settings.modifyWillClearCache': '修改将清除缓存', + 'settings.appInfo': '应用信息', + 'settings.aboutUs': '关于我们', + 'settings.appVersion': '应用版本与团队信息', + 'settings.confirmClear': '确认清除', + 'settings.confirmClearMessage': '确定要清除所有缓存吗?这将删除所有数据包括登录状态,需要重新登录。', + 'settings.cacheCleared': '缓存清除成功,即将跳转到登录页', + 'settings.languageSettings': '语言设置', + 'settings.language': '语言', + 'settings.selectLanguage': '选择语言', + 'settings.languageChanged': '语言切换成功', + + // 重置密码页面 + 'retrievePassword.title': '重置密码', + 'retrievePassword.subtitle': '通过手机号找回您的账户密码', + 'retrievePassword.mobileRequired': '请输入手机号码', + 'retrievePassword.inputCorrectMobile': '请输入正确的手机号码', + 'retrievePassword.captchaRequired': '请输入图形验证码', + 'retrievePassword.mobileCaptchaRequired': '请输入短信验证码', + 'retrievePassword.newPasswordRequired': '请输入新密码', + 'retrievePassword.confirmNewPasswordRequired': '请确认新密码', + 'retrievePassword.passwordsNotMatch': '两次输入的密码不一致', + 'retrievePassword.mobilePlaceholder': '请输入手机号码', + 'retrievePassword.captchaPlaceholder': '请输入图形验证码', + 'retrievePassword.mobileCaptchaPlaceholder': '请输入短信验证码', + 'retrievePassword.newPasswordPlaceholder': '请输入新密码', + 'retrievePassword.confirmNewPasswordPlaceholder': '请确认新密码', + 'retrievePassword.getMobileCaptcha': '获取验证码', + 'retrievePassword.captchaSendSuccess': '验证码发送成功', + 'retrievePassword.passwordUpdateSuccess': '密码重置成功', + 'retrievePassword.resetButton': '重置密码', + 'retrievePassword.goToLogin': '返回登录', + + // 消息提示 + 'message.loginSuccess': '登录成功!', + 'message.loginFail': '登录失败', + 'message.registerSuccess': '注册成功', + 'message.registerFail': '注册失败', + 'message.saveSuccess': '保存成功', + 'message.saveFail': '保存失败', + 'message.deleteSuccess': '删除成功', + 'message.deleteFail': '删除失败', + 'message.bindSuccess': '绑定成功', + 'message.bindFail': '绑定失败', + 'message.unbindSuccess': '解绑成功', + 'message.unbindFail': '解绑失败', + 'message.networkError': '网络错误,请检查网络连接', + 'message.serverError': '服务器错误,请稍后再试', + 'message.invalidAddress': '地址可能无效,请检查服务端是否启动或网络连接是否正常;也可能因 HTTPS 协议问题导致无法发送请求', + 'message.languageChanged': '语言已切换', + 'message.passwordError': '账号或密码错误', + 'message.phoneRegistered': '此手机号码已经注册过', + + // Agent工具页面 + 'agent.tools.pageTitle': 'Agent工具', + 'agent.tools.unselected': '未选', + 'agent.tools.selected': '已选', + 'agent.tools.noMorePlugins': '暂无更多插件', + 'agent.tools.pleaseSelectPlugin': '请选择插件功能', + 'agent.tools.builtInPlugins': '内置插件', + 'agent.tools.mcpAccessPoint': 'mcp接入点', + 'agent.tools.copy': '复制', + 'agent.tools.noTools': '暂无工具', + 'agent.tools.parameterConfig': '参数配置', + 'agent.tools.noParamsNeeded': '无需配置参数', + 'agent.tools.pleaseInput': '请输入', + 'agent.tools.inputOneItemPerLine': '每行输入一个项目', + 'agent.tools.pleaseInputValidJson': '请输入有效的JSON格式', + 'agent.tools.enableFunction': '启用功能', + 'agent.tools.toggleFunction': '开启或关闭此功能', + 'agent.tools.jsonFormatError': 'JSON格式错误', + 'agent.tools.noMcpAddressToCopy': '暂无MCP地址可复制', + 'agent.tools.mcpAddressCopied': 'MCP地址已复制到剪贴板', + 'agent.tools.copyFailed': '复制失败,请重试', + 'agent.tools.defaultValue': '默认值', + 'agent.tools.notSelected': '未选', + 'agent.tools.clickToConfigure': '点击配置', + 'agent.tools.mcpEndpoint': 'MCP接入点', + 'agent.tools.eachLineOneItem': '每行输入一个项目', + + // 设备配置页面 + 'deviceConfig.pageTitle': '设备配置', + 'deviceConfig.wifiConfig': 'WiFi配网', + 'deviceConfig.ultrasonicConfig': '超声波配网', + 'deviceConfig.selectConfigMethod': '选择配网方式', + 'deviceConfig.networkConfig': '网络配置', + 'deviceConfig.selectedNetwork': '选中网络', + 'deviceConfig.signal': '信号', + 'deviceConfig.openNetwork': '开放网络', + 'deviceConfig.encryptedNetwork': '加密网络', + 'deviceConfig.password': '密码', + 'deviceConfig.pleaseEnterPassword': '请输入WiFi密码', + 'deviceConfig.startConfig': '开始配网', + 'deviceConfig.connectToXiaozhiHotspot': '请先连接xiaozhi热点 (xiaozhi-XXXXXX)', + 'deviceConfig.detecting': '检测中...', + 'deviceConfig.reDetect': '重新检测', + 'deviceConfig.alreadyConnected': '已连接xiaozhi热点', + 'deviceConfig.refreshStatus': '刷新状态', + 'deviceConfig.wifiNetworks': 'WiFi网络', + 'deviceConfig.selectWifiNetwork': '选择WiFi网络', + 'deviceConfig.refreshScan': '刷新扫描', + 'deviceConfig.noWifiNetworks': '暂无WiFi网络', + 'deviceConfig.clickToRefreshScan': '请点击刷新扫描', + 'deviceConfig.signalStrong': '信号强', + 'deviceConfig.signalGood': '信号良好', + 'deviceConfig.signalFair': '信号一般', + 'deviceConfig.signalWeak': '信号弱', + 'deviceConfig.channel': '频道', + 'deviceConfig.about': '约', + 'deviceConfig.seconds': '秒', + 'deviceConfig.generating': '生成中...', + 'deviceConfig.playing': '播放中...', + 'deviceConfig.generateAndPlaySoundWave': '生成并播放声波', + 'deviceConfig.playSoundWave': '播放声波', + 'deviceConfig.stopPlaying': '停止播放', + 'deviceConfig.autoLoopPlaySoundWave': '自动循环播放声波', + 'deviceConfig.configAudioFile': '配网音频文件', + 'deviceConfig.duration': '时长', + 'deviceConfig.ultrasonicConfigInstructions': '超声波配网说明', + 'deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered': '确保已选择WiFi网络并输入密码', + 'deviceConfig.clickGenerateAndPlaySoundWave': '点击生成并播放声波,系统会将配网信息编码为音频', + 'deviceConfig.bringPhoneCloseToXiaozhiDevice': '将手机靠近xiaozhi设备(距离1-2米)', + 'deviceConfig.duringAudioPlaybackXiaozhiWillReceive': '音频播放时,xiaozhi会接收并解码配网信息', + 'deviceConfig.afterConfigSuccessDeviceWillConnect': '配网成功后设备会自动连接WiFi网络', + 'deviceConfig.usesAfskModulation': '使用AFSK调制技术,通过1800Hz和1500Hz频率传输数据', + 'deviceConfig.ensureModeratePhoneVolume': '请确保手机音量适中,避免环境噪音干扰', + 'deviceConfig.generatingUltrasonicConfigAudio': '生成超声波配网音频', + 'deviceConfig.configData': '配网数据', + 'deviceConfig.dataBytesLength': '数据字节长度', + 'deviceConfig.bitStreamLength': '比特流长度', + 'deviceConfig.base64Length': 'base64长度', + 'deviceConfig.audioFileTooLarge': '音频文件过大,请缩短SSID或密码长度', + 'deviceConfig.audioGenerationSuccess': '音频生成成功', + 'deviceConfig.samplePoints': '采样点数', + 'deviceConfig.soundWaveGenerationSuccess': '声波生成成功', + 'deviceConfig.audioGenerationFailed': '音频生成失败', + 'deviceConfig.soundWaveGenerationFailed': '声波生成失败', + 'deviceConfig.pleaseGenerateAudioFirst': '请先生成音频', + 'deviceConfig.startPlayingUltrasonicConfigAudio': '开始播放超声波配网音频', + 'deviceConfig.ultrasonicAudioStartedPlaying': '超声波音频开始播放', + 'deviceConfig.startPlayingConfigSoundWave': '开始播放配网声波', + 'deviceConfig.ultrasonicAudioPlaybackEnded': '超声波音频播放结束', + 'deviceConfig.audioPlaybackFailed': '音频播放失败', + 'deviceConfig.audioResourceBusy': '音频资源繁忙,请稍后重试', + 'deviceConfig.audioFormatNotSupported': '音频格式不支持,可能是data URI问题', + 'deviceConfig.audioFileError': '音频文件错误', + 'deviceConfig.cleaningUpAudioContext': '清理音频上下文', + 'deviceConfig.cleaningUpAudioContextFailed': '清理音频上下文失败', + 'deviceConfig.stoppedPlayingUltrasonicAudio': '停止播放超声波音频', + 'deviceConfig.stoppedPlaying': '已停止播放', + 'deviceConfig.configMethod': '配网方式', + 'deviceConfig.enterWifiPassword': '请输入WiFi密码', + 'deviceConfig.xiaozhi': 'xiaozhi', + 'deviceConfig.connectXiaozhiHotspot': '请连接xiaozhi热点', + 'deviceConfig.wifiScanResponse': 'WiFi扫描响应', + 'deviceConfig.scanSuccess': '扫描成功', + 'deviceConfig.networks': '个网络', + 'deviceConfig.wifiScanFailed': 'WiFi扫描失败', + 'deviceConfig.scanFailedCheckConnection': '扫描失败,请检查连接', + 'deviceConfig.checking': '检查中', + 'deviceConfig.reCheck': '重新检查', + 'deviceConfig.connectedXiaozhiHotspot': '已连接xiaozhi热点', + 'deviceConfig.wifiNetwork': 'WiFi网络', + 'deviceConfig.scanning': '扫描中', + 'deviceConfig.cancel': '取消', + 'deviceConfig.clickRefreshScan': '请点击刷新扫描', + 'deviceConfig.esp32ConnectionCheckFailed': 'ESP32连接检查失败', + 'deviceConfig.startWifiConfig': '开始WiFi配网', + 'deviceConfig.configSuccess': '配网成功', + 'deviceConfig.deviceWillConnectTo': '设备将连接到', + 'deviceConfig.deviceWillRestart': '设备将重启', + 'deviceConfig.pleaseDisconnectXiaozhiHotspot': '请断开xiaozhi热点连接', + 'deviceConfig.configFailed': '配网失败', + 'deviceConfig.wifiConfigFailed': 'WiFi配网失败', + 'deviceConfig.pleaseCheckNetworkConnection': '请检查网络连接', + 'deviceConfig.startWifiConfigButton': '开始配网', + 'deviceConfig.wifiConfigInstructions': 'WiFi配网说明', + 'deviceConfig.phoneConnectXiaozhiHotspot': '手机连接xiaozhi热点', + 'deviceConfig.selectTargetWifiNetwork': '选择目标WiFi网络', + 'deviceConfig.enterWifiPasswordIfNeeded': '如有需要请输入WiFi密码', + 'deviceConfig.clickStartConfigAndWait': '点击开始配网并等待', + 'deviceConfig.afterConfigSuccessDeviceWillRestart': '配网成功后设备将自动重启', + 'deviceConfig.audioPlaybackError': '音频播放错误', + 'deviceConfig.playbackFailed': '播放失败', + + // Voiceprint page + 'voiceprint.audioNotExist': '该音频不存在', + 'voiceprint.getAudioFailed': '获取音频失败', + 'voiceprint.audioPlayFailed': '音频播放失败', +} diff --git a/backend/main/manager-mobile/src/i18n/zh_TW.ts b/backend/main/manager-mobile/src/i18n/zh_TW.ts new file mode 100644 index 0000000..9125e29 --- /dev/null +++ b/backend/main/manager-mobile/src/i18n/zh_TW.ts @@ -0,0 +1,500 @@ +// 繁體中文語言包 +export default { + // TabBar + 'tabBar.home': '首頁', + 'tabBar.deviceConfig': '配網', + 'tabBar.settings': '系統', + // 設置頁面標題 + 'settings.title': '設置', + // 登錄頁面 + 'login.pageTitle': '登錄', + 'login.navigationTitle': '登錄', + 'login.fetchConfigError': '獲取配置失敗:', + 'login.selectLanguage': '選擇語言', + 'login.selectLanguageTip': '繁體', + 'login.welcomeBack': '歡迎回來', + 'login.pleaseLogin': '請登錄您的賬戶', + 'login.enterUsername': '請輸入用戶名', + 'login.enterPassword': '請輸入密碼', + 'login.enterCaptcha': '請輸入驗證碼', + 'login.loginButton': '登錄', + 'login.loggingIn': '登錄中...', + 'login.noAccount': '新用戶註冊', + 'login.enterPhone': '請輸入手機號碼', + 'login.selectCountry': '選擇國家/地區', + 'login.confirm': '確認', + 'login.serverSetting': '服務端設置', + 'login.requiredUsername': '用戶名不能為空', + 'login.requiredPassword': '密碼不能為空', + 'login.requiredCaptcha': '驗證碼不能為空', + 'login.requiredMobile': '請輸入正確的手機號碼', + 'login.captchaError': '圖形驗證碼錯誤', + 'login.forgotPassword': '忘記密碼', + 'login.userAgreement': '用戶協議', + 'login.privacyPolicy': '隱私政策', + + // 忘記密碼頁面 + 'retrievePassword.title': '重置密碼', + 'retrievePassword.subtitle': '請輸入您的手機號碼以重置密碼', + 'retrievePassword.mobileRequired': '請輸入手機號碼', + 'retrievePassword.inputCorrectMobile': '請輸入正確的手機號碼', + 'retrievePassword.captchaRequired': '請輸入圖形驗證碼', + 'retrievePassword.mobileCaptchaRequired': '請輸入手機驗證碼', + 'retrievePassword.newPasswordRequired': '請輸入新密碼', + 'retrievePassword.confirmNewPasswordRequired': '請確認新密碼', + 'retrievePassword.passwordsNotMatch': '兩次輸入的密碼不一致', + 'retrievePassword.mobilePlaceholder': '請輸入手機號碼', + 'retrievePassword.captchaPlaceholder': '請輸入圖形驗證碼', + 'retrievePassword.mobileCaptchaPlaceholder': '請輸入手機驗證碼', + 'retrievePassword.newPasswordPlaceholder': '請輸入新密碼', + 'retrievePassword.confirmNewPasswordPlaceholder': '請確認新密碼', + 'retrievePassword.getMobileCaptcha': '獲取驗證碼', + 'retrievePassword.captchaSendSuccess': '驗證碼發送成功', + 'retrievePassword.passwordUpdateSuccess': '密碼重置成功', + 'retrievePassword.resetButton': '重置密碼', + 'retrievePassword.goToLogin': '返回登錄', + + // 註冊頁面 + 'register.pageTitle': '註冊', + 'register.createAccount': '創建賬戶', + 'register.enterUsername': '請輸入用戶名', + 'register.enterPassword': '請輸入密碼', + 'register.confirmPassword': '請確認密碼', + 'register.enterPhone': '請輸入手機號碼', + 'register.enterCode': '請輸入驗證碼', + 'register.getCode': '獲取驗證碼', + 'register.agreeTerms': '我已閱讀並同意', + 'register.terms': '《用戶協議》', + 'register.privacy': '《隱私政策》', + 'register.registerButton': '註冊', + 'register.registering': '註冊中...', + 'register.haveAccount': '已有賬戶?', + 'register.loginNow': '立即登錄', + 'register.selectCountry': '選擇國家/地區', + 'register.confirm': '確認', + 'register.captchaSendSuccess': '驗證碼發送成功', + + // 首頁 + 'home.pageTitle': '首頁', + 'home.createAgent': '創建智能體', + 'home.agentName': '智能體', + 'home.modelInfo': '模型信息', + 'home.lastActive': '最近活躍', + 'home.greeting': '你好,小智', + 'home.subtitle': '讓我們度過', + 'home.wonderfulDay': '美好的一天!', + 'home.emptyState': '暫無智能體', + 'home.deviceManagement': '設備管理', + 'home.lastConversation': '最近對話:', + 'home.delete': '刪除', + 'home.createFirstAgent': '點擊右下角 + 號創建您的第一個智能體', + 'home.dialogTitle': '創建智能體', + 'home.inputPlaceholder': '例如:客服助手、語音助理、知識問答', + 'home.createError': '暱稱長度必須在 1 到 64 個字元之間。', + 'home.createNow': '立即創建', + 'home.justNow': '剛剛', + 'home.minutesAgo': '分鐘前', + 'home.hoursAgo': '小時前', + 'home.daysAgo': '天前', + 'home.languageModel': '語言模型', + 'home.voiceModel': '音色模型', + + // Agent頁面 + 'agent.pageTitle': '智能體', + 'agent.roleConfig': '角色配置', + 'agent.deviceManagement': '設備管理', + 'agent.chatHistory': '聊天記錄', + 'agent.voiceprintManagement': '聲紋管理', + 'agent.editTitle': '編輯智能體', + 'agent.toolsTitle': '編輯功能', + 'agent.voiceActivityDetection': '語音活動檢測', + 'agent.speechRecognition': '語音識別', + 'agent.largeLanguageModel': '大語言模型', + 'agent.save': '保存', + 'agent.cancel': '取消', + // Agent編輯頁面 + 'agent.basicInfo': '基礎資訊', + 'agent.agentName': '助手暱稱', + 'agent.inputAgentName': '請輸入助手暱稱', + 'agent.roleMode': '角色模式', + 'agent.agentTag': '智慧體標籤', + 'agent.addAgentTag': '添加標籤', + 'agent.inputAgentTag': '請輸入智慧體標籤', + 'agent.contextProvider': '上下文源', + 'agent.contextProviderSuccess': '已成功添加 {count} 個源。', + 'agent.contextProviderDocLink': '如何部署上下文源', + 'agent.editContextProvider': '編輯源', + 'agent.roleDescription': '角色介紹', + 'agent.inputRoleDescription': '請輸入角色介紹', + 'agent.modelConfig': '模型配置', + 'agent.vad': '語音活動檢測', + 'agent.asr': '語音識別', + 'agent.llm': '大語言模型', + 'agent.vllm': '視覺大模型', + 'agent.intent': '意圖識別', + 'agent.memory': '記憶', + 'agent.voiceSettings': '語音設置', + 'agent.tts': '語音合成', + 'agent.voiceprint': '角色音色', + 'agent.plugins': '外掛', + 'agent.editFunctions': '編輯功能', + 'agent.historyMemory': '歷史記憶', + 'agent.memoryContent': '記憶內容', + 'agent.saving': '儲存中...', + 'agent.saveSuccess': '儲存成功', + 'agent.saveFail': '儲存失敗', + 'agent.loadFail': '加載失敗', + 'agent.pleaseInputAgentName': '請輸入助手暱稱', + 'agent.pleaseInputRoleDescription': '請輸入角色介紹', + 'agent.pleaseSelect': '請選擇', + 'agent.reportText': '上报文字', + 'agent.reportTextVoice': '上报文字+语音', + 'agent.reportMode': '上報模式', + 'agent.language': '對話語言', + 'agent.languageConfig': '語速音調', + 'agent.ttsVolume': '音量', + 'agent.ttsRate': '語速', + 'agent.ttsPitch': '音調', + 'agent.volumeHint': '-100=最小, 0=標準, 100=最大', + 'agent.speedHint': '-100=最慢, 0=標準, 100=最快', + 'agent.pitchHint': '-100=最低, 0=標準, 100=最高', + + // 上下文源对话框相关 + 'contextProviderDialog.title': '編輯源', + 'contextProviderDialog.noContextApi': '暫無上下文API', + 'contextProviderDialog.add': '添加', + 'contextProviderDialog.apiUrl': '介面地址', + 'contextProviderDialog.apiUrlPlaceholder': 'http://api.example.com/data', + 'contextProviderDialog.requestHeaders': '請求頭', + 'contextProviderDialog.headerKeyPlaceholder': 'Key', + 'contextProviderDialog.headerValuePlaceholder': 'Value', + 'contextProviderDialog.noHeaders': '暫無 Headers', + 'contextProviderDialog.addHeader': '添加 Header', + 'contextProviderDialog.cancel': '取消', + 'contextProviderDialog.confirm': '確定', + + // 手動添加設備對話框相關 + 'manualAddDeviceDialog.title': '手動添加設備', + 'manualAddDeviceDialog.deviceType': '設備型號', + 'manualAddDeviceDialog.deviceTypePlaceholder': '請選擇設備型號', + 'manualAddDeviceDialog.firmwareVersion': '固件版本', + 'manualAddDeviceDialog.firmwareVersionPlaceholder': '請輸入固件版本', + 'manualAddDeviceDialog.macAddress': 'Mac地址', + 'manualAddDeviceDialog.macAddressPlaceholder': '請輸入Mac地址', + 'manualAddDeviceDialog.confirm': '確定', + 'manualAddDeviceDialog.cancel': '取消', + 'manualAddDeviceDialog.requiredMacAddress': '請輸入Mac地址', + 'manualAddDeviceDialog.invalidMacAddress': '請輸入正確的Mac地址格式,例如:00:1A:2B:3C:4D:5E', + 'manualAddDeviceDialog.requiredDeviceType': '請選擇設備型號', + 'manualAddDeviceDialog.requiredFirmwareVersion': '請輸入固件版本', + 'manualAddDeviceDialog.getFirmwareTypeFailed': '獲取固件類型失敗', + 'manualAddDeviceDialog.addSuccess': '設備添加成功', + 'manualAddDeviceDialog.addFailed': '添加失敗', + 'manualAddDeviceDialog.bindWithCode': '6位驗證碼綁定', + + // 聊天歷史頁面 + 'chatHistory.getChatSessions': '獲取聊天會話列表', + 'chatHistory.noSelectedAgent': '沒有選中的智能體', + 'chatHistory.getChatSessionsFailed': '獲取聊天會話列表失敗:', + 'chatHistory.unknownTime': '未知時間', + 'chatHistory.justNow': '剛剛', + 'chatHistory.minutesAgo': '{minutes}分鐘前', + 'chatHistory.hoursAgo': '{hours}小時前', + 'chatHistory.daysAgo': '{days}天前', + 'chatHistory.conversationRecord': '對話記錄', + 'chatHistory.totalChats': '共 {count} 條對話', + 'chatHistory.loading': '加載中...', + 'chatHistory.noMoreData': '沒有更多數據了', + 'chatHistory.noChatRecords': '暫無聊天記錄', + 'chatHistory.chatRecordsDescription': '與智能體的對話記錄會顯示在這裡', + // 聊天詳情頁面 + 'chatHistory.pageTitle': '聊天詳情', + 'chatHistory.assistantName': '智能助手', + 'chatHistory.userName': '用戶', + 'chatHistory.aiAssistantName': 'AI助手', + 'chatHistory.loadFailed': '獲取聊天記錄失敗', + 'chatHistory.parameterError': '頁面參數錯誤', + 'chatHistory.invalidAudioId': '音頻ID無效', + 'chatHistory.audioPlayFailed': '音頻播放失敗', + 'chatHistory.playAudioFailed': '播放音頻失敗', + + // 設備管理頁面 + 'device.pageTitle': '設備管理', + 'device.noDevices': '暫無設備', + 'device.macAddress': 'MAC地址', + 'device.firmwareVersion': '固件版本', + 'device.lastConnected': '最近對話', + 'device.otaUpdate': 'OTA升級', + 'device.unbind': '解除綁定', + 'device.confirmUnbind': '確定要解綁設備', + 'device.bindDevice': '綁定新設備', + 'device.deviceType': '設備類型', + 'device.loading': '加載中...', + 'device.neverConnected': '從未連接', + 'device.justNow': '剛剛', + 'device.minutesAgo': '{minutes}分鐘前', + 'device.hoursAgo': '{hours}小時前', + 'device.daysAgo': '{days}天前', + 'device.otaAutoUpdateEnabled': 'OTA自動升級已開啟', + 'device.otaAutoUpdateDisabled': 'OTA自動升級已關閉', + 'device.operationFailed': '操作失敗,請重試', + 'device.deviceUnbound': '設備已解除綁定', + 'device.unbindFailed': '解除綁定失敗,請重試', + 'device.unbindDevice': '解除綁定設備', + 'device.confirmUnbindDevice': '確定要解除綁定設備 "{macAddress}" 嗎?', + 'device.cancel': '取消', + 'device.noDevice': '暫無設備', + 'device.pleaseSelectAgent': '請先選擇智能體', + 'device.deviceBindSuccess': '設備綁定成功!', + 'device.bindFailed': '綁定失敗,請檢查驗證碼是否正確', + 'device.enterDeviceCode': '請輸入設備驗證碼', + 'device.bindNow': '立即綁定', + 'device.lastConnection': '最近對話', + 'device.clickToBindFirstDevice': '點擊右下角 + 號綁定您的第一個設備', + + // 通用 + 'common.success': '成功', + 'common.fail': '失敗', + 'common.loading': '加載中...', + 'common.confirm': '確認', + 'common.cancel': '取消', + 'common.delete': '刪除', + 'common.edit': '編輯', + 'common.add': '添加', + 'common.pleaseSelect': '請選擇', + 'common.unknownError': '未知錯誤', + 'common.networkError': '網路錯誤', + + // SM2加密相關錯誤消息 + 'sm2.publicKeyNotConfigured': 'SM2公鑰未配置,請聯繫管理員', + 'sm2.encryptionFailed': '密碼加密失敗', + 'sm2.keyGenerationFailed': '金鑰對生成失敗', + 'sm2.invalidPublicKey': '無效的公鑰格式', + 'sm2.encryptionError': '加密過程中發生錯誤', + 'sm2.publicKeyRetry': '正在重試獲取公鑰...', + 'sm2.publicKeyRetryFailed': '公鑰獲取重試失敗', + + // Voiceprint page + 'voiceprint.noSelectedAgent': '沒有選中的智能體', + 'voiceprint.pleaseSelectAgent': '請先選擇智能體', + 'voiceprint.fetchHistoryFailed': '獲取對話記錄失敗', + 'voiceprint.clickToSelectVector': '點擊選擇聲紋向量', + 'voiceprint.pleaseInputName': '請輸入姓名', + 'voiceprint.pleaseSelectVector': '請選擇聲紋向量', + 'voiceprint.addSuccess': '添加成功', + 'voiceprint.addFailed': '添加說話人失敗', + 'voiceprint.editSuccess': '編輯成功', + 'voiceprint.editFailed': '編輯說話人失敗', + 'voiceprint.deleteConfirmMsg': '確定要刪除這個說話人嗎?', + 'voiceprint.deleteConfirmTitle': '確認刪除', + 'voiceprint.deleteSuccess': '刪除成功', + 'voiceprint.loading': '加載中...', + 'voiceprint.delete': '刪除', + 'voiceprint.emptyTitle': '暫無聲紋數據', + 'voiceprint.emptyDesc': '點擊右下角 + 號添加您的第一個說話人', + 'voiceprint.addSpeaker': '添加說話人', + 'voiceprint.voiceVector': '聲紋向量', + 'voiceprint.name': '姓名', + 'voiceprint.description': '描述', + 'voiceprint.pleaseInputDescription': '請輸入描述', + 'voiceprint.cancel': '取消', + 'voiceprint.save': '保存', + 'voiceprint.editSpeaker': '編輯說話人', + 'voiceprint.selectVector': '選擇聲紋向量', + 'voiceprint.voiceprintInterfaceNotConfigured': '聲紋接口未配置', + + // 設置頁面 + 'settings.pageTitle': '設置', + 'settings.navigationTitle': '設置', + 'settings.networkSettings': '網絡設置', + 'settings.serverApiUrl': '服務端接口地址', + 'settings.validServerUrl': '請輸入有效的服務端地址(以 http 或 https 開頭,並以 /xiaozhi 結尾)', + 'settings.saveSettings': '保存設置', + 'settings.resetDefault': '恢復默認', + 'settings.restartApp': '重啟應用', + 'settings.restartNow': '立即重啟', + 'settings.restartLater': '稍後', + // 關於我們 + 'settings.aboutApp': '關於小智智控台', + 'settings.aboutContent': '小智智控台\n\n基於 Vue.js 3 + uni-app 構建的跨平台移動端管理應用,為小智ESP32智能硬體提供設備管理、智能體配置等功能。\n\n© 2025 xiaozhi-esp32-server {version}', + 'settings.restartSuccess': '已保存,可稍後手動重啟應用', + 'settings.serverUrlSavedAndCacheCleared': '服務端地址已保存,緩存已清除', + 'settings.resetToDefaultAndCacheCleared': '已恢復默認設置,緩存已清除', + 'settings.resetSuccess': '重置成功', + 'settings.enterServerUrl': '請輸入服務端地址', + 'settings.clearCacheFailed': '清除緩存失敗', + 'settings.cacheManagement': '緩存管理', + 'settings.totalCacheSize': '總緩存大小', + 'settings.appDataSize': '應用數據總大小', + 'settings.cacheClear': '緩存清理', + 'settings.clearAllCache': '清空所有緩存數據', + 'settings.clearCache': '清除緩存', + 'settings.modifyWillClearCache': '修改將清除緩存', + 'settings.appInfo': '應用信息', + 'settings.aboutUs': '關於我們', + 'settings.appVersion': '應用版本與團隊信息', + 'settings.confirmClear': '確認清除', + 'settings.confirmClearMessage': '確定要清除所有緩存嗎?這將刪除所有數據包括登錄狀態,需要重新登錄。', + 'settings.cacheCleared': '緩存清除成功,即將跳轉到登錄頁', + 'settings.languageSettings': '語言設置', + 'settings.language': '語言', + 'settings.selectLanguage': '選擇語言', + 'settings.languageChanged': '語言切換成功', + + // 消息提示 + 'message.loginSuccess': '登錄成功!', + 'message.loginFail': '登錄失敗', + 'message.registerSuccess': '註冊成功', + 'message.registerFail': '註冊失敗', + 'message.saveSuccess': '保存成功', + 'message.saveFail': '保存失敗', + 'message.deleteSuccess': '刪除成功', + 'message.deleteFail': '刪除失敗', + 'message.bindSuccess': '綁定成功', + 'message.bindFail': '綁定失敗', + 'message.unbindSuccess': '解除綁定成功', + 'message.unbindFail': '解除綁定失敗', + 'message.networkError': '網絡錯誤,請檢查網絡連接', + 'message.serverError': '服務器錯誤,請稍後再試', + 'message.invalidAddress': '地址可能無效,請檢查服務端是否啟動或網絡連接是否正常; 也可能因HTTPS協定問題導致無法發送請求常', + 'message.languageChanged': '語言已切換', + 'message.passwordError': '帳號或密碼錯誤', + 'message.phoneRegistered': '此手機號已經註冊過', + + // Agent工具頁面 + 'agent.tools.pageTitle': 'Agent工具', + 'agent.tools.unselected': '未選', + 'agent.tools.selected': '已選', + 'agent.tools.noMorePlugins': '暫無更多插件', + 'agent.tools.pleaseSelectPlugin': '請選擇插件功能', + 'agent.tools.builtInPlugins': '內置插件', + 'agent.tools.mcpAccessPoint': 'mcp接入點', + 'agent.tools.copy': '複製', + 'agent.tools.noTools': '暫無工具', + 'agent.tools.parameterConfig': '參數配置', + 'agent.tools.noParamsNeeded': '無需配置參數', + 'agent.tools.pleaseInput': '請輸入', + 'agent.tools.inputOneItemPerLine': '每行輸入一個項目', + 'agent.tools.pleaseInputValidJson': '請輸入有效的JSON格式', + 'agent.tools.enableFunction': '啟用功能', + 'agent.tools.toggleFunction': '開啟或關閉此功能', + 'agent.tools.jsonFormatError': 'JSON格式錯誤', + 'agent.tools.noMcpAddressToCopy': '暫無MCP地址可複製', + 'agent.tools.mcpAddressCopied': 'MCP地址已複製到剪貼簿', + 'agent.tools.copyFailed': '複製失敗,請重試', + 'agent.tools.defaultValue': '默認值', + 'agent.tools.notSelected': '未選', + 'agent.tools.clickToConfigure': '點擊配置', + 'agent.tools.mcpEndpoint': 'MCP接入點', + 'agent.tools.eachLineOneItem': '每行輸入一個項目', + + // 設備配置頁面 + 'deviceConfig.pageTitle': '設備配置', + 'deviceConfig.wifiConfig': 'WiFi配網', + 'deviceConfig.ultrasonicConfig': '超聲波配網', + 'deviceConfig.selectConfigMethod': '選擇配網方式', + 'deviceConfig.networkConfig': '網絡配置', + 'deviceConfig.selectedNetwork': '選中網絡', + 'deviceConfig.signal': '信號', + 'deviceConfig.openNetwork': '開放網絡', + 'deviceConfig.encryptedNetwork': '加密網絡', + 'deviceConfig.password': '密碼', + 'deviceConfig.pleaseEnterPassword': '請輸入WiFi密碼', + 'deviceConfig.startConfig': '開始配網', + 'deviceConfig.connectToXiaozhiHotspot': '請先連接xiaozhi熱點 (xiaozhi-XXXXXX)', + 'deviceConfig.detecting': '檢測中...', + 'deviceConfig.reDetect': '重新檢測', + 'deviceConfig.alreadyConnected': '已連接xiaozhi熱點', + 'deviceConfig.refreshStatus': '刷新狀態', + 'deviceConfig.wifiNetworks': 'WiFi網絡', + 'deviceConfig.selectWifiNetwork': '選擇WiFi網絡', + 'deviceConfig.refreshScan': '刷新掃描', + 'deviceConfig.noWifiNetworks': '暫無WiFi網絡', + 'deviceConfig.clickToRefreshScan': '請點擊刷新掃描', + 'deviceConfig.signalStrong': '信號強', + 'deviceConfig.signalGood': '信號良好', + 'deviceConfig.signalFair': '信號一般', + 'deviceConfig.signalWeak': '信號弱', + 'deviceConfig.channel': '頻道', + 'deviceConfig.about': '約', + 'deviceConfig.seconds': '秒', + 'deviceConfig.generating': '生成中...', + 'deviceConfig.playing': '播放中...', + 'deviceConfig.generateAndPlaySoundWave': '生成並播放聲波', + 'deviceConfig.playSoundWave': '播放聲波', + 'deviceConfig.stopPlaying': '停止播放', + 'deviceConfig.autoLoopPlaySoundWave': '自動循環播放聲波', + 'deviceConfig.configAudioFile': '配網音頻文件', + 'deviceConfig.duration': '時長', + 'deviceConfig.ultrasonicConfigInstructions': '超聲波配網說明', + 'deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered': '確保已選擇WiFi網絡並輸入密碼', + 'deviceConfig.clickGenerateAndPlaySoundWave': '點擊生成並播放聲波,系統會將配網信息編碼為音頻', + 'deviceConfig.bringPhoneCloseToXiaozhiDevice': '將手機靠近xiaozhi設備(距離1-2米)', + 'deviceConfig.duringAudioPlaybackXiaozhiWillReceive': '音頻播放時,xiaozhi會接收並解碼配網信息', + 'deviceConfig.afterConfigSuccessDeviceWillConnect': '配網成功後設備會自動連接WiFi網絡', + 'deviceConfig.usesAfskModulation': '使用AFSK調制技術,通過1800Hz和1500Hz頻率傳輸數據', + 'deviceConfig.ensureModeratePhoneVolume': '請確保手機音量適中,避免環境噪音干擾', + 'deviceConfig.generatingUltrasonicConfigAudio': '生成超聲波配網音頻', + 'deviceConfig.configData': '配網數據', + 'deviceConfig.dataBytesLength': '數據字節長度', + 'deviceConfig.bitStreamLength': '比特流長度', + 'deviceConfig.base64Length': 'base64長度', + 'deviceConfig.audioFileTooLarge': '音頻文件過大,請縮短SSID或密碼長度', + 'deviceConfig.audioGenerationSuccess': '音頻生成成功', + 'deviceConfig.samplePoints': '採樣點數', + 'deviceConfig.soundWaveGenerationSuccess': '聲波生成成功', + 'deviceConfig.audioGenerationFailed': '音頻生成失敗', + 'deviceConfig.soundWaveGenerationFailed': '聲波生成失敗', + 'deviceConfig.pleaseGenerateAudioFirst': '請先生成音頻', + 'deviceConfig.startPlayingUltrasonicConfigAudio': '開始播放超聲波配網音頻', + 'deviceConfig.ultrasonicAudioStartedPlaying': '超聲波音頻開始播放', + 'deviceConfig.startPlayingConfigSoundWave': '開始播放配網聲波', + 'deviceConfig.ultrasonicAudioPlaybackEnded': '超聲波音頻播放結束', + 'deviceConfig.audioPlaybackFailed': '音頻播放失敗', + 'deviceConfig.audioResourceBusy': '音頻資源繁忙,請稍後重試', + 'deviceConfig.audioFormatNotSupported': '音頻格式不支援,可能是data URI問題', + 'deviceConfig.audioFileError': '音頻文件錯誤', + 'deviceConfig.cleaningUpAudioContext': '清理音頻上下文', + 'deviceConfig.cleaningUpAudioContextFailed': '清理音頻上下文失敗', + 'deviceConfig.stoppedPlayingUltrasonicAudio': '停止播放超聲波音頻', + 'deviceConfig.stoppedPlaying': '已停止播放', + 'deviceConfig.configMethod': '配網方式', + 'deviceConfig.enterWifiPassword': '請輸入WiFi密碼', + 'deviceConfig.xiaozhi': 'xiaozhi', + 'deviceConfig.connectXiaozhiHotspot': '請連接xiaozhi熱點', + 'deviceConfig.wifiScanResponse': 'WiFi掃描響應', + 'deviceConfig.scanSuccess': '掃描成功', + 'deviceConfig.networks': '個網絡', + 'deviceConfig.wifiScanFailed': 'WiFi掃描失敗', + 'deviceConfig.scanFailedCheckConnection': '掃描失敗,請檢查連接', + 'deviceConfig.checking': '檢查中', + 'deviceConfig.reCheck': '重新檢查', + 'deviceConfig.connectedXiaozhiHotspot': '已連接xiaozhi熱點', + 'deviceConfig.wifiNetwork': 'WiFi網絡', + 'deviceConfig.scanning': '掃描中', + 'deviceConfig.cancel': '取消', + 'deviceConfig.clickRefreshScan': '請點擊刷新掃描', + 'deviceConfig.esp32ConnectionCheckFailed': 'ESP32連接檢查失敗', + 'deviceConfig.startWifiConfig': '開始WiFi配網', + 'deviceConfig.configSuccess': '配網成功', + 'deviceConfig.deviceWillConnectTo': '設備將連接到', + 'deviceConfig.deviceWillRestart': '設備將重啟', + 'deviceConfig.pleaseDisconnectXiaozhiHotspot': '請斷開xiaozhi熱點連接', + 'deviceConfig.configFailed': '配網失敗', + 'deviceConfig.wifiConfigFailed': 'WiFi配網失敗', + 'deviceConfig.pleaseCheckNetworkConnection': '請檢查網絡連接', + 'deviceConfig.startWifiConfigButton': '開始配網', + 'deviceConfig.wifiConfigInstructions': 'WiFi配網說明', + 'deviceConfig.phoneConnectXiaozhiHotspot': '手機連接xiaozhi熱點', + 'deviceConfig.selectTargetWifiNetwork': '選擇目標WiFi網絡', + 'deviceConfig.enterWifiPasswordIfNeeded': '如有需要請輸入WiFi密碼', + 'deviceConfig.clickStartConfigAndWait': '點擊開始配網並等待', + 'deviceConfig.afterConfigSuccessDeviceWillRestart': '配網成功後設備將自動重啟', + 'deviceConfig.audioPlaybackError': '音頻播放錯誤', + 'deviceConfig.playbackFailed': '播放失敗', + + // Voiceprint page + 'voiceprint.audioNotExist': '該音頻不存在', + 'voiceprint.getAudioFailed': '獲取音頻失敗', + 'voiceprint.audioPlayFailed': '音頻播放失敗', +} diff --git a/backend/main/manager-mobile/src/layouts/default.vue b/backend/main/manager-mobile/src/layouts/default.vue new file mode 100644 index 0000000..360c6b2 --- /dev/null +++ b/backend/main/manager-mobile/src/layouts/default.vue @@ -0,0 +1,17 @@ + + + diff --git a/backend/main/manager-mobile/src/layouts/fg-tabbar/fg-tabbar.vue b/backend/main/manager-mobile/src/layouts/fg-tabbar/fg-tabbar.vue new file mode 100644 index 0000000..819aa6f --- /dev/null +++ b/backend/main/manager-mobile/src/layouts/fg-tabbar/fg-tabbar.vue @@ -0,0 +1,68 @@ + + + diff --git a/backend/main/manager-mobile/src/layouts/fg-tabbar/tabbar.md b/backend/main/manager-mobile/src/layouts/fg-tabbar/tabbar.md new file mode 100644 index 0000000..2485b06 --- /dev/null +++ b/backend/main/manager-mobile/src/layouts/fg-tabbar/tabbar.md @@ -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` 会闪烁,无缓存。 + + +> 注意:花里胡哨的效果需要自己实现,本模版不提供。 diff --git a/backend/main/manager-mobile/src/layouts/fg-tabbar/tabbar.ts b/backend/main/manager-mobile/src/layouts/fg-tabbar/tabbar.ts new file mode 100644 index 0000000..03be03f --- /dev/null +++ b/backend/main/manager-mobile/src/layouts/fg-tabbar/tabbar.ts @@ -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) + }, +}) diff --git a/backend/main/manager-mobile/src/layouts/fg-tabbar/tabbarList.ts b/backend/main/manager-mobile/src/layouts/fg-tabbar/tabbarList.ts new file mode 100644 index 0000000..5273136 --- /dev/null +++ b/backend/main/manager-mobile/src/layouts/fg-tabbar/tabbarList.ts @@ -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 diff --git a/backend/main/manager-mobile/src/layouts/tabbar.vue b/backend/main/manager-mobile/src/layouts/tabbar.vue new file mode 100644 index 0000000..0c1bb1c --- /dev/null +++ b/backend/main/manager-mobile/src/layouts/tabbar.vue @@ -0,0 +1,19 @@ + + + diff --git a/backend/main/manager-mobile/src/main.ts b/backend/main/manager-mobile/src/main.ts new file mode 100644 index 0000000..4b3ad83 --- /dev/null +++ b/backend/main/manager-mobile/src/main.ts @@ -0,0 +1,26 @@ +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' + +// 导入国际化相关功能 +import { initI18n } from './i18n' +import { useLangStore } from './store/lang' + +export function createApp() { + const app = createSSRApp(App) + app.use(store) + app.use(routeInterceptor) + app.use(VueQueryPlugin) + + // 初始化国际化 + initI18n() + + return { + app, + } +} diff --git a/backend/main/manager-mobile/src/manifest.json b/backend/main/manager-mobile/src/manifest.json new file mode 100644 index 0000000..67225dc --- /dev/null +++ b/backend/main/manager-mobile/src/manifest.json @@ -0,0 +1,124 @@ +{ + "name": "小智", + "appid": "__UNI__36A515E", + "description": "", + "versionName": "1.0.0", + "versionCode": "100", + "transformPx": false, + "app-plus": { + "usingComponents": true, + "nvueStyleCompiler": "uni-app", + "compilerVersion": 3, + "splashscreen": { + "alwaysShowBeforeRender": true, + "waiting": true, + "autoclose": true, + "delay": 0 + }, + "modules": {}, + "distribute": { + "android": { + "permissions": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "minSdkVersion": 30, + "targetSdkVersion": 30, + "abiFilters": [ + "armeabi-v7a", + "arm64-v8a" + ] + }, + "ios": {}, + "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" + } + } + } + }, + "compatible": { + "ignoreVersion": true + } + }, + "quickapp": {}, + "mp-weixin": { + "appid": "wxa2abb91f64032a2b", + "setting": { + "urlCheck": false, + "es6": true, + "minified": true + }, + "usingComponents": true, + "optimization": { + "subPackages": 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", + "h5": { + "router": {} + } +} \ No newline at end of file diff --git a/backend/main/manager-mobile/src/pages-sub/demo/index.vue b/backend/main/manager-mobile/src/pages-sub/demo/index.vue new file mode 100644 index 0000000..4231cff --- /dev/null +++ b/backend/main/manager-mobile/src/pages-sub/demo/index.vue @@ -0,0 +1,27 @@ + +{ + "layout": "default", + "style": { + "navigationBarTitleText": "分包页面" + } +} + + + + + + + diff --git a/backend/main/manager-mobile/src/pages.json b/backend/main/manager-mobile/src/pages.json new file mode 100644 index 0000000..554a0a2 --- /dev/null +++ b/backend/main/manager-mobile/src/pages.json @@ -0,0 +1,167 @@ +{ + "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": { + "custom": false, + "color": "#e6e6e6", + "selectedColor": "#667dea", + "backgroundColor": "#fff", + "borderStyle": "black", + "height": "50px", + "fontSize": "10px", + "iconWidth": "24px", + "spacing": "3px", + "list": [ + { + "iconPath": "static/tabbar/robot.png", + "selectedIconPath": "static/tabbar/robot_activate.png", + "pagePath": "pages/index/index", + "text": "首页", + "icon": "home", + "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" + } + ] + }, + "pages": [ + { + "path": "pages/index/index", + "type": "home", + "layout": "tabbar", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "首页" + } + }, + { + "path": "pages/agent/edit", + "type": "page" + }, + { + "path": "pages/agent/index", + "type": "page", + "layout": "default", + "style": { + "navigationBarTitleText": "智能体", + "navigationStyle": "custom" + } + }, + { + "path": "pages/agent/tools", + "type": "page", + "layout": "default", + "style": { + "navigationBarTitleText": "编辑功能", + "navigationStyle": "custom" + } + }, + { + "path": "pages/chat-history/detail", + "type": "page", + "layout": "default", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "聊天详情" + } + }, + { + "path": "pages/chat-history/index", + "type": "page" + }, + { + "path": "pages/device/index", + "type": "page" + }, + { + "path": "pages/device-config/index", + "type": "page", + "style": { + "navigationBarTitleText": "设备配置", + "navigationStyle": "custom" + } + }, + { + "path": "pages/forgot-password/index", + "type": "page", + "layout": "default", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "ForgotPassword" + } + }, + { + "path": "pages/login/index", + "type": "page", + "layout": "default", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "Login" + } + }, + { + "path": "pages/register/index", + "type": "page", + "layout": "default", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "注册" + } + }, + { + "path": "pages/settings/index", + "type": "page", + "layout": "default", + "style": { + "navigationBarTitleText": "设置", + "navigationStyle": "custom" + } + }, + { + "path": "pages/voiceprint/index", + "type": "page" + } + ], + "subPackages": [ + { + "root": "pages-sub", + "pages": [ + { + "path": "demo/index", + "type": "page", + "layout": "default", + "style": { + "navigationBarTitleText": "分包页面" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/backend/main/manager-mobile/src/pages/agent/edit.vue b/backend/main/manager-mobile/src/pages/agent/edit.vue new file mode 100644 index 0000000..ef61477 --- /dev/null +++ b/backend/main/manager-mobile/src/pages/agent/edit.vue @@ -0,0 +1,1085 @@ + + +