Repository navigation
fix(server): return plain text for response_format=text - #3874
Merged
LauraGPT merged 1 commit intoNov 11, 2026
Merged
Conversation
The packaged funasr-server handles response_format=text by wrapping the transcript in JSONResponse, so the body is a JSON string literal such as "say \"hi\"" with application/json. OpenAI's transcription API returns the bare transcript for this format, and the OpenAI Python SDK hands response.text straight back to the caller, so clients received the surrounding quotes and escaped characters as part of the transcript. Return PlainTextResponse for this branch. json and verbose_json are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
LauraGPT
added a commit
that referenced
this pull request
Nov 12, 2026
…esponses Correct the Product site CI failure exposed by #3874 without changing the handler or weakening security/format contracts. Preserve the 1.4.15 recipe and add visible, source-bound current-main notices. Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
Merged
LauraGPT
added a commit
that referenced
this pull request
Nov 12, 2026
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.
Summary
funasr-serveranswersresponse_format=texton/v1/audio/transcriptionswithJSONResponse(result["text"]), so the body is a JSON string literal ("say \"hi\"",application/json). OpenAI's transcription API returns the bare transcript fortext, and the OpenAI Python SDK returnsresponse.textdirectly for that format (openai.lib._parsing._audio.get_transcription_response_format_typemapstexttostr), so SDK and curl users receive the quotes and escape characters as part of the transcript.Fix: return
PlainTextResponsefor this branch.jsonandverbose_jsonare unchanged.Type of change
Validation
Environment: macOS arm64, Python 3.11.15, CPU-only torch 2.15.0, fastapi 0.162.4 / starlette 1.10.0, openai 3.49.0, pytest 9.2.0.
test_text_response_format_returns_plain_textintests/test_server_app_openai_segments.py(the stubbedfastapi.responsesmodule gains aPlainTextResponsestub). It fails onmain(the route returns the JSON-wrapped value) and passes with this change:python -m pytest -q tests/test_server_app_openai_segments.pygives 1 failed / 23 passed onmain, 24 passed here.tests/test_service_docs_contract.py,tests/test_openai_api_n8n_compat.py,tests/test_fun_asr_nano_openai_response.py,tests/test_openai_api_docker_validation.py,tests/test_docs_funasr_install_commands.pypass.tests/test_gradio_app.pyfails the same 19 cases onmainand here becausegradiois not installed in the test environment.create_app(device="cpu", preload_model="sensevoice")with a stubAutoModel,POST /v1/audio/transcriptions(response_format=text) throughfastapi.testclient.TestClientand throughopenai.OpenAI(..., http_client=TestClient).main:application/json, body"say \"hi\""; this branch:text/plain; charset=utf-8, bodysay "hi".python -m compileall funasr examples testsTestClientagainstcreate_app; no model weights, no GPU, no runningfunasr-serverprocess)User impact
OpenAI-compatible clients (OpenAI SDK, LiteLLM-style proxies, scripts migrating from Whisper) that request
response_format=textget the transcript itself.Notes for reviewers
srtandvttstill fall through to thejsonbranch; that is out of scope here.🤖 Generated with Claude Code