Skip to content

Conversation

@atdrendel
Copy link

Before:

$ echo "Hallo" | ./sag
Command-line ElevenLabs TTS with macOS playback. Call it like macOS 'say': if you skip the subcommand, text args are passed to 'speak' (e.g. `sag "Hello"`).

Tip: run `sag prompting` for model-specific prompting tips.
Models: `eleven_v3` (default), `eleven_multilingual_v2` (stable), `eleven_flash_v2_5` (fast/cheap), `eleven_turbo_v2_5` (balanced).

Usage:
  sag [command]

Examples:
  sag "Hi Peter"
  echo 'piped input' | sag
  sag speak -v Roger --rate 200 "Faster speech"
  sag prompting

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  prompting   Prompting guide for better ElevenLabs speech
  speak       Speak the provided text using ElevenLabs TTS (default: stream to speakers)
  voices      List available ElevenLabs voices

Flags:
      --api-key string        ElevenLabs API key (or ELEVENLABS_API_KEY)
      --api-key-file string   Read ElevenLabs API key from file (or ELEVENLABS_API_KEY_FILE)
      --base-url string       Override ElevenLabs API base URL (default "https://api.elevenlabs.io")
  -h, --help                  help for sag
  -V, --version               Print version and exit

Use "sag [command] --help" for more information about a command.

After:

$ echo "Hallo" | ./sag
# Audio output: "Hallo"

Copilot AI review requested due to automatic review settings February 2, 2026 22:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables the sag command to automatically default to the "speak" subcommand when text is piped in via stdin, mimicking the behavior of macOS's say command. This allows users to pipe text directly to sag without explicitly specifying the "speak" subcommand.

Changes:

  • Modified maybeDefaultToSpeak() to detect piped stdin and inject the "speak" subcommand when no arguments are provided
  • Added test coverage for the new piped stdin behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/root.go Added logic to check if stdin is a TTY and inject "speak" subcommand for piped input
cmd/root_test.go Added test to verify "speak" is injected when stdin is piped

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant