fix: 流式转写服务的连通性测试改走流式客户端 - #7
Open
Syfer-Omestics wants to merge 1 commit into
Open
Syfer-Omestics wants to merge 1 commit into
Syfer-Omestics wants to merge 1 commit into
Conversation
The 连通性测试 button called transcribeAudio() unconditionally, which asserts an HTTP endpoint. Streaming providers (OpenAI Realtime transcription/translation, DashScope Paraformer) all use wss:// endpoints, so the assert fell through to its last branch and the button reported "转写服务地址协议不受支持" for every one of them — the WebSocket client was never reached. Recording itself worked; only the self-test was broken. Streaming profiles now probe through the same client recording uses: connect, stream one second of silence, and report whatever the server says. Silence does not trip VAD, so an empty transcript is a pass — the test answers "can it connect", not "can it hear". A server-side rejection (bad model name, no permission) usually arrives only after the first audio frame, hence the grace window before the verdict. createStreamingTranscriptionClient moves from main.ts to asr/clients.ts, next to the three client classes it constructs, so the settings tab can reach it without importing main. Also spell out in the endpoint help and the close-error hint that self-hosted and relayed OpenAI-compatible services often need the full path plus ?model=<name>: unlike the translation client, the transcription client uses the configured address verbatim. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Fixes #6
问题
runAsrConnectivityTest()无条件调transcribeAudio(),而后者第一件事就是assertSafeServiceEndpoint(p.endpoint, "http", "转写服务地址")。流式服务(OpenAI Realtime 转写 / 翻译、百炼 Paraformer)的端点全是wss://,既不匹配https:也不匹配http:,于是掉进getServiceEndpointSecurityIssue()最后那个return:WebSocket 客户端一次都没被碰到。录音路径是好的——
main.ts里那条兜底分支的注释早就写了「端点是wss://,HTTP 必失败」——只是连通性测试没跟上。改动
流式服务改用录音时同一套客户端自检。
testStreamingTranscribeConnectivity()建连、灌 1 秒静音、收网,把服务端说的话原样报出来。几个取舍:error事件。送完就判会漏掉它们,白报一个「连通成功」。await finish()。connect()挂掉时底层 socket 已经被 ws 关了,再等只是白白耗掉客户端那 5 秒收网超时,按钮干转。改走_safeClose()。createStreamingTranscriptionClient从main.ts搬到asr/clients.ts,和它 new 出来的那三个客户端类放一起,设置页才够得着(否则要 import main)。纯搬迁,逻辑没动。端点说明补一句
?model=。OpenAIRealtimeTranslationClient会自己拼?model=,OpenAIRealtimeTranscriptionClient是地址原样使用。官方端点没问题,但自建 / 中转的 OpenAI 兼容服务很多要求 URL 带?model=,不带直接 403,而设置项只写了「保持默认即可」。这里只改了说明文案和关闭时的报错提示,没有动拼 URL 的行为——给官方端点自动加?model=会把它从 transcription session 变成 conversation session,风险不该塞在这个 PR 里。要不要对齐两个客户端,留给你定。验证
npm run verify(lint + build + test)通过,434 + 5 个测试tests/streaming-connectivity-test.test.ts5 例:钉住原 bug 的那条http校验分支、静音探针的帧数与收网、首帧之后才到的服务端拒绝、握手失败不空等finish()、三个协议各自路由且端点原样透传wss://<host>/v1/realtime?model=<model>握手 101 →transcription_session.created→.delta/.completed正常出中文;不带?model=的地址 403main.js按仓库惯例一并重新构建提交了。🤖 Generated with Claude Code