### Interaction Flow Source: https://help.aliyun.com/zh/model-studio/websocket-for-paraformer-real-time-service The interaction flow between the client and server for the Paraformer real-time service involves establishing a connection, starting a task, streaming audio, and managing task completion. ```APIDOC ## Interaction Flow The interaction flow between the client and server proceeds in the following order: 1. **Establish Connection:** The client establishes a WebSocket connection with the server. 2. **Start Task:** The client sends a `run-task` instruction to initiate the task and receives a `task-started` event from the server, indicating the task has begun. 3. **Send Audio Stream:** The client starts sending binary audio data (must be mono audio) and simultaneously receives `result-generated` events from the server, which contain the speech recognition results. 4. **Notify Task End:** The client sends a `finish-task` instruction to notify the server that the task is ending, and continues to receive `result-generated` events. 5. **Task Finished:** The client receives a `task-finished` event from the server, signaling the end of the task. 6. **Close Connection:** The client closes the WebSocket connection. ``` -------------------------------- ### WebSocket Endpoints Source: https://help.aliyun.com/zh/model-studio/websocket-for-paraformer-real-time-service The WebSocket URL for connecting to the Paraformer real-time speech recognition service is fixed. Two endpoints are provided: one for China Mainland and one for international access. The connection must use the 'wss://' protocol. ```APIDOC ## WebSocket Endpoints ### China Mainland `wss://dashscope.aliyuncs.com/api-ws/v1/inference` ### International `wss://dashscope-intl.aliyuncs.com/api-ws/v1/inference` **Note:** The URL must use the `wss://` protocol and remains constant. Authorization is set in the request header. ``` -------------------------------- ### Request Headers Source: https://help.aliyun.com/zh/model-studio/websocket-for-paraformer-real-time-service The following information must be included in the request headers for WebSocket communication. The Authorization header is crucial for authentication during the WebSocket handshake. ```APIDOC ## Request Headers | Parameter | Type | Required | Description | | --------------------- | ------ | -------- | ---------------------------------------------------------------------------------------------------------- | | Authorization | string | Yes | Authentication token, format: `Bearer `. Replace `` with your actual API Key. | | user-agent | string | No | Client identifier for server-side tracking. | | X-DashScope-WorkSpace | string | No | Aliyun Baichuan business space ID. | | X-DashScope-DataInspection | string | No | Enables data compliance detection. Defaults to not sent or `enable`. Enable only if necessary. | **Important:** Authorization is validated during the WebSocket handshake. Invalid or missing API Key will result in handshake failure with HTTP 401/403 errors. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.