Skip to content

fix: support Opus/OGG output format#16

Open
derspotter wants to merge 1 commit intosteipete:mainfrom
derspotter:fix/opus-output-format
Open

fix: support Opus/OGG output format#16
derspotter wants to merge 1 commit intosteipete:mainfrom
derspotter:fix/opus-output-format

Conversation

@derspotter
Copy link

Problem

The --format flag and .ogg/.opus file extensions are not respected — sag always outputs MP3 regardless of the requested format.

Two bugs:

  1. output_format is sent in the JSON request body, but the ElevenLabs API expects it as a query parameter.
  2. inferFormatFromExt() doesn't recognize .ogg/.opus extensions.

Fix

  • Move output_format from JSON body to query parameter (both StreamTTS and ConvertTTS)
  • Add .ogg/.opus extension inference → opus_48000_64
  • Change Accept header from audio/mpeg to */* to accept non-MP3 responses

Use case

WhatsApp and Telegram voice notes require OGG/Opus. With this fix:

sag "Hello" -o voice.ogg   # outputs native Opus from ElevenLabs API
sag "Hello" --format opus_48000_128 -o output.opus  # also works

No ffmpeg conversion needed.

- Move output_format from JSON body to query parameter (per ElevenLabs API spec)
- Add .ogg/.opus extension inference -> opus_48000_64
- Change Accept header to */* to support non-MP3 formats
- Fixes both StreamTTS and ConvertTTS endpoints
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