-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathget_subs_tmux.sh
More file actions
executable file
·53 lines (40 loc) · 1.64 KB
/
Copy pathget_subs_tmux.sh
File metadata and controls
executable file
·53 lines (40 loc) · 1.64 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
#!/bin/bash
#
# This script downloads the en- subtitles of a Youtube video,
# and launches an interactive pi session to summarize it.
#
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "${SCRIPT_DIR}" || exit 1
SESSION="subs_interactive"
# Drop previous sub data
rm -f subs.en* subs.log.{txt,json}
touch subs.log.{txt,json}
# Download fresh new English subs
yt-dlp.sh --write-auto-subs --write-subs --sub-langs="en" --sub-format "vtt" --skip-download "$@" -o subs || exit 1
# Check we got one
F="$(/bin/ls subs*vtt | head -1)"
[ -z "$F" ] && { echo "[-] No subs*vtt found..."; exit 1; }
# Convert VTT to clean text
python3 vtt2text.py "$F"
TXT_F="${F%.vtt}.txt"
[ ! -f "$TXT_F" ] && { echo "[-] Failed to convert $F to text"; exit 1; }
# Kill old session if it exists
tmux kill-session -t "$SESSION" 2>/dev/null || true
# Create new tmux session (detached)
tmux new-session -d -s "$SESSION" -c "$SCRIPT_DIR"
# Launch pi interactively in the pane.
# We mirror the docker configuration from pi.google_run.sh but remove --mode json and -p
# to enter the interactive TUI mode.
PI_CMD="source ai.google.key && \
podman run -w \$PWD --rm -v \$PWD:\$PWD \
-e NODE_NO_READLINE=1 -e FORCE_COLOR=1 \
-e GOOGLE_AI_STUDIO_API_KEY=\$KEY -e GEMINI_API_KEY=\$KEY \
-it pi pi --model gemma-4-31b-it"
tmux send-keys -t "$SESSION" "$PI_CMD" C-m
# Give it a few seconds to start up and be ready for input
sleep 3
# Send the initial summary request
tmux send-keys -t "$SESSION" "Read file @$TXT_F and give me a 5-10 paragraph summary, making sure you dont miss the important points" C-m
# Attach to session
tmux attach -t "$SESSION"