Conversation
5d2aada to
a2aa9c6
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for wiring the existing STT/TTS helpers into the OpenAI-compatible API surface. The gap is real: current main still advertises audio_api: false at gateway/platforms/api_server.py:1506 and registers no audio routes at gateway/platforms/api_server.py:4767-4809.
Problems
gateway/platforms/api_server.py:4368raises the application-wide aiohttp limit to 100 MB. The new middleware branch only distinguishes audio requests whenContent-Lengthis supplied, so a chunked request to an existing non-audio endpoint bypasses the intended 10 MB limit. Current main relies on the 10 MBclient_max_sizecap atgateway/platforms/api_server.py:4767.gateway/platforms/api_server.py:1328labels the response using the requested format, but the underlying helper does not guarantee that format. In particular, Edge TTS saves MP3 bytes to the supplied path (tools/tts_tool.py:939-963), so a.wavtemp path can be returned asaudio/wavwhile containing MP3 data.
Suggested changes
- Preserve the non-audio cap for chunked and Content-Length requests; enforce a separate streaming cap for audio uploads.
- Either transcode formats or expose only formats the configured provider can produce, and derive MIME from the final artifact.
- Add coverage for both cases and document the public endpoints.
Automated hermes-sweeper review.
| @@ -4099,13 +4365,15 @@ async def connect(self) -> bool: | |||
|
|
|||
| try: | |||
| mws = [mw for mw in (cors_middleware, body_limit_middleware, security_headers_middleware) if mw is not None] | |||
| self._app = web.Application(middlewares=mws, client_max_size=MAX_REQUEST_BYTES) | |||
| self._app = web.Application(middlewares=mws, client_max_size=AUDIO_MAX_REQUEST_BYTES) | |||
There was a problem hiding this comment.
This lifts aiohttp's global body limit for every route. The route-specific middleware only branches when Content-Length is present, so chunked non-audio requests now reach 100 MB instead of the existing 10 MB cap. Keep the global non-audio limit or enforce a route-aware streaming limit that also covers chunked bodies.
There was a problem hiding this comment.
Fixed in 4b235630a. The app keeps the 100 MB outer ceiling required by audio routes, while body_limit_middleware now clones each request with its route-specific limit so request.read()/json() enforce 10 MB for chunked non-audio requests too. Multipart audio bytes are counted explicitly because aiohttp multipart reads bypass client_max_size. Added regression coverage for both chunked paths.
| return await self._stream_file_response( | ||
| request, | ||
| actual_path, | ||
| media_type, |
There was a problem hiding this comment.
The MIME type comes from the requested suffix, not the generated artifact. For example, Edge TTS always writes MP3 bytes (tools/tts_tool.py:_generate_edge_tts), so response_format=wav can return MP3 data as audio/wav. Transcode, restrict formats by provider, or infer the actual output type before sending the response.
There was a problem hiding this comment.
Fixed in 4b235630a. Speech responses now sniff the generated artifact signature and derive Content-Type from the actual bytes rather than the requested suffix. Added an Edge-TTS regression test where response_format=wav produces MP3 bytes and is correctly returned as audio/mpeg. The public audio endpoints are now documented as well.
There was a problem hiding this comment.
also sempai finally noticed me lol (robot sempai)
4b23563 to
d674153
Compare
|
I reproduced the two current review findings on this PR and prepared a hardened continuation while preserving the authorship of the original commits: https://github.com/dliu120/hermes-agent/tree/feat/api-audio-salvage The branch is based on the original audio commits and adds:
Verification on
I did not open a competing upstream PR. Please cherry-pick any or all of the follow-up commits if this direction matches the contract you want here; I am also happy to rework the branch around maintainer feedback. |
What does this PR do?
This exposes Hermes' existing voice capabilities through the API server by adding OpenAI-style audio endpoints for transcription and speech synthesis.
Today the API server already supports chat and responses, but third-party UIs still cannot use Hermes for voice because
/v1/audio/transcriptionsand/v1/audio/speechare missing. This change closes that gap by wiring the API surface to the existing STT/TTS helpers, streaming generated audio back to clients, and exposing the Hermes-specific metadata headers browser clients need.Related Issue
N/A
Type of Change
Changes Made
POST /v1/audio/transcriptionswith multipart upload handling,json/text/verbose_jsonresponses, provider metadata headers, and transcript hallucination filteringPOST /v1/audio/speechwith streamed audio responses formp3,wav,opus, andoggX-Hermes-Session-Idand read STT/TTS metadata headers/v1/audio/*routes so uploaded audio can be processedgateway/platforms/api_server.pyHow to Test
curl -X POST http://localhost:8642/v1/audio/transcriptions -H "Authorization: Bearer $API_SERVER_KEY" -F "file=@sample.webm" -F "model=whisper-1" -F "response_format=verbose_json"and verify you get a transcript payload plusX-Hermes-STT-Provider/X-Hermes-Transcript-Filteredheaders.curl -X POST http://localhost:8642/v1/audio/speech -H "Authorization: Bearer $API_SERVER_KEY" -H "Content-Type: application/json" -d '{"input":"hello from Hermes","response_format":"mp3"}' --output speech.mp3 -D headers.txtand verify streamed audio plusX-Hermes-TTS-Provider/X-Hermes-Voice-Compatibleheaders./mnt/samesung/ai/util/hermes-agent/.venv/bin/python -m pytest tests/gateway/test_api_server.py -qfrom the branch checkout and verify the API-server suite stays green.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass/mnt/samesung/ai/util/hermes-agent/.venvDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
python3 -m py_compile gateway/platforms/api_server.py/mnt/samesung/ai/util/hermes-agent/.venv/bin/python -m pytest tests/gateway/test_api_server.py -q→107 passed/mnt/samesung/ai/util/hermes-agent/.venv/bin/python -m pytest tests/ -q, but the repository is not currently full-suite green in this environment