fix: 修复自启动脚本
This commit is contained in:
@@ -24,15 +24,18 @@ cat <<EOF > /data/open-xiaoai/kws/reply.txt
|
||||
主人你好,请问有什么吩咐?
|
||||
EOF
|
||||
|
||||
# 运行启动脚本
|
||||
# 运行启动脚本 init.sh
|
||||
curl -sSfL https://gitee.com/idootop/artifacts/releases/download/open-xiaoai-kws/init.sh | sh
|
||||
```
|
||||
|
||||
如果你想要开机自启动,可以运行以下命令,然后重启小爱音箱即可。
|
||||
如果你想要开机自启动,运行以下命令重启小爱音箱即可。
|
||||
|
||||
```shell
|
||||
# 下载到 /data/init.sh 开机时自启动
|
||||
curl -L -o /data/init.sh https://gitee.com/idootop/artifacts/releases/download/open-xiaoai-kws/init.sh
|
||||
# 下载 boot.sh 到 /data/init.sh 开机时自启动
|
||||
curl -L -o /data/init.sh https://gitee.com/idootop/artifacts/releases/download/open-xiaoai-kws/boot.sh
|
||||
|
||||
# 重启小爱音箱
|
||||
reboot
|
||||
```
|
||||
|
||||
## 设置唤醒词
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
MIN_SPACE_MB=32
|
||||
DOWNLOAD_BASE_URL="https://gitee.com/idootop/artifacts/releases/download/open-xiaoai-kws"
|
||||
|
||||
|
||||
check_disk_space() {
|
||||
local space_kb=$(df -k "$1" | awk 'NR==2 {print $4}')
|
||||
if [ $((space_kb / 1024)) -lt "$MIN_SPACE_MB" ]; then
|
||||
echo 1
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
BASE_DIR="/data"
|
||||
if [ $(check_disk_space "$BASE_DIR") -eq 1 ]; then
|
||||
BASE_DIR="/tmp"
|
||||
if [ $(check_disk_space "$BASE_DIR") -eq 1 ]; then
|
||||
echo "❌ 磁盘空间不足,请先清理磁盘空间(至少需要 $MIN_SPACE_MB MB 空间)"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
WORK_DIR="$BASE_DIR/open-xiaoai/kws"
|
||||
KWS_BIN="$WORK_DIR/kws"
|
||||
|
||||
if [ ! -d "$WORK_DIR" ]; then
|
||||
mkdir -p "$WORK_DIR"
|
||||
fi
|
||||
|
||||
if [ ! -f "$WORK_DIR/models/encoder.onnx" ]; then
|
||||
echo "🔥 正在下载模型文件..."
|
||||
curl -L -# -o "$WORK_DIR/kws.tar.gz" "$DOWNLOAD_BASE_URL/kws.tar.gz"
|
||||
tar -xzvf "$WORK_DIR/kws.tar.gz" -C "$WORK_DIR"
|
||||
chmod +x "$KWS_BIN"
|
||||
rm "$WORK_DIR/kws.tar.gz"
|
||||
echo "✅ 模型文件下载完毕"
|
||||
fi
|
||||
|
||||
|
||||
CONFIG_DIR="/data/open-xiaoai/kws"
|
||||
|
||||
if [ ! -d "$CONFIG_DIR" ]; then
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
fi
|
||||
|
||||
if [ ! -f "$CONFIG_DIR/keywords.txt" ]; then
|
||||
echo "n ǐ h ǎo x iǎo zh ì @你好小智" >> "$CONFIG_DIR/keywords.txt"
|
||||
echo "d òu b āo d òu b āo @豆包豆包" >> "$CONFIG_DIR/keywords.txt"
|
||||
echo "t iān m āo j īng l íng @天猫精灵" >> "$CONFIG_DIR/keywords.txt"
|
||||
echo "x iǎo d ù x iǎo d ù @小度小度" >> "$CONFIG_DIR/keywords.txt"
|
||||
echo "✅ 默认唤醒词已创建"
|
||||
fi
|
||||
|
||||
if [ "$1" != "--no-monitor" ]; then
|
||||
# 如果没有设置 --no-monitor 参数,则启动 monitor 进程
|
||||
MONITOR_BIN="$CONFIG_DIR/monitor"
|
||||
if [ ! -f "$MONITOR_BIN" ]; then
|
||||
curl -L -# -o "$MONITOR_BIN" "$DOWNLOAD_BASE_URL/monitor"
|
||||
chmod +x "$MONITOR_BIN"
|
||||
fi
|
||||
kill -9 `ps|grep "open-xiaoai/kws/monitor"|grep -v grep|awk '{print $1}'` > /dev/null 2>&1 || true
|
||||
"$MONITOR_BIN" > /dev/null 2>&1 &
|
||||
fi
|
||||
|
||||
echo "🔥 正在启动唤醒词识别服务,请耐心等待..."
|
||||
echo "🐢 模型加载较慢,请在语音提示初始化成功后,再使用自定义唤醒词"
|
||||
|
||||
kill -9 `ps|grep "open-xiaoai/kws/kws"|grep -v grep|awk '{print $1}'` > /dev/null 2>&1 || true
|
||||
"$KWS_BIN" \
|
||||
--model-type=zipformer2 \
|
||||
--tokens="$WORK_DIR/models/tokens.txt" \
|
||||
--encoder="$WORK_DIR/models/encoder.onnx" \
|
||||
--decoder="$WORK_DIR/models/decoder.onnx" \
|
||||
--joiner="$WORK_DIR/models/joiner.onnx" \
|
||||
--keywords-file="/data/open-xiaoai/kws/keywords.txt" \
|
||||
--provider=cpu \
|
||||
--num-threads=1 \
|
||||
--chunk-size=1024 \
|
||||
noop
|
||||
+11
-9
@@ -44,17 +44,11 @@ fi
|
||||
|
||||
|
||||
CONFIG_DIR="/data/open-xiaoai/kws"
|
||||
MONITOR_BIN="$CONFIG_DIR/monitor"
|
||||
|
||||
if [ ! -d "$CONFIG_DIR" ]; then
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
fi
|
||||
|
||||
if [ ! -f "$MONITOR_BIN" ]; then
|
||||
curl -L -# -o "$MONITOR_BIN" "$DOWNLOAD_BASE_URL/monitor"
|
||||
chmod +x "$MONITOR_BIN"
|
||||
fi
|
||||
|
||||
if [ ! -f "$CONFIG_DIR/keywords.txt" ]; then
|
||||
echo "n ǐ h ǎo x iǎo zh ì @你好小智" >> "$CONFIG_DIR/keywords.txt"
|
||||
echo "d òu b āo d òu b āo @豆包豆包" >> "$CONFIG_DIR/keywords.txt"
|
||||
@@ -63,12 +57,20 @@ if [ ! -f "$CONFIG_DIR/keywords.txt" ]; then
|
||||
echo "✅ 默认唤醒词已创建"
|
||||
fi
|
||||
|
||||
if [ "$1" != "--no-monitor" ]; then
|
||||
# 如果没有设置 --no-monitor 参数,则启动 monitor 进程
|
||||
MONITOR_BIN="$CONFIG_DIR/monitor"
|
||||
if [ ! -f "$MONITOR_BIN" ]; then
|
||||
curl -L -# -o "$MONITOR_BIN" "$DOWNLOAD_BASE_URL/monitor"
|
||||
chmod +x "$MONITOR_BIN"
|
||||
fi
|
||||
kill -9 `ps|grep "open-xiaoai/kws/monitor"|grep -v grep|awk '{print $1}'` > /dev/null 2>&1 || true
|
||||
"$MONITOR_BIN" &
|
||||
fi
|
||||
|
||||
echo "🔥 正在启动唤醒词识别服务,请耐心等待..."
|
||||
echo "🐢 模型加载较慢,请在语音提示初始化成功后,再使用自定义唤醒词"
|
||||
|
||||
kill -9 `ps|grep "open-xiaoai/kws/monitor"|grep -v grep|awk '{print $1}'` > /dev/null 2>&1 || true
|
||||
"$MONITOR_BIN" &
|
||||
|
||||
kill -9 `ps|grep "open-xiaoai/kws/kws"|grep -v grep|awk '{print $1}'` > /dev/null 2>&1 || true
|
||||
"$KWS_BIN" \
|
||||
--model-type=zipformer2 \
|
||||
|
||||
Reference in New Issue
Block a user