feat(stt): add JSON input_audio request format#181
Open
8x22b wants to merge 1 commit into
Open
Conversation
Add STT_REQUEST_FORMAT env var (multipart default | json). The json format sends base64 audio in an input_audio JSON body instead of multipart form-data, required by providers like OpenRouter. Ports a local STT protocol patch onto the current source.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
STT_REQUEST_FORMAT(multipartdefault |json). Thejsonformat sends base64-encoded audio in aninput_audio: { data, format }JSON body instead ofmultipart/form-data, for STT providers whose/audio/transcriptionsendpoint does not accept multipart uploads.Why
Some providers (e.g. OpenRouter) expect audio inline as base64 JSON rather than a multipart file upload. Today this only works with a local source patch; this makes it a supported, documented option.
Changes
config.stt.requestFormatparsed fromSTT_REQUEST_FORMAT(validated; falls back tomultipart).transcribeAudio()selects the body shape based on the format. The fetch / timeout / error / response-parsing path is shared; only the request body andContent-Typediffer between the two formats.json, the audio format is derived from the filename extension (oga/ogg/mp3/wav/m4a/flac/aac/webm, defaultogg).multipartbehavior is unchanged.Config
STT_REQUEST_FORMATmultipartjsonsends base64 audio in aninput_audioJSON bodyTests
Two new cases in
tests/app/services/stt-service.test.tsfor thejsonpath (body shape andContent-Type, format detection from filename, optionallanguage). The defaultmultiparttests are unchanged.npm run lint,npm run build,npm testpass.