DroneMind/scripts/bundle_for_device.sh
2026-04-14 09:54:26 +08:00

55 lines
1.8 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# 在本机把「原仓库」里的 models及可选 GGUF 缓存)拷进本子工程,便于整包 scp/rsync 到另一台香橙派。
#
# 用法(在 voice_drone_assistant 根目录):
# bash scripts/bundle_for_device.sh
# bash scripts/bundle_for_device.sh /path/to/rocket_drone_audio
#
# 默认上一级目录为原仓库(即 voice_drone_assistant 仍放在 rocket_drone_audio 子目录时的布局)。
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SRC="${1:-$ROOT/..}"
M="$ROOT/models"
if [[ ! -d "$SRC/src/models" ]]; then
echo "未找到 $SRC/src/models ,请传入正确的原仓库根路径:" >&2
echo " bash scripts/bundle_for_device.sh /path/to/rocket_drone_audio" >&2
exit 1
fi
mkdir -p "$M"
echo "源目录: $SRC"
echo "目标 models: $M"
copy_dir() {
local name="$1"
if [[ -d "$SRC/src/models/$name" ]]; then
echo " 复制 models/$name ..."
rm -rf "$M/$name"
cp -a "$SRC/src/models/$name" "$M/"
else
echo " 跳过(不存在): src/models/$name"
fi
}
copy_dir "SenseVoiceSmall"
copy_dir "Kokoro-82M-v1.1-zh-ONNX"
copy_dir "SileroVad"
# 可选:大模型 GGUF体积大按需
if [[ -d "$SRC/cache/qwen25-1.5b-gguf" ]]; then
read -r -p "是否复制 Qwen GGUF 到 cache/?(可能数百 MB数 GB[y/N] " ans
if [[ "${ans:-}" =~ ^[yY] ]]; then
mkdir -p "$ROOT/cache/qwen25-1.5b-gguf"
cp -a "$SRC/cache/qwen25-1.5b-gguf/"* "$ROOT/cache/qwen25-1.5b-gguf/" 2>/dev/null || true
echo " 已复制 cache/qwen25-1.5b-gguf"
fi
else
echo " 未找到 $SRC/cache/qwen25-1.5b-gguf ,大模型请在新机器上再下载或单独拷贝"
fi
echo
echo "完成。可将整个目录打包拷贝到另一台设备:"
echo " $ROOT"
echo "新设备上请执行: pip install -r requirements.txt或使用相同 conda 环境)"