-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
59 lines (49 loc) · 2.01 KB
/
Copy pathsetup.sh
File metadata and controls
59 lines (49 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WHISPER_DIR="${SCRIPT_DIR}/whisper.cpp"
WHISPER_BUILD_DIR="${WHISPER_DIR}/build"
MODEL_NAME="${MODEL_NAME:-tiny}"
log() { echo "[SETUP] $(date '+%H:%M:%S') $*"; }
log "=== Whisper Live Transcription API Setup ==="
log "Installing system dependencies (cmake, ffmpeg)..."
DEBIAN_FRONTEND=noninteractive apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq cmake ffmpeg
log "Installing Python dependencies..."
pip3 install --break-system-packages -r "${SCRIPT_DIR}/requirements.txt"
if [ -d "${WHISPER_DIR}" ]; then
if [ -z "$(ls -A "${WHISPER_DIR}")" ]; then
log "Whisper.cpp directory is empty, re-cloning..."
rm -rf "${WHISPER_DIR}"
git clone --depth 1 https://github.com/ggerganov/whisper.cpp.git "${WHISPER_DIR}"
else
log "Whisper.cpp already exists, skipping clone"
fi
else
log "Cloning whisper.cpp..."
git clone --depth 1 https://github.com/ggerganov/whisper.cpp.git "${WHISPER_DIR}"
fi
if [ -f "${WHISPER_BUILD_DIR}/bin/whisper-cli" ]; then
log "Whisper.cpp already built, skipping build"
else
log "Building whisper.cpp..."
cmake -B "${WHISPER_BUILD_DIR}" \
-DBUILD_SHARED_LIBS=OFF \
-DWHISPER_BUILD_TESTS=OFF \
-DWHISPER_BUILD_EXAMPLES=ON \
-S "${WHISPER_DIR}" \
-DCMAKE_BUILD_TYPE=Release
cmake --build "${WHISPER_BUILD_DIR}" -j"$(nproc)" --target whisper-cli
fi
if [ -f "${WHISPER_DIR}/models/ggml-${MODEL_NAME}.bin" ]; then
log "Model ggml-${MODEL_NAME}.bin already downloaded, skipping"
else
log "Downloading ${MODEL_NAME} model..."
bash "${WHISPER_DIR}/models/download-ggml-model.sh" "${MODEL_NAME}"
fi
log "Setup complete."
log ""
log "Start the server: ./start.sh"
log "Quick test: curl -s -X POST 'http://localhost:8000/api/transcribe?language=en' -F 'file=@${WHISPER_DIR}/samples/jfk.wav'"
log "Web UI: http://localhost:8000/"
log "API docs: http://localhost:8000/docs"