Conversation
🦋 Changeset detectedLatest commit: 9d9f0e3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 38 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
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
websocketURL, with binary protobuf and canonical protobuf JSON from@rimelabs/api@0.0.1.updateOptions(). Handle terminal Rime HTTP TTS errors through the existing error event without an unhandled background rejection.Python counterpart: livekit/agents#6978
Interface and data flow
flowchart TB subgraph MAIN["Before this PR"] M_TTS["rime.TTS"] M_MODE{"useWebsocket / baseURL"} M_HTTP["HTTP synthesis"] M_WS3["Legacy WS3<br/>JSON messages + aligned timestamps"] M_TTS --> M_MODE M_MODE -->|"HTTP mode"| M_HTTP M_MODE -->|"WebSocket mode"| M_WS3 end subgraph BRANCH["This PR"] TTS["rime.TTS"] SELECT{"Endpoint configuration"} TTS --> SELECT SELECT -->|"No websocketURL"| LEGACY{"Legacy mode"} LEGACY -->|"HTTP URL"| HTTP["ChunkedStream<br/>HTTP synthesis"] LEGACY -->|"WebSocket baseURL or<br/>useWebsocket=true"| WS3["SynthesizeStream + RimePool<br/>WS3 JSON + aligned timestamps"] SELECT -->|"websocketURL"| MODEL{"resolveOptions<br/>model resolution"} MODEL -->|"/coda/ws"| CODA["modelId = coda"] MODEL -->|"/mist/ws"| MIST["modelId = mistv3"] MODEL -->|"/ws"| DEDICATED["Dedicated endpoint<br/>explicit modelId required"] CODA --> V1 MIST --> V1 DEDICATED --> V1 V1["SynthesizeStream + RimePool<br/>sentence tokenizer + connection reuse"] V1 --> INPUT["pushText: send complete sentences<br/>flush: release buffered text locally<br/>endInput: send end<br/>close: cancel active context"] INPUT --> PROTOCOL{"websocketProtocol"} PROTOCOL -->|"binary, default"| BINARY["rime.v1.binary<br/>protobuf frames"] PROTOCOL -->|"json"| JSON["rime.v1.json<br/>canonical protobuf JSON"] BINARY --> WIRE JSON --> WIRE WIRE["RimeConnection<br/>ready, start, text*, end or cancel<br/>started, audio*, done"] WIRE --> AUDIO["RimeAudio<br/>PCM, PCMU, WAV, MP3, Ogg Opus, WebM Opus<br/>mono PCM frames at samplingRate"] end subgraph MODEL_STATE["Endpoint and model safety"] UPDATE["updateOptions"] UPDATE --> IDENTITY{"Model changed on the same<br/>normalized model endpoint?"} IDENTITY -->|"yes"| REJECT["Reject update"] IDENTITY -->|"no"| ALLOW["Accept valid options<br/>transport mode stays fixed"] ALLOW --> CONNECTION{"Full URL, API key,<br/>or protocol changed?"} CONNECTION -->|"yes"| POOL["Replace RimePool<br/>retire old pool after its streams finish"] CONNECTION -->|"no"| KEEP["Keep RimePool"] NORMAL["Model endpoint identity ignores query and trailing slash<br/>Normalizes scheme, host, and effective port<br/>Endpoint validation rejects fragments and user information"] NORMAL -.-> IDENTITY end subgraph STREAM_STATE["Per-stream state"] CURRENT["Current TTS options and RimePool"] CURRENT --> NEW["Create SynthesizeStream"] NEW --> SNAPSHOT["Copy options and retain pool<br/>Rime StreamTTS preserves stream metadata"] SNAPSHOT --> METRICS["Existing streams keep their model and endpoint<br/>after later TTS updates"] SNAPSHOT --> EVENTS["Forward metrics and errors<br/>to the owning Rime TTS"] end TTS -.-> UPDATE TTS -.-> CURRENTThe JS implementation uses one
SynthesizeStreamfor v1 and WS3, withRimeConnectionfor transport andRimeAudiofor decoding. V1 always uses sentence input. Itsflush()keeps the synthesis context open. V1 does not provide aligned timestamps.Testing
pnpm exec vitest run plugins/rime/src: 136 passed, 1 skipped. The service test requires API keys; live provider behavior was not verified.@livekit/agentsand@livekit/agents-plugin-rime, including TypeScript declarations: passed.git diff --check: passed.libmp3lameandlibopusonPATH.