Skip to content

Explicit --format is ignored when --output has a recognized extension #21

Description

@100yenadmin

Hi, I hit a format precedence bug in sag 0.4.0.

Repro

sag speak \
  --voice-id "$ELEVENLABS_VOICE_ID" \
  --output out.mp3 \
  --format mp3_44100_192 \
  --no-stream \
  "format precedence check"

ffprobe -v quiet -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 out.mp3

Expected: out.mp3 is requested/generated as mp3_44100_192.

Actual: the saved file is still 128 kbps.

I also verified the same ElevenLabs format directly against the API (output_format=mp3_44100_192) and that returns a true 192 kbps MP3, so the mismatch appears to be in sag's CLI/request construction rather than ElevenLabs.

Root cause

cmd/speak.go currently re-infers the format from --output unconditionally:

  • --output out.mp3 resets opts.outputFmt back to the inferred .mp3 default (mp3_44100_128)
  • that happens even when --format was explicitly set

That contradicts the docs, which say explicit --format should win.

Proposed fix

Only infer from the output extension when --format was not explicitly provided. I have a small patch + regression test ready and will open a PR right after filing this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions