Files
karuo-ai/01_卡资(金)/金仓_存储备份/脚本/handy_transcription_hook.sh
2026-07-19 00:21:46 +08:00

35 lines
1.1 KiB
Bash
Executable File
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
# Handy hooks/transcription语音结束 → 回廊洗字 → 执行口令(小乖/乖乖/小宝)→ 直投 Cursor不进输入框
# stdout 必须为空Handy 才不会 ⌘V 粘贴。
set -euo pipefail
KARUO_AI_ROOT="${KARUO_AI_ROOT:-/Users/karuo/Documents/个人/卡若AI}"
PIPE="${KARUO_AI_ROOT}/运营中枢/工作台/脚本/karuo_voice_pipeline.py"
APPLY_PY="${KARUO_AI_ROOT}/运营中枢/工作台/脚本/apply_karuo_voice_corrections.py"
RAW="$(cat)"
if [[ -z "${RAW//[[:space:]]/}" ]]; then
exit 0
fi
# 默认:不粘贴。仅当显式 KARUO_VOICE_PASTE_WITHOUT_WAKE=1 且无执行口令时stdout 输出洗后文(旧 dictation
if [[ "${KARUO_VOICE_PASTE_WITHOUT_WAKE:-}" =~ ^(1|true|yes)$ ]]; then
if [[ -f "$APPLY_PY" ]]; then
CORRECTED="$(python3 "$APPLY_PY" <<<"$RAW")"
if [[ "$RAW" != *$'\n' && "$CORRECTED" == *$'\n' ]]; then
CORRECTED="${CORRECTED%$'\n'}"
fi
printf '%s' "$CORRECTED"
else
printf '%s' "$RAW"
fi
exit 0
fi
if [[ -f "$PIPE" ]]; then
python3 "$PIPE" --transcription-hook <<<"$RAW" 2>/dev/null || true
fi
# 不输出任何内容 → Handy 不粘贴
exit 0