import asyncioimport jsonimport websocketsimport base64class RimeClient: def __init__(self, speaker, api_key): self.url = f"wss://users-ws.rime.ai/ws3?speaker={speaker}&modelId=mistv3&audioFormat=mp3" self.auth_headers = { "Authorization": f"Bearer {api_key}" } self.audio_data = b'' async def send_messages(self, websocket, messages): for message in messages: await websocket.send(json.dumps(message)) async def handle_audio(self, websocket): while True: try: audio = await websocket.recv() except websockets.exceptions.ConnectionClosedOK: break message = json.loads(audio) if message['type'] == 'chunk': self.audio_data += base64.b64decode(message['data']) if message['type'] == 'timestamps': print("Rime model pronounced the words...\n") for w, t in zip(message['word_timestamps']['words'], message['word_timestamps']['start']): print(f"'{w}' at time {t}") async def run(self, messages): async with websockets.connect(self.url, additional_headers=self.auth_headers) as websocket: await asyncio.gather( self.send_messages(websocket, messages), self.handle_audio(websocket), ) def save_audio(self, file_path): with open(file_path, 'wb') as f: f.write(self.audio_data) print(f"\n Audio saved at {file_path}")message = [ {"text": "This "}, {"text": "is "}, {"text": "an "}, {"text": "incomplete "}, {"text": "sentence "}, {"operation": "eos"},]client = RimeClient("cove", api_key="YOUR_API_KEY")asyncio.run(client.run(message))client.save_audio("output.mp3")
Legacy WebSockets
Websockets JSON
Mist v3 JSON WebSocket (/ws3): structured events with base64 audio chunks and word-level timestamps.
import asyncioimport jsonimport websocketsimport base64class RimeClient: def __init__(self, speaker, api_key): self.url = f"wss://users-ws.rime.ai/ws3?speaker={speaker}&modelId=mistv3&audioFormat=mp3" self.auth_headers = { "Authorization": f"Bearer {api_key}" } self.audio_data = b'' async def send_messages(self, websocket, messages): for message in messages: await websocket.send(json.dumps(message)) async def handle_audio(self, websocket): while True: try: audio = await websocket.recv() except websockets.exceptions.ConnectionClosedOK: break message = json.loads(audio) if message['type'] == 'chunk': self.audio_data += base64.b64decode(message['data']) if message['type'] == 'timestamps': print("Rime model pronounced the words...\n") for w, t in zip(message['word_timestamps']['words'], message['word_timestamps']['start']): print(f"'{w}' at time {t}") async def run(self, messages): async with websockets.connect(self.url, additional_headers=self.auth_headers) as websocket: await asyncio.gather( self.send_messages(websocket, messages), self.handle_audio(websocket), ) def save_audio(self, file_path): with open(file_path, 'wb') as f: f.write(self.audio_data) print(f"\n Audio saved at {file_path}")message = [ {"text": "This "}, {"text": "is "}, {"text": "an "}, {"text": "incomplete "}, {"text": "sentence "}, {"operation": "eos"},]client = RimeClient("cove", api_key="YOUR_API_KEY")asyncio.run(client.run(message))client.save_audio("output.mp3")
The Rime API authenticates every request with a bearer token in the Authorization header: Authorization: Bearer YOUR_API_KEY. See API authentication for how to create a key.
This page describes the legacy /ws3 endpoint, which keeps working for existing integrations. For a new Mist v3 integration, use Mist v3 WebSocket v1.
This WebSocket sends and receives JSON messages. Compared with the plain-text WebSocket, it adds word-level timestamps, a done event after each synthesis, and contextId tagging. You pass every synthesis parameter as a query parameter when you open the connection, and those settings apply for the life of the connection.The API buffers input until it detects a sentence boundary, typically at ., ?, or !, so synthesis starts once it has enough text for natural prosody. The wait is most noticeable on the first sentence. After that, later text usually arrives while earlier audio is still playing, and the buffering becomes largely invisible. To change when synthesis starts, set segment.
Sends text for synthesis. This is the message your client sends most often.schema:
type TextMessage = { text: string, contextId?: string,}
examples:
{ "text": "this is the minimum text message."}{ "text": "this is a text message with a context id.", "contextId": "159495B1-5C81-4C73-A51A-9CE10A08239E"}
If you set contextId, the server attaches it to the events it sends back for that text. The server tracks one context ID at a time.
Discards buffered text that hasn’t been synthesized yet. Send it when the user interrupts. It doesn’t cancel a synthesis already in progress, so stop playback in your client and drop any audio that still arrives.
data holds base64-encoded audio in the audioFormat set at connection time. Decode each chunk and append the bytes in order to rebuild the audio. With pcm, a chunk can end mid-sample, so keep whole samples. If the text that produced this audio had a contextId, the event includes it.
The server sends word-level timestamps alongside the audio chunks, so your client can tell which words have been spoken at any point. The server estimates them from the text rather than measuring the audio. Treat them as approximate. When the user talks over the output, map the playback position back to the last word they actually heard.
Timestamps are emitted only when lang is en/eng or es/spa, or when lang is omitted. Requests in any other language receive chunk and done events with no timestamps event and no error (this includes fr and de). Don’t block playback while waiting for a timestamps event.
The three arrays inside word_timestamps are the same length and index-aligned: for a given index i, words[i] is spoken from start[i] to end[i]. Times are in seconds, measured from the beginning of the audio for the current synthesis. If a context id was attached to the text that produced this audio, it is included on the event.Example payload:
After the last audio chunk for a synthesis batch has been sent, the server emits a done event. This signals that the current synthesis is fully complete. If the client sends more text and triggers further synthesis, another done will follow.
type DoneEvent = { type: "done", contextId: string | null,}
If a message is malformed or unexpected, the server responds immediately with an error event. The server does not close the connection and keeps accepting well-formed messages, so your client decides whether to close it.
type ErrorEvent = { type: "error", message: string,}
When set to true, adds pauses between words enclosed in angle brackets. The number inside the brackets specifies the pause duration in milliseconds.
Example: Hi. <200> I'd love to have a conversation with you. adds a 200ms pause. Learn more about custom pauses.
Comma-separated list of speed values applied to words in square brackets. Values < 1.0 speed up speech, > 1.0 slow it down.
Example: “This is [slow] and [fast]”, use “3, 0.5” to make “slow” slower and “fast” faster.
Controls how text is segmented for synthesis. Available options:
“immediate” - Synthesizes text immediately without waiting for complete sentences
“never” - Never segments the text, waits for explicit flush or EOS
“bySentence” (default) - Waits for complete sentences before synthesis
import asyncioimport jsonimport websocketsimport base64class RimeClient: def __init__(self, speaker, api_key): self.url = f"wss://users-ws.rime.ai/ws3?speaker={speaker}&modelId=mistv3&audioFormat=mp3" self.auth_headers = { "Authorization": f"Bearer {api_key}" } self.audio_data = b'' async def send_messages(self, websocket, messages): for message in messages: await websocket.send(json.dumps(message)) async def handle_audio(self, websocket): while True: try: audio = await websocket.recv() except websockets.exceptions.ConnectionClosedOK: break message = json.loads(audio) if message['type'] == 'chunk': self.audio_data += base64.b64decode(message['data']) if message['type'] == 'timestamps': print("Rime model pronounced the words...\n") for w, t in zip(message['word_timestamps']['words'], message['word_timestamps']['start']): print(f"'{w}' at time {t}") async def run(self, messages): async with websockets.connect(self.url, additional_headers=self.auth_headers) as websocket: await asyncio.gather( self.send_messages(websocket, messages), self.handle_audio(websocket), ) def save_audio(self, file_path): with open(file_path, 'wb') as f: f.write(self.audio_data) print(f"\n Audio saved at {file_path}")message = [ {"text": "This "}, {"text": "is "}, {"text": "an "}, {"text": "incomplete "}, {"text": "sentence "}, {"operation": "eos"},]client = RimeClient("cove", api_key="YOUR_API_KEY")asyncio.run(client.run(message))client.save_audio("output.mp3")
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Rime Docs","colors":{"primary":"#1DADC7","light":"#4FC3D9","dark":"#147D91"},"logo":{"light":"https://mintcdn.com/rimelabs/qBNCx7nLDEv-FtZq/logo/light.png?fit=max\u0026auto=format\u0026n=qBNCx7nLDEv-FtZq\u0026q=85\u0026s=b74ee12f1a1075334db19359152c2f8a","dark":"https://mintcdn.com/rimelabs/qBNCx7nLDEv-FtZq/logo/dark.png?fit=max\u0026auto=format\u0026n=qBNCx7nLDEv-FtZq\u0026q=85\u0026s=d13aea3ecd100ed7ca31c828e93b123f","href":"/"},"favicon":"https://mintcdn.com/rimelabs/Z6D4LmkrIeBeHoml/rime-social-logo.png?fit=max\u0026auto=format\u0026n=Z6D4LmkrIeBeHoml\u0026q=85\u0026s=41aa58d6143a74b8c11b8d9713e77344","api":{"playground":{"display":"none"}},"background":{"color":{"light":"#F0E9DD","dark":"#2E2A25"}},"navbar":{"links":[{"href":"https://www.rimestat.us","label":"Status"}],"primary":{"type":"button","label":"Dashboard","href":"https://app.rime.ai"}},"footer":{"links":[{"header":"Rime","items":[{"label":"Status","href":"https://www.rimestat.us"},{"label":"Dashboard","href":"https://app.rime.ai"}]}]},"integrations":{"posthog":{"apiKey":"phc_BzP0KaTCqAgNZjeq3B4EjaQPRKzthbvQZxTXBh6K7Yp","apiHost":"https://n.rime.ai","sessionRecording":true}},"errors":{"404":{"redirect":false,"title":"We can't find that page.","description":"This page does not exist or has moved.\n\n**[API reference](/docs/api-reference)**: every TTS, WebSocket, and utility endpoint\n\n**[WebSocket overview](/docs/websockets)**: endpoint and transport choices\n\n**[Five-minute quickstart](/docs/quickstart-five-minute)**: generate an audio clip\n\n**[Models](/docs/models)**: Coda and Mist v3\n\n**[Voices](/docs/voices)**: the current voice catalog\n\n**[API authentication](/docs/api-authentication)**: create and use API keys\n\n**[Changelog](/docs/changelog)**: recent changes and release notes\n\nThe machine-readable index is available at [/llms.txt](/llms.txt).\n\n[Report a broken link](mailto:support@rime.ai)."}},"contextual":{"options":["copy","view","chatgpt","claude","cursor","vscode","mcp","add-mcp"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"rimelabs","hasAudioNarration":false,"actualSubdomain":"rimelabs","customDomains":["docs.rime.ai"],"gitSource":{"type":"github","owner":"rimelabs","repo":"rime","deployBranch":"main","contentDirectory":"web/docs","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6aed33fa7515cb0164b5afa1","clientVersion":"0.0.4088","searchFilterCounts":[{"language":"default","tag":"Documentation","count":85},{"language":"default","tag":"Build with Rime","count":67},{"language":"default","tag":"Text-to-speech","count":49},{"language":"default","tag":"API Reference","count":22},{"language":"default","tag":"Customizing speech","count":21},{"language":"default","tag":"Prism","count":13},{"language":"default","tag":"Integrations","count":12},{"language":"default","tag":"MCP Server","count":12},{"language":"default","tag":"CLI Reference","count":10},{"language":"default","tag":"Pronunciation","count":10}]},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"comment-mode","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":".chat-assistant-floating-input,chat-assistant-floating-input{display:none!important}a[href=\"/\"]:has(>.nav-logo){display:inline-flex;align-items:center;gap:0.5rem}a[href=\"/\"]:has(>.nav-logo)::after{color:rgb(24 24 27);content:\"docs\" / \"\";font-size:1rem;font-weight:600;letter-spacing:-0.025em;line-height:1}html.dark a[href=\"/\"]:has(>.nav-logo)::after{color:rgb(244 244 245)}html[data-current-path=\"/\"] .nav-tabs-item[data-active=\"true\"]{color:rgb(75 85 99);text-shadow:none}html.dark[data-current-path=\"/\"] .nav-tabs-item[data-active=\"true\"]{color:rgb(156 163 175)}html[data-current-path=\"/\"] .nav-tabs-item[data-active=\"true\"]>div{background-color:transparent!important}#topbar-cta-button a>span.absolute{background-color:#24211d!important}#topbar-cta-button a span,#topbar-cta-button a svg{color:#f8f3ea!important}html.dark #topbar-cta-button a>span.absolute{background-color:#f8f3ea!important}html.dark #topbar-cta-button a span,html.dark #topbar-cta-button a svg{color:#24211d!important}"}],"page":{"pagePath":"api-reference/mistv3/websockets-json","slug":"/api-reference/mistv3/websockets-json","pageMetadata":{"og:title":"Mist v3 JSON WebSocket API - Rime Docs","title":"Websockets JSON","description":"Mist v3 JSON WebSocket (/ws3): structured events with base64 audio chunks and word-level timestamps.","api":"GET wss://users-ws.rime.ai/ws3","authMethod":"bearer","href":"/api-reference/mistv3/websockets-json"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Mist v3 JSON WebSocket (/ws3): structured events with base64 audio chunks and word-level timestamps.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,em:`em`,li:`li`,p:`p`,pre:`pre`,span:`span`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Note,ParamField,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`The Rime API authenticates every request with a bearer token in the `,_jsx(_components.code,{children:`Authorization`}),` header: `,_jsx(_components.code,{children:`Authorization: Bearer YOUR_API_KEY`}),`. See `,_jsx(_components.a,{href:`/docs/api-authentication`,children:`API authentication`}),` for how to create a key.`]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[`This page describes the legacy `,_jsx(_components.code,{children:`/ws3`}),` endpoint, which keeps working for existing integrations. For a new Mist v3 integration, use `,_jsx(_components.a,{href:`/api-reference/mistv3/websocket-v1`,children:`Mist v3 WebSocket v1`}),`.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`overview`,children:`Overview`}),`\n`,_jsxs(_components.p,{children:[`This WebSocket sends and receives JSON messages. Compared with the `,_jsx(_components.a,{href:`/api-reference/mistv3/websockets`,children:`plain-text WebSocket`}),`, it adds word-level timestamps, a `,_jsx(_components.code,{children:`done`}),` event after each synthesis, and `,_jsx(_components.code,{children:`contextId`}),` tagging. You pass every synthesis parameter as a query parameter when you open the connection, and those settings apply for the life of the connection.`]}),`\n`,_jsxs(_components.p,{children:[`The API buffers input until it detects a sentence boundary, typically at `,_jsx(_components.code,{children:`.`}),`, `,_jsx(_components.code,{children:`?`}),`, or `,_jsx(_components.code,{children:`!`}),`, so synthesis starts once it has enough text for natural prosody. The wait is most noticeable on the first sentence. After that, later text usually arrives while earlier audio is still playing, and the buffering becomes largely invisible. To change when synthesis starts, set `,_jsx(_components.code,{children:`segment`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`messages`,children:`Messages`}),`\n`,_jsx(Heading,{level:`3`,id:`send`,children:`Send`}),`\n`,_jsx(Heading,{level:`4`,id:`text`,children:`Text`}),`\n`,_jsx(_components.p,{children:`Sends text for synthesis. This is the message your client sends most often.`}),`\n`,_jsx(_components.p,{children:`schema:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`type`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` TextMessage`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` text`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` contextId`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`?:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`examples:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`8`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"this is the minimum text message.\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"this is a text message with a context id.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"contextId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"159495B1-5C81-4C73-A51A-9CE10A08239E\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`If you set `,_jsx(_components.code,{children:`contextId`}),`, the server attaches it to the events it sends back for that text. The server tracks one context ID at a time.`]}),`\n`,_jsx(Heading,{level:`4`,id:`clear`,children:`Clear`}),`\n`,_jsx(_components.p,{children:`Discards buffered text that hasn’t been synthesized yet. Send it when the user interrupts. It doesn’t cancel a synthesis already in progress, so stop playback in your client and drop any audio that still arrives.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{ `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"operation\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"clear\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`4`,id:`flush`,children:`Flush`}),`\n`,_jsx(_components.p,{children:`Synthesizes whatever text is buffered, without waiting for a sentence boundary, and sends the audio.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{ `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"operation\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"flush\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`4`,id:`eos`,children:`EOS`}),`\n`,_jsx(_components.p,{children:`Synthesizes whatever text is buffered, sends the audio, and then the server closes the connection.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{ `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"operation\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` : `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"eos\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`receive`,children:`Receive`}),`\n`,_jsx(Heading,{level:`4`,id:`chunk`,children:`Chunk`}),`\n`,_jsx(_components.p,{children:`Carries a piece of the synthesized audio. This is the event your client receives most often.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`type`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Base64String`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`type`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` AudioChunkEvent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` type`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"chunk\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` data`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Base64String`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` contextId`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`data`}),` holds base64-encoded audio in the `,_jsx(_components.code,{children:`audioFormat`}),` set at connection time. Decode each chunk and append the bytes in order to rebuild the audio. With `,_jsx(_components.code,{children:`pcm`}),`, a chunk can end mid-sample, so `,_jsx(_components.a,{href:`/docs/streaming#keep-whole-samples-in-raw-pcm`,children:`keep whole samples`}),`. If the text that produced this audio had a `,_jsx(_components.code,{children:`contextId`}),`, the event includes it.`]}),`\n`,_jsx(Heading,{level:`4`,id:`timestamps`,children:`Timestamps`}),`\n`,_jsx(_components.p,{children:`The server sends word-level timestamps alongside the audio chunks, so your client can tell which words have been spoken at any point. The server estimates them from the text rather than measuring the audio. Treat them as approximate. When the user talks over the output, map the playback position back to the last word they actually heard.`}),`\n`,_jsxs(Warning,{children:[`Timestamps are emitted only when `,_jsx(_components.code,{children:`lang`}),` is `,_jsx(_components.code,{children:`en`}),`/`,_jsx(_components.code,{children:`eng`}),` or `,_jsx(_components.code,{children:`es`}),`/`,_jsx(_components.code,{children:`spa`}),`, or when `,_jsx(_components.code,{children:`lang`}),` is omitted. Requests in any other language receive `,_jsx(_components.code,{children:`chunk`}),` and `,_jsx(_components.code,{children:`done`}),` events with no `,_jsx(_components.code,{children:`timestamps`}),` event and no error (this includes fr and de). Don’t block playback while waiting for a timestamps event.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`9`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`type`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` TimestampsEvent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` type`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"timestamps\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` word_timestamps`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` words`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` start`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` number`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` end`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` number`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` contextId`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The three arrays inside `,_jsx(_components.code,{children:`word_timestamps`}),` are the same length and index-aligned: for a given index `,_jsx(_components.code,{children:`i`}),`, `,_jsx(_components.code,{children:`words[i]`}),` is spoken from `,_jsx(_components.code,{children:`start[i]`}),` to `,_jsx(_components.code,{children:`end[i]`}),`. Times are in seconds, measured from the beginning of the audio for the current synthesis. If a context id was attached to the text that produced this audio, it is included on the event.`]}),`\n`,_jsx(_components.p,{children:`Example payload:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`9`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"timestamps\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"word_timestamps\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"words\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Testing\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"mistv3\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"timestamps.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"start\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0.35396`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1.41584`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"end\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0.35396`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1.41584`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3.18564`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"contextId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`null`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`4`,id:`done`,children:`Done`}),`\n`,_jsxs(_components.p,{children:[`After the last audio chunk for a synthesis batch has been sent, the server emits a `,_jsx(_components.code,{children:`done`}),` event. This signals that the current synthesis is fully complete. If the client sends more text and triggers further synthesis, another `,_jsx(_components.code,{children:`done`}),` will follow.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`type`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` DoneEvent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` type`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"done\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` contextId`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`When exactly `,_jsx(_components.code,{children:`done`}),` fires depends on the `,_jsx(_components.code,{children:`segment`}),` setting. See `,_jsx(_components.a,{href:`/docs/websockets-segment`,children:`Segmentation and behavior settings`}),` for full details.`]}),`\n`,_jsx(Heading,{level:`4`,id:`error`,children:`Error`}),`\n`,_jsxs(_components.p,{children:[`If a message is malformed or unexpected, the server responds immediately with an `,_jsx(_components.code,{children:`error`}),` event. The server does `,_jsx(_components.em,{children:`not`}),` close the connection and keeps accepting well-formed messages, so your client decides whether to close it.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`type`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` ErrorEvent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` type`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"error\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` message`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`variable-parameters`,children:`Variable parameters`}),`\n`,_jsx(ParamField,{body:`speaker`,type:`string`,required:true,id:`param-speaker`,children:_jsxs(_components.p,{children:[`Must be a voice from the `,_jsx(_components.a,{href:`/docs/voices`,children:`Rime voice catalog`}),`.`]})}),`\n`,_jsx(ParamField,{body:`modelId`,type:`string`,default:`mistv3`,id:`param-model-id`,children:_jsxs(_components.p,{children:[`Set to `,_jsx(_components.code,{children:`mistv3`}),`.`]})}),`\n`,_jsx(ParamField,{body:`audioFormat`,type:`string`,id:`param-audio-format`,children:_jsxs(_components.p,{children:[`One of `,_jsx(_components.code,{children:`wav`}),`, `,_jsx(_components.code,{children:`mp3`}),` (or `,_jsx(_components.code,{children:`mpeg`}),`), `,_jsx(_components.code,{children:`ogg`}),` (Opus in OGG), `,_jsx(_components.code,{children:`webm`}),` (Opus in WebM), `,_jsx(_components.code,{children:`pcm`}),` (or `,_jsx(_components.code,{children:`l16`}),`), or `,_jsx(_components.code,{children:`mulaw`}),` (or `,_jsx(_components.code,{children:`pcmu`}),`). Unrecognized values fall back to `,_jsx(_components.code,{children:`wav`}),`.`]})}),`\n`,_jsx(ParamField,{body:`lang`,type:`string`,default:`eng`,id:`param-lang`,children:_jsxs(_components.p,{children:[`If provided, the language must match the language spoken by the selected speaker. Verify the pairing in the `,_jsx(_components.a,{href:`/docs/voices`,children:`Rime voice catalog`}),`.`]})}),`\n`,_jsx(ParamField,{body:`pauseBetweenBrackets`,type:`bool`,default:`false`,id:`param-pause-between-brackets`,children:_jsxs(_components.p,{children:[`When set to true, adds pauses between words enclosed in angle brackets. The number inside the brackets specifies the pause duration in milliseconds.\nExample: `,_jsx(_components.code,{children:`Hi. \u003c200> I'd love to have a conversation with you.`}),` adds a 200ms pause. Learn more about `,_jsx(_components.a,{href:`/docs/custom-pauses`,children:`custom pauses`}),`.`]})}),`\n`,_jsx(ParamField,{body:`samplingRate`,type:`int`,id:`param-sampling-rate`,children:_jsx(_components.p,{children:`The sampling rate in Hz. Default: 24000. Values above 24000 are upsampled.`})}),`\n`,_jsx(ParamField,{body:`inlineSpeedAlpha`,type:`string`,id:`param-inline-speed-alpha`,children:_jsx(_components.p,{children:`Comma-separated list of speed values applied to words in square brackets. Values \u003c 1.0 speed up speech, > 1.0 slow it down.\nExample: “This is [slow] and [fast]”, use “3, 0.5” to make “slow” slower and “fast” faster.`})}),`\n`,_jsx(ParamField,{body:`speedAlpha`,type:`float`,default:`1.0`,id:`param-speed-alpha`,children:_jsx(_components.p,{children:`Adjusts the speed of speech. Higher than 1.0 is faster and lower than 1.0 is slower.`})}),`\n`,_jsxs(ParamField,{body:`segment`,type:`string`,default:`bySentence`,id:`param-segment`,children:[_jsx(_components.p,{children:`Controls how text is segmented for synthesis. Available options:`}),_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`“immediate” - Synthesizes text immediately without waiting for complete sentences`}),`\n`,_jsx(_components.li,{children:`“never” - Never segments the text, waits for explicit flush or EOS`}),`\n`,_jsx(_components.li,{children:`“bySentence” (default) - Waits for complete sentences before synthesis`}),`\n`]})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"og:title":"Mist v3 JSON WebSocket API - Rime Docs","title":"Websockets JSON","description":"Mist v3 JSON WebSocket (/ws3): structured events with base64 audio chunks and word-level timestamps.","api":"GET wss://users-ws.rime.ai/ws3","authMethod":"bearer","href":"/api-reference/mistv3/websockets-json"}}},"mdxSourceWithNoJs":null,"noJsSplices":[[331,336,"RequestExample,Warni"],[556,573,"RequestExample)_missingMdxReference(`RequestExample`,true);if(!Warning)_missingM"],[31834,32262,",`\n`,_jsx(RequestExample,{children:_jsx(CodeBlock,{filename:`Python`,numberOfLines:`59`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`59`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` asyncio`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` json`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` websockets`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` base64`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` RimeClient`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` __init__`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`speaker`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`api_key`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.url `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"wss://users-ws.rime.ai/ws3?speaker=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`speaker`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u0026modelId=mistv3\u0026audioFormat=mp3\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.auth_headers `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Bearer `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.audio_data `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` b`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`''`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` send_messages`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`websocket`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`messages`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` message `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` messages:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` websocket.send(json.dumps(message))`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` handle_audio`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`websocket`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` while`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audio `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` websocket.recv()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` except`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` websockets.exceptions.ConnectionClosedOK:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` message `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` json.loads(audio)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` message[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'type'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'chunk'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.audio_data `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`+=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` base64.b64decode(message[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'data'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`])`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` message[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'type'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'timestamps'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Rime model pronounced the words...`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` w, t `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` zip`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(message[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'word_timestamps'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`][`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'words'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`], message[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'word_timestamps'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`][`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'start'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`w`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`' at time `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`t`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`messages`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` with`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` websockets.connect(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.url, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`additional_headers`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.auth_headers) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` websocket:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` asyncio.gather(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.send_messages(websocket, messages),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.handle_audio(websocket),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` )`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` save_audio`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`file_path`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` with`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` open`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(file_path, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'wb'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` f:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` f.write(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.audio_data)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` Audio saved at `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`file_path`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`message `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"This \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"is \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"an \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"incomplete \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"sentence \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"operation\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"eos\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` RimeClient(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"cove\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"YOUR_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`asyncio.run(client.run(message))`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client.save_audio(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"output.mp3\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}"]]},"mdxExtracts":{"tableOfContents":[{"title":"Overview","slug":"overview","depth":2,"children":[]},{"title":"Messages","slug":"messages","depth":2,"children":[{"title":"Send","slug":"send","depth":3,"children":[]},{"title":"Text","slug":"text","depth":4,"children":[]},{"title":"Clear","slug":"clear","depth":4,"children":[]},{"title":"Flush","slug":"flush","depth":4,"children":[]},{"title":"EOS","slug":"eos","depth":4,"children":[]},{"title":"Receive","slug":"receive","depth":3,"children":[]},{"title":"Chunk","slug":"chunk","depth":4,"children":[]},{"title":"Timestamps","slug":"timestamps","depth":4,"children":[]},{"title":"Done","slug":"done","depth":4,"children":[]},{"title":"Error","slug":"error","depth":4,"children":[]}]},{"title":"Variable parameters","slug":"variable-parameters","depth":2,"children":[]}],"codeExamples":{"request":{"type":"RequestExample","children":[{"filename":"Python","html":"\u003cpre class=\"shiki shiki-themes github-light-default dark-plus\" style=\"background-color:#ffffff;--shiki-dark-bg:#0B0C0E;color:#1f2328;--shiki-dark:#D4D4D4\" language=\"python\">\u003ccode language=\"python\" numberOfLines=\"59\">\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">import\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> asyncio\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">import\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> json\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">import\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websockets\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">import\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> base64\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">class\u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#4EC9B0\"> RimeClient\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> def\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#DCDCAA\"> __init__\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">speaker\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">api_key\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">):\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.url \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> f\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"wss://users-ws.rime.ai/ws3?speaker=\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">{\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">speaker\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">}\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\u0026#x26;modelId=mistv3\u0026#x26;audioFormat=mp3\"\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.auth_headers \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> {\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> \"Authorization\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">f\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"Bearer \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">{\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">api_key\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">}\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> }\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.audio_data \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> b\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">''\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> async\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> def\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\"> send_messages\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">websocket\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">messages\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">):\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> for\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> message \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">in\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> messages:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> await\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websocket.send(json.dumps(message))\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> async\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> def\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\"> handle_audio\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">websocket\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">):\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> while\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> True\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> try\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> audio \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> await\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websocket.recv()\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> except\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websockets.exceptions.ConnectionClosedOK:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> break\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> message \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> json.loads(audio)\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> if\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> message[\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">'type'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">] \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">==\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> 'chunk'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.audio_data \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">+=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> base64.b64decode(message[\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">'data'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">])\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> if\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> message[\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">'type'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">] \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">==\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> 'timestamps'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#DCDCAA\"> print\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"Rime model pronounced the words...\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D7BA7D\">\\n\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> for\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> w, t \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">in\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#DCDCAA\"> zip\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(message[\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">'word_timestamps'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">][\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">'words'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">], message[\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">'word_timestamps'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">][\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">'start'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">]):\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#DCDCAA\"> print\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">f\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"'\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">{\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">w\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">}\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">' at time \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">{\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">t\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">}\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> async\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> def\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\"> run\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">messages\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">):\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> async\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> with\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websockets.connect(\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.url, \u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\">additional_headers\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.auth_headers) \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">as\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websocket:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> await\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> asyncio.gather(\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.send_messages(websocket, messages),\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.handle_audio(websocket),\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> )\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> def\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\"> save_audio\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">file_path\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">):\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> with\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#DCDCAA\"> open\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(file_path, \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">'wb'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">) \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">as\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> f:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> f.write(\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.audio_data)\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#DCDCAA\"> print\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">f\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D7BA7D\">\\n\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> Audio saved at \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">{\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">file_path\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">}\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">message \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> [\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> {\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"text\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"This \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">},\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> {\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"text\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"is \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">},\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> {\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"text\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"an \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">},\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> {\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"text\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"incomplete \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">},\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> {\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"text\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"sentence \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">},\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> {\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"operation\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"eos\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">},\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">]\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">client \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> RimeClient(\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"cove\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\">api_key\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"YOUR_API_KEY\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">asyncio.run(client.run(message))\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">client.save_audio(\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"output.mp3\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)\u003c/span>\u003c/span>\n\u003c/code>\u003c/pre>"}],"attributes":[]}},"endpoint":{"title":"Websockets JSON","path":"/ws3","servers":[{"url":"wss://users-ws.rime.ai"}],"method":"get","request":{"security":[{"title":"Bearer Auth","parameters":{"header":{"Authorization":{"type":"http","scheme":"bearer","description":"Bearer authentication header of the form `Bearer \u003ctoken>`, where `\u003ctoken>` is your auth token."}},"query":{},"cookie":{}}}],"parameters":{"query":{},"header":{},"cookie":{},"path":{}},"body":{"application/json":{"schemaArray":[{"type":"object","properties":{"speaker":[{"type":"string","description":"Must be a voice from the Rime voice catalog .","required":true}],"modelId":[{"type":"string","description":"Set to `mistv3` ."}],"audioFormat":[{"type":"string","description":"One of `wav` , `mp3` (or `mpeg` ), `ogg` (Opus in OGG), `webm` (Opus in WebM), `pcm` (or `l16` ), or `mulaw` (or `pcmu` ). Unrecognized values fall back to `wav` ."}],"lang":[{"type":"string","description":"If provided, the language must match the language spoken by the selected speaker. Verify the pairing in the Rime voice catalog ."}],"pauseBetweenBrackets":[{"type":"boolean","description":"When set to true, adds pauses between words enclosed in angle brackets. The number inside the brackets specifies the pause duration in milliseconds. Example: `Hi. \u003c200> I'd love to have a conversation with you.` adds a 200ms pause. Learn more about custom pauses ."}],"samplingRate":[{"type":"integer","description":"The sampling rate in Hz. Default: 24000. Values above 24000 are upsampled."}],"inlineSpeedAlpha":[{"type":"string","description":"Comma-separated list of speed values applied to words in square brackets. Values \u003c 1.0 speed up speech, > 1.0 slow it down. Example: “This is [slow] and [fast]”, use “3, 0.5” to make “slow” slower and “fast” faster."}],"speedAlpha":[{"type":"number","description":"Adjusts the speed of speech. Higher than 1.0 is faster and lower than 1.0 is slower."}],"segment":[{"type":"string","description":"Controls how text is segmented for synthesis. Available options: “immediate” - Synthesizes text immediately without waiting for complete sentences “never” - Never segments the text, waits for explicit flush or EOS “bySentence” (default) - Waits for complete sentences before synthesis"}]}}],"examples":{"example":{"value":{"speaker":"\u003cstring>","modelId":"\u003cstring>","audioFormat":"\u003cstring>","lang":"\u003cstring>","pauseBetweenBrackets":true,"samplingRate":123,"inlineSpeedAlpha":"\u003cstring>","speedAlpha":123,"segment":"\u003cstring>"}}}}}},"response":{},"deprecated":false}},"jsLinks":[],"subdomain":"rimelabs","siteName":"Rime Docs","title":"Mist v3 JSON WebSocket API - Rime Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-22T16:11:34.362Z","originalFileLocation":"api-reference/mistv3/websockets-json.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Mist v3 JSON WebSocket (/ws3): structured events with base64 audio chunks and word-level timestamps.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Rime Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Mist v3 JSON WebSocket API - Rime Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Mist v3 JSON WebSocket (/ws3): structured events with base64 audio chunks and word-level timestamps.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Rime Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.rime.ai/api-reference/mistv3/websockets-json\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://rimelabs.mintlify.site/_mintlify/api/og/v2?division=Legacy+WebSockets\u0026amp;title=Websockets+JSON\u0026amp;description=Mist+v3+JSON+WebSocket+%28%2Fws3%29%3A+structured+events+with+base64+audio+chunks+and+word-level+timestamps.\u0026amp;theme=227fbc3aedf112565fcf6961\u0026amp;signature=f05f711983c59bd2fcce223637494a722a8580fb1bea09205c83931d41576db6\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Mist v3 JSON WebSocket API - Rime Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Mist v3 JSON WebSocket (/ws3): structured events with base64 audio chunks and word-level timestamps.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://rimelabs.mintlify.site/_mintlify/api/og/v2?division=Legacy+WebSockets\u0026amp;title=Websockets+JSON\u0026amp;description=Mist+v3+JSON+WebSocket+%28%2Fws3%29%3A+structured+events+with+base64+audio+chunks+and+word-level+timestamps.\u0026amp;theme=227fbc3aedf112565fcf6961\u0026amp;signature=f05f711983c59bd2fcce223637494a722a8580fb1bea09205c83931d41576db6\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Rime Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#1DADC7\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.rime.ai/api-reference/mistv3/websockets-json\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/mistv3/websockets-json.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.rime.ai/#organization\",\"name\":\"Rime Docs\",\"url\":\"https://docs.rime.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/rimelabs/qBNCx7nLDEv-FtZq/logo/light.png?fit=max\u0026auto=format\u0026n=qBNCx7nLDEv-FtZq\u0026q=85\u0026s=b74ee12f1a1075334db19359152c2f8a\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.rime.ai#website\",\"name\":\"Rime Docs\",\"url\":\"https://docs.rime.ai\",\"publisher\":{\"@id\":\"https://docs.rime.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.rime.ai/api-reference/mistv3/websockets-json#webpage\",\"url\":\"https://docs.rime.ai/api-reference/mistv3/websockets-json\",\"name\":\"Websockets JSON\",\"description\":\"Mist v3 JSON WebSocket (/ws3): structured events with base64 audio chunks and word-level timestamps.\",\"dateModified\":\"2026-10-22T16:11:34.362Z\",\"isPartOf\":{\"@id\":\"https://docs.rime.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.rime.ai/api-reference/mistv3/websockets-json#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.rime.ai/api-reference/mistv3/websockets-json#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Mist v3 API reference\",\"item\":\"https://docs.rime.ai/api-reference/mistv3/http\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Legacy WebSockets\",\"item\":\"https://docs.rime.ai/api-reference/mistv3/websockets\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Websockets JSON\",\"item\":\"https://docs.rime.ai/api-reference/mistv3/websockets-json\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.rime.ai/api-reference/mistv3/websockets-json#apireference\",\"headline\":\"Websockets JSON\",\"name\":\"Websockets JSON\",\"description\":\"Mist v3 JSON WebSocket (/ws3): structured events with base64 audio chunks and word-level timestamps.\",\"url\":\"https://docs.rime.ai/api-reference/mistv3/websockets-json\",\"mainEntityOfPage\":{\"@id\":\"https://docs.rime.ai/api-reference/mistv3/websockets-json#webpage\"},\"dateModified\":\"2026-10-22T16:11:34.362Z\",\"publisher\":{\"@id\":\"https://docs.rime.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.rime.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Rime Docs\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Rime Docs","nav":{"global":null,"tabs":[{"tab":"Home","hidden":true,"searchable":true,"pages":[{"title":"Home","href":""}]},{"tab":"Documentation","pages":[{"title":"Documentation","href":"/docs/introduction"}]},{"tab":"API Reference","groups":[{"group":"Overview","pages":[{"title":"API reference index","href":"/docs/api-reference"},{"title":"API cheat sheet","icon":"list-check","href":"/docs/api-cheat-sheet"}]},{"group":"Coda API reference","pages":[{"title":"Streaming HTTP","api":"POST https://coda.api.rime.ai/","href":"/api-reference/coda/http"},{"group":"WebSocket v1","pages":[{"title":"Coda WebSocket API","sidebarTitle":"API reference","href":"/api-reference/coda/websocket-v1"},{"title":"JSON quickstart","href":"/api-reference/coda/websocket-v1-json"},{"title":"Protobuf quickstart","href":"/api-reference/coda/websocket-v1-protobuf"},{"title":"LiveKit integration","href":"/api-reference/coda/websocket-v1-livekit"}]},{"group":"Legacy WebSockets","pages":[{"title":"Legacy WebSocket (/ws)","sidebarTitle":"Legacy /ws","api":"GET wss://users-ws.rime.ai/ws","href":"/api-reference/coda/websockets"},{"title":"Legacy JSON WebSocket (/ws3)","sidebarTitle":"Legacy /ws3 JSON","api":"GET wss://users-ws.rime.ai/ws3","href":"/api-reference/coda/websockets-json"}]}]},{"group":"Mist v3 API reference","pages":[{"title":"Streaming HTTP","api":"POST https://mist.api.rime.ai/","href":"/api-reference/mistv3/http"},{"group":"WebSocket v1","pages":[{"title":"Mist v3 WebSocket API","sidebarTitle":"API reference","href":"/api-reference/mistv3/websocket-v1"}]},{"group":"Legacy WebSockets","pages":[{"title":"Websockets","description":"Mist v3 plain-text WebSocket (/ws): send text, receive raw audio bytes.","api":"GET wss://users-ws.rime.ai/ws","href":"/api-reference/mistv3/websockets"},{"title":"Websockets JSON","api":"GET wss://users-ws.rime.ai/ws3","href":"/api-reference/mistv3/websockets-json"}]}]},{"group":"Speech-to-text API reference","pages":[{"title":"Streaming WebSocket","description":"Stream audio to Rime speech-to-text over a WebSocket, without the SDK. This reference covers the connection, the messages, the start parameters, the limits, and long recordings, plus a complete Python client.","href":"/api-reference/stt/websockets"},{"title":"gRPC","href":"/api-reference/stt/grpc"}]},{"group":"Prism API reference","pages":[{"title":"Prism WebSocket","href":"/api-reference/prism/websocket"},{"title":"Prism LiveKit plugin reference","sidebarTitle":"LiveKit plugin","icon":"video","href":"/api-reference/prism/livekit"}]},{"group":"API Metadata","pages":[{"title":"List All Voices","api":"GET https://users.rime.ai/data/voices/all-v2.json","href":"/api-reference/data/voices-v2"},{"title":"List Voice Details","api":"GET https://users.rime.ai/data/voices/voice_details.json","href":"/api-reference/data/voice-details"}]},{"group":"Other APIs","pages":[{"title":"Coverage","sidebarTitle":"Vocabulary Coverage","api":"POST https://users.rime.ai/oov","href":"/api-reference/other/oov"},{"title":"Phonemize","sidebarTitle":"Phonemize Audio","api":"POST https://optimize.rime.ai/phonemize","href":"/api-reference/other/phonemize"},{"title":"Text Normalization","api":"POST https://optimize.rime.ai/textnorm","href":"/api-reference/other/textnorm"}]}]},{"tab":"SDK Reference","pages":[{"title":"SDK Reference","href":"/api-reference/sdk/overview"}]},{"tab":"CLI Reference","pages":[{"title":"CLI Reference","href":"/cli-reference/overview"}]},{"tab":"MCP Server","pages":[{"title":"MCP Server","href":"/mcp-reference/overview"}]}]},"basePath":"","title":"Mist v3 JSON WebSocket API - Rime Docs","buildId":"dpl_DTau1J5HqS9UTgVSDwGksstFWtPa","deploymentId":"dpl_DTau1J5HqS9UTgVSDwGksstFWtPa","dynamics":["c2aa737661","2b790eda92","b0f84f53ff"],"chunks":["OpenApiReferenceProvider-5FCzAcfS.js","utils-SLtAG4EZ.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-2DZi8ZMu.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-D7J3nkzE.js","snippetPresets-D0Alv0AH.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","conditional-requirements-CFM0id0Q.js","ApiExamples-BI4qNJ2c.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-BD3uyr8j.js","shallow-D8iEBr5z.js","getApiPlaygroundDisplay-CgNP4lzR.js","CodeSnippet-CX-QHuMs.js","CodeSnippets-VlXE-ZUf.js","Page-D9ithiIZ.js","getPastedJson-DYNQkZ1M.js","icon-CzacdwOi.js","MethodPill-2JVqoYKi.js","DuplicateIcon-_xVXs-U8.js","createIcon-BRHrweLo.js","DynamicMarkdown-mQG_iQiE.js","SectionHeading-DMpJzv8f.js","axios-vUo_bRtp.js"]}