You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

324 lines
8.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 一、视频教程
[小智$ai$服务端本地部署完整教程,支持$DeepSeek$接入](https://www.bilibili.com/video/BV1GvQWYZEd2/)
### 二、安装$Anaconda3$
下载地址
> https://www.anaconda.com/download
安装与配置
> https://blog.csdn.net/2302_76672693/article/details/144267428
将下面的四个目录添加到环境变量中
```
D:\anaconda3\Library\mingw-w64\bin
D:\anaconda3\Library\bin
D:\anaconda3\Library\usr\bin
D:\anaconda3\Scripts
```
确认是否安装成功
```
WIN+R输入cmd打开控制台输入conda -V
```
使用$Anaconda$ 的黑窗口进行配置
```
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Anaconda (anaconda3)\Anaconda Prompt.lnk
```
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150744617.png)
设置$Anaconda$镜像
```cmd
conda config --remove-key channels
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --show channels
```
**创建环境**
```
conda create --name python310 python=3.10
```
**激活环境**
```
conda activate python310
```
**查看当前环境**
```
conda env list
```
**退出虚拟环境**
```
conda deactivate
```
**查看已安装了哪些包**
```
pip list
```
### 三、部署步骤
```shell
# 如果以前配置过,那么先移除掉,如果以前没有配置过,略过本步骤
conda remove -n xiaozhi-esp32-server --all -y
# 创建虚拟环境
conda create -n xiaozhi-esp32-server python=3.10 -y
conda activate xiaozhi-esp32-server
# 音频的编码解码库
conda install libopus -y
conda install ffmpeg -y
# 安装音频处理工具,录制,转码,剪辑等
https://github.com/ShiftMediaProject/opus/releases
黄海下载的是libopus_v1.4_msvc17.zip
然后依据下面的文档指示,对环境代码进行配置:
```
> [解决Exception: Could not find Opus library. Make sure it is installed.](https://blog.csdn.net/Rysxt_/article/details/146361114)
``` python
if lib_location is None:
lib_location = r'D:\anaconda3\envs\xiaozhi-esp32-server\Lib\site-packages\libopus_v1.4_msvc17\bin\x64\opus.dll'
```
进入到你的项目根目录再进入main/xiaozhi-server
```powershell
d:
cd D:\dsWork\QingLong\XiaoZhi\xiaozhi-esp32-server\main\xiaozhi-server
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip install -r requirements.txt
```
**下载语音识别模型文件**
> 下载地址https://pan.baidu.com/share/init?surl=QlgM58FHhYv1tFnUT_A8Sg&pwd=qvna
将model.pt 放到
```
D:\dsWork\QingLong\XiaoZhi\xiaozhi-esp32-server\main\xiaozhi-server\models\SenseVoiceSmall
```
**配置项目**
如果你的xiaozhi-server目录没有data你需要创建data目录。如果你的data下面没有.config.yaml文件你可以把源码目录下的config.yaml文件复制一份重命名为.config.yaml
**注册**
```cmd
#我的电脑:
D:\dsWork\QingLong\XiaoZhi\xiaozhi-esp32-server\main\manager-web
#在地址栏输入 cmd 回车,然后输入:
npm install
npm run serve
```
http://10.10.21.20:8001/#/home
huanghai
DsideaL@123
### 四、修改固件
[编译esp32固件](https://github.com/TOM88812/xiaozhi-esp32-server/blob/main/docs/firmware-build.md)
下载安装
esp-idf-tools-setup-offline-5.3.2.exe
安装驱动
CH343SER.EXE
**实验材料**
处理器型号 $ESP32-S3-N16R8$
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150754335.png)
屏幕 $0.91$英寸,$SSD$ $1306$,分辨率:$128*32$
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150753720.png)
**步骤1**
双击桌面上的ESP-IDF 5.3 PowerShell 快捷方式
**步骤2**
**修改配置文件**
```
D:\dsWork\QingLong\XiaoZhi\xiaozhi-esp32\main\Kconfig.projbuild
```
```yaml
# 设置OTA地址
config OTA_VERSION_URL
string "OTA Version URL"
default "http://10.10.21.20:8002/xiaozhi/ota/"
help
The application will access this URL to check for updates.
# 配置本地服务器的服务地址
config WEBSOCKET_URL
depends on CONNECTION_TYPE_WEBSOCKET
string "Websocket URL"
default "ws://192.168.1.20:8000/xiaozhi/v1/"
help
Communication with the server through websocket after wake up.
# 修改默认连接方式
choice CONNECTION_TYPE
prompt "Connection Type"
default CONNECTION_TYPE_WEBSOCKET
help
网络数据传输协议
config CONNECTION_TYPE_MQTT_UDP
bool "MQTT + UDP"
config CONNECTION_TYPE_WEBSOCKET
bool "Websocket"
endchoice
# 设置默认的开发板类型
choice BOARD_TYPE
prompt "Board Type"
default BOARD_TYPE_BREAD_COMPACT_WIFI
help
Board type. 开发板类型
config BOARD_TYPE_BREAD_COMPACT_WIFI
bool "面包板新版接线WiFi"
config BOARD_TYPE_BREAD_COMPACT_WIFI_LCD
bool "面包板新版接线WiFi+ LCD"
config BOARD_TYPE_BREAD_COMPACT_ML307
bool "面包板新版接线ML307 AT"
config BOARD_TYPE_BREAD_COMPACT_ESP32
bool "面包板WiFi ESP32 DevKit"
config BOARD_TYPE_BREAD_COMPACT_ESP32_LCD
bool "面包板WiFi+ LCD ESP32 DevKit"
# 设置默认屏幕
choice DISPLAY_OLED_TYPE
depends on BOARD_TYPE_BREAD_COMPACT_WIFI || BOARD_TYPE_BREAD_COMPACT_ML307 || BOARD_TYPE_BREAD_COMPACT_ESP32
prompt "OLED Type"
default OLED_SSD1306_128X32
help
OLED 屏幕类型选择
config OLED_SSD1306_128X32
bool "SSD1306, 分辨率128*32"
config OLED_SSD1306_128X64
bool "SSD1306, 分辨率128*64"
config OLED_SH1106_128X64
bool "SH1106, 分辨率128*64"
endchoice
```
**设定目标板**
```
d:
cd D:\dsWork\QingLong\XiaoZhi\xiaozhi-esp32
idf.py set-target esp32s3
```
**进入配置界面**
```
idf.py menuconfig
```
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150817323.png)配置一下
进入$Xiaozhi$ $Assistant$选项
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150817839.png)
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150818535.png)
$Board$ $Type$:
config BOARD_TYPE_BREAD_COMPACT_WIFI
bool "面包板新版接线WiFi"
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150812722.png)
$DISPLAY\_OLED\_TYPE$:
$OLED\_SSD1306\_128X32$
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150757608.png)
按ESC退回主界面再点S进行保存。
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150822282.png)
**编译固件**
```
idf.py build
```
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150834785.png)
**打包$bin$固件**
```
cd scripts
python release.py
```
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150835200.png)
**打包后的产物**
```
D:\dsWork\QingLong\XiaoZhi\xiaozhi-esp32\build\merged-binary.bin
```
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202504150836242.png)
### 六、相关教程
1. [固件开源地址](https://github.com/78/xiaozhi-esp32)
2. [服务端开源地址](https://github.com/xinnan-tech/xiaozhi-esp32-server)
3. [Windows搭建 ESP IDF 5.3.2开发环境以及编译小智](https://icnynnzcwou8.feishu.cn/wiki/JEYDwTTALi5s2zkGlFGcDiRknXf)
5. [小智 AI 聊天机器人百科全书](
https://ccnphfhqs21z.feishu.cn/wiki/F5krwD16viZoF0kKkvDcrZNYnhb)
6. [购买店铺链接](https://docs.qq.com/sheet/DWmRhbnVHSnRWc2xz?tab=vajqu5)