#!/bin/bash
# 下载并编译 whisper.cpp，下载中文模型
set -e
WHISPER_DIR="/home/aska/Code/Cyrene/backend/voice-service/whisper.cpp"
MODEL_DIR="$WHISPER_DIR/models"

if [ ! -f "$WHISPER_DIR/main" ]; then
    echo "[whisper] 克隆 whisper.cpp..."
    git clone https://github.com/ggerganov/whisper.cpp.git "$WHISPER_DIR"
    cd "$WHISPER_DIR"
    echo "[whisper] 编译 whisper.cpp..."
    make -j$(nproc)
fi

# 下载 ggml-small.bin (中文支持好，~466MB)
if [ ! -f "$MODEL_DIR/ggml-small.bin" ]; then
    echo "[whisper] 下载 small 模型..."
    cd "$MODEL_DIR"
    bash ../models/download-ggml-model.sh small
fi

echo "whisper.cpp 安装完成: $WHISPER_DIR/main"
