Первый релиз WhisperKey
This commit is contained in:
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/zsh
|
||||
set -euo pipefail
|
||||
|
||||
PROJECT_DIR=${0:A:h:h}
|
||||
APP_DIR="$PROJECT_DIR/dist/WhisperKey.app"
|
||||
|
||||
cd "$PROJECT_DIR"
|
||||
swift build -c release
|
||||
|
||||
rm -rf "$APP_DIR"
|
||||
mkdir -p "$APP_DIR/Contents/MacOS" "$APP_DIR/Contents/Resources"
|
||||
cp "$PROJECT_DIR/.build/release/WhisperKey" "$APP_DIR/Contents/MacOS/WhisperKey"
|
||||
cp "$PROJECT_DIR/Resources/Info.plist" "$APP_DIR/Contents/Info.plist"
|
||||
codesign --force --deep --sign - "$APP_DIR"
|
||||
|
||||
echo "$APP_DIR"
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/bin/zsh
|
||||
set -euo pipefail
|
||||
|
||||
SUPPORT_DIR="$HOME/Library/Application Support/WhisperKey"
|
||||
WAV_PATH="${1:-$SUPPORT_DIR/last-dictation.wav}"
|
||||
|
||||
if [[ ! -f "$WAV_PATH" ]]; then
|
||||
echo "Нет записи для сравнения: $WAV_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== whisper.cpp ==="
|
||||
"$SUPPORT_DIR/whisper-cli" \
|
||||
-m "$SUPPORT_DIR/ggml-large-v3-turbo.bin" \
|
||||
-f "$WAV_PATH" \
|
||||
-l ru \
|
||||
--no-timestamps \
|
||||
--no-prints \
|
||||
--no-fallback \
|
||||
--max-context 0
|
||||
|
||||
echo
|
||||
echo "=== openai/whisper ==="
|
||||
"$SUPPORT_DIR/openai-whisper-venv/bin/python" - "$WAV_PATH" "$SUPPORT_DIR/openai-models" <<'PY'
|
||||
import sys
|
||||
import whisper
|
||||
|
||||
audio_path, model_dir = sys.argv[1], sys.argv[2]
|
||||
model = whisper.load_model("turbo", download_root=model_dir)
|
||||
result = model.transcribe(
|
||||
audio_path,
|
||||
language="ru",
|
||||
temperature=0,
|
||||
condition_on_previous_text=False,
|
||||
fp16=False,
|
||||
)
|
||||
print(result["text"].strip())
|
||||
PY
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/zsh
|
||||
set -euo pipefail
|
||||
|
||||
PROJECT_DIR=${0:A:h:h}
|
||||
"$PROJECT_DIR/scripts/build-app.sh"
|
||||
|
||||
ditto "$PROJECT_DIR/dist/WhisperKey.app" "/Applications/WhisperKey.app"
|
||||
|
||||
LOGIN_AGENT_DIR="$HOME/Library/LaunchAgents"
|
||||
LOGIN_AGENT="$LOGIN_AGENT_DIR/com.romanv.WhisperKey.plist"
|
||||
mkdir -p "$LOGIN_AGENT_DIR"
|
||||
cp "$PROJECT_DIR/Resources/com.romanv.WhisperKey.plist" "$LOGIN_AGENT"
|
||||
launchctl bootout "gui/$(id -u)" "$LOGIN_AGENT" 2>/dev/null || true
|
||||
launchctl bootstrap "gui/$(id -u)" "$LOGIN_AGENT"
|
||||
|
||||
open "/Applications/WhisperKey.app"
|
||||
|
||||
echo "Installed: /Applications/WhisperKey.app"
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/bin/zsh
|
||||
set -euo pipefail
|
||||
|
||||
SUPPORT_DIR="$HOME/Library/Application Support/WhisperKey"
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TEMP_DIR"' EXIT
|
||||
|
||||
mkdir -p "$SUPPORT_DIR"
|
||||
git clone --depth 1 https://github.com/ggml-org/whisper.cpp.git "$TEMP_DIR/whisper.cpp"
|
||||
cmake -S "$TEMP_DIR/whisper.cpp" -B "$TEMP_DIR/whisper.cpp/build" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DWHISPER_METAL=ON \
|
||||
-DWHISPER_COREML=OFF \
|
||||
-DWHISPER_BUILD_SERVER=ON
|
||||
cmake --build "$TEMP_DIR/whisper.cpp/build" --config Release --target whisper-cli whisper-server -j 8
|
||||
cp "$TEMP_DIR/whisper.cpp/build/bin/whisper-cli" "$SUPPORT_DIR/whisper-cli"
|
||||
cp "$TEMP_DIR/whisper.cpp/build/bin/whisper-server" "$SUPPORT_DIR/whisper-server"
|
||||
chmod 755 "$SUPPORT_DIR/whisper-cli" "$SUPPORT_DIR/whisper-server"
|
||||
|
||||
MODEL_FILE="ggml-large-v3-turbo.bin"
|
||||
MODEL_URL="https://huggingface.co/ggerganov/whisper.cpp/resolve/main/$MODEL_FILE"
|
||||
MODEL_SHA256="1fc70f774d38eb169993ac391eea357ef47c88757ef72ee5943879b7e8e2bc69"
|
||||
if [[ ! -s "$SUPPORT_DIR/$MODEL_FILE" ]]; then
|
||||
curl --fail --location --progress-bar "$MODEL_URL" --output "$SUPPORT_DIR/$MODEL_FILE"
|
||||
fi
|
||||
|
||||
ACTUAL_SHA256=$(shasum -a 256 "$SUPPORT_DIR/$MODEL_FILE" | awk '{print $1}')
|
||||
if [[ "$ACTUAL_SHA256" != "$MODEL_SHA256" ]]; then
|
||||
echo "Model checksum mismatch: $ACTUAL_SHA256" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VAD_FILE="ggml-silero-v6.2.0.bin"
|
||||
VAD_URL="https://huggingface.co/ggml-org/whisper-vad/resolve/main/$VAD_FILE"
|
||||
VAD_SHA256="2aa269b785eeb53a82983a20501ddf7c1d9c48e33ab63a41391ac6c9f7fb6987"
|
||||
if [[ ! -s "$SUPPORT_DIR/$VAD_FILE" ]]; then
|
||||
curl --fail --location --progress-bar "$VAD_URL" --output "$SUPPORT_DIR/$VAD_FILE"
|
||||
fi
|
||||
|
||||
ACTUAL_VAD_SHA256=$(shasum -a 256 "$SUPPORT_DIR/$VAD_FILE" | awk '{print $1}')
|
||||
if [[ "$ACTUAL_VAD_SHA256" != "$VAD_SHA256" ]]; then
|
||||
echo "VAD checksum mismatch: $ACTUAL_VAD_SHA256" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Local Whisper installed:"
|
||||
echo " $SUPPORT_DIR/whisper-cli"
|
||||
echo " $SUPPORT_DIR/whisper-server"
|
||||
echo " $SUPPORT_DIR/$MODEL_FILE"
|
||||
Reference in New Issue
Block a user