Created
January 26, 2026 07:18
-
-
Save hasenbalg/1e9e86311d868fade1b48be4f40bb054 to your computer and use it in GitHub Desktop.
tts wayland
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # install gtts | |
| PIDFILE="/tmp/tts_reader.pid" | |
| TMPFILE="/tmp/tts_audio.mp3" | |
| # Stop if already running | |
| if [ -f "$PIDFILE" ]; then | |
| kill "$(cat "$PIDFILE")" 2>/dev/null | |
| rm "$PIDFILE" | |
| exit 0 | |
| fi | |
| # Read selected text | |
| TEXT="$(wl-paste --primary)" | |
| [ -z "$TEXT" ] && TEXT="$(wl-paste)" | |
| [ -z "$TEXT" ] && exit 0 | |
| # Generate MP3 | |
| gtts-cli "$TEXT" --output "$TMPFILE" | |
| # Play it | |
| mpv --no-terminal "$TMPFILE" & | |
| PID=$! | |
| echo "$PID" > "$PIDFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment