-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·162 lines (138 loc) · 4.2 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·162 lines (138 loc) · 4.2 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
# Claude Code Voice - One-line installation script
# Usage: curl -sSL https://raw.githubusercontent.com/trssantos/claude-code-voice/main/install.sh | bash
set -e
REPO="trssantos/claude-code-voice"
BINARY_NAME="claude-code-voice"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
error() {
echo -e "${RED}[ERROR]${NC} $1"
exit 1
}
# Detect OS
detect_os() {
case "$OSTYPE" in
linux-gnu*)
OS="linux"
;;
darwin*)
OS="macos"
;;
msys*|win32)
OS="windows"
;;
*)
error "Unsupported OS: $OSTYPE"
;;
esac
}
# Install system dependencies
install_system_deps() {
info "Installing system dependencies..."
if [[ "$OS" == "linux" ]]; then
if command -v apt-get &> /dev/null; then
info "Detected Ubuntu/Debian"
sudo apt-get update
sudo apt-get install -y libasound2-dev pkg-config
elif command -v dnf &> /dev/null; then
info "Detected Fedora"
sudo dnf install -y alsa-lib-devel
elif command -v pacman &> /dev/null; then
info "Detected Arch"
sudo pacman -S --noconfirm alsa-lib
else
warn "Could not detect package manager. Please install ALSA development libraries manually."
fi
elif [[ "$OS" == "macos" ]]; then
info "macOS detected - no additional system dependencies needed"
elif [[ "$OS" == "windows" ]]; then
info "Windows detected - no additional system dependencies needed"
fi
}
# Check if Rust is installed
check_rust() {
if ! command -v cargo &> /dev/null; then
info "Rust not found. Installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
else
info "Rust is already installed"
fi
}
# Install the tool
install_tool() {
info "Installing $BINARY_NAME from source..."
cargo install --git "https://github.com/$REPO"
}
# Add to PATH if needed
setup_path() {
CARGO_BIN="$HOME/.cargo/bin"
# Check if cargo bin is in PATH
if [[ ":$PATH:" != *":$CARGO_BIN:"* ]]; then
info "Adding $CARGO_BIN to PATH..."
# Determine shell config file
if [[ -n "$ZSH_VERSION" ]]; then
SHELL_CONFIG="$HOME/.zshrc"
elif [[ -n "$BASH_VERSION" ]]; then
SHELL_CONFIG="$HOME/.bashrc"
else
SHELL_CONFIG="$HOME/.profile"
fi
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> "$SHELL_CONFIG"
export PATH="$CARGO_BIN:$PATH"
info "Added to PATH in $SHELL_CONFIG"
warn "Please run: source $SHELL_CONFIG"
fi
}
# Download base model
download_model() {
echo ""
info "Would you like to download the base Whisper model now? (~142MB)"
echo -n "Download model? [Y/n] "
# Read from /dev/tty to handle piped input
read -r response < /dev/tty || response=""
if [[ -z "$response" ]] || [[ "$response" =~ ^[Yy]$ ]]; then
info "Downloading base model..."
"$BINARY_NAME" download base || warn "Model download failed. You can download it later with: $BINARY_NAME download base"
else
info "Skipping model download. Download later with: $BINARY_NAME download base"
fi
echo ""
}
# Main installation flow
main() {
echo "=================================="
echo " Claude Code Voice Installer"
echo "=================================="
echo ""
detect_os
install_system_deps
check_rust
install_tool
setup_path
info "Installation complete!"
echo ""
echo "Next steps:"
echo " 1. Download a Whisper model: $BINARY_NAME download base"
echo " 2. Start the daemon: $BINARY_NAME start"
echo " 3. Press Ctrl+Shift+Space to record, release to transcribe"
echo ""
echo "For help: $BINARY_NAME --help"
echo ""
# Only offer to download model if binary is in PATH
if command -v "$BINARY_NAME" &> /dev/null; then
download_model
fi
}
main