Primary: /run/agenix/elevenlabs-key (read via 'read -r' which strips the trailing newline agenix files contain). Fallback: ELEVENLABS_API_KEY env var (backwards compatible). No need to export the key in shell environment anymore — if the agenix secret exists, talk picks it up automatically. Override path via ELEVENLABS_KEY_FILE env var if needed.
99 lines
2.9 KiB
Markdown
99 lines
2.9 KiB
Markdown
# talk
|
|
|
|
ElevenLabs TTS voice notifications with a dismissable desktop popup. Generates speech from text via the ElevenLabs API, plays it through `mpv`, and shows a notification with a **⛔ Abbrechen** button to stop playback.
|
|
|
|
## Usage
|
|
|
|
### Argument
|
|
|
|
```bash
|
|
talk "Build abgeschlossen. Alle Tests erfolgreich."
|
|
```
|
|
|
|
### Stdin (pipe)
|
|
|
|
```bash
|
|
echo "Deployment fertig" | talk
|
|
nixos-rebuild build 2>&1 | tail -3 | talk
|
|
pi -p "Fasse zusammen" | talk
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
| Variable | Required | Default | Description |
|
|
|---|---|---|---|
|
|
| `ELEVENLABS_API_KEY` | ⚠️ | — | Fallback if agenix file is absent |
|
|
| `ELEVENLABS_KEY_FILE` | ❌ | `/run/agenix/elevenlabs-key` | Path to agenix secrets file (preferred) |
|
|
| `ELEVENLABS_VOICE_ID` | ❌ | `KXxZd16DiBqt82nbarJx` | Voice ID to use |
|
|
| `VOICE_NOTIFY` | ❌ | `1` | Set to `0` to silence all output |
|
|
|
|
The API key is read from the agenix file at `/run/agenix/elevenlabs-key` by default. The file should contain just the key (trailing newline is stripped automatically via `read -r`). If the file doesn't exist, `talk` falls back to the `ELEVENLABS_API_KEY` environment variable.
|
|
|
|
## How It Works
|
|
|
|
1. Sends text to ElevenLabs `text-to-speech` API → receives MP3
|
|
2. Plays audio via `mpv` (background)
|
|
3. Shows `notify-send` popup with **⛔ Abbrechen** action (background)
|
|
4. Polls every 0.2s:
|
|
- If mpv finished → kill notification, exit
|
|
- If user clicked **Abbrechen** → kill mpv, exit
|
|
5. Cleans up temp files on exit
|
|
|
|
## Cancel Button
|
|
|
|
The notification popup has a **⛔ Abbrechen** action button. Clicking it kills `mpv` playback immediately. The popup disappears when audio finishes or is cancelled.
|
|
|
|
The poll loop uses `[ -s ]` (non-empty file check) on the action output file. This ensures the loop only reacts when `notify-send` actually writes the action key — not when the empty file is created by the shell redirect.
|
|
|
|
## Integration Patterns
|
|
|
|
### After long-running tasks
|
|
|
|
```bash
|
|
nixos-rebuild switch 2>&1 | tail -5 | talk
|
|
```
|
|
|
|
### With AI agents (print mode)
|
|
|
|
```bash
|
|
# Pi
|
|
pi -p "Review diesen Code" | talk
|
|
|
|
# OpenCode
|
|
opencode run "Erkläre diese Funktion" -q | talk
|
|
```
|
|
|
|
### With crunch (scheduled jobs)
|
|
|
|
```bash
|
|
crunch ai pi daily "08:00" "Fasse Basecamp Todos zusammen"
|
|
# → talk speaks the summary at 08:00
|
|
```
|
|
|
|
## NixOS Installation
|
|
|
|
```nix
|
|
# home-manager
|
|
home.packages = [ pkgs.m3ta.talk ];
|
|
```
|
|
|
|
The API key is read from `/run/agenix/elevenlabs-key` at runtime — set up the secret in your agenix configuration:
|
|
|
|
```nix
|
|
# secrets.nix
|
|
age.secrets."elevenlabs-key" = {
|
|
file = ./secrets/elevenlabs-key.age;
|
|
# Optionally set owner/group if needed
|
|
};
|
|
```
|
|
|
|
No need to export `ELEVENLABS_API_KEY` in shell environment anymore.
|
|
|
|
## Dependencies
|
|
|
|
- `curl` — API calls
|
|
- `python3` — JSON payload construction
|
|
- `mpv` — audio playback
|
|
- `libnotify` — desktop notification
|
|
- `busybox` — coreutils (rm, cat, grep, sleep, kill, stat)
|