软件包:@onesay/sdk;许可证:Apache-2.0。
环境
每个环境都有自己的中枢API和Realtime WebSocket地址。
| 环境 | 中枢API | Realtime WebSocket |
|---|---|---|
| 生产环境 | https://api.onesay.com/v1 | wss://realtime.onesay.com/v1 |
要连接其他地域的节点,请用配置中的地址调用setCustomEndpoints,并使用environment: "custom"。
房间事件
SDK的事件名称,以及它对应的OneSay事件。
Connected->room.connectedDisconnected->room.disconnectedReconnecting->room.reconnectingReconnected->room.reconnectedParticipantJoined->participant.joinedParticipantLeft->participant.leftSignalOpened->signal.openedSignalEnded->signal.endedError->error
任务事件
SDK的事件名称,以及它对应的OneSay事件。
Created->task.createdStarted->task.startedTranscriptPartial->artifact.deltaTranscriptFinal->artifact.finalizedCompleted->task.completedFailed->task.failedCancelled->task.cancelled
在浏览器中,SDK只通过你提供的Token提供器进行身份验证,从不使用密钥。语音任务发送你传入的音频:16000 Hz单声道pcm_s16le;SDK不会为此打开麦克风,也从不静默丢弃音频。SDK还提供转换采样缓冲区的辅助函数。
语音任务
- 入口:
client.tasks.create,client.tasks.get,client.tasks.list,client.tasks.cancel,RealtimeClient - 传输:onesay.realtime.v1 WebSocket with canonical PCM frames, contiguous ACK, unacked-only replay and bounded resume
- 结果:Task and Artifact readback
实时语音(RTC)
- 入口:
client.rtc.connect,client.rtc.get,client.rtc.revoke,client.rtc.endPublication,client.rtc.agents.create,client.rtc.agents.get,client.rtc.agents.stop - 传输:OneSay RTC session over the locked native SDK, loaded lazily on the first RTC operation
- 结果:publications, subscriptions, packets, streams, RPC, data tracks and explicit Agent executions
RTC会话状态
connectedreconnectingclosed
会话状态是这个客户端观察到的状态。每次授权都由服务端决定;只有服务端报告撤销已生效,撤销才算完成。
能力
| 能力 | 支持情况 | 说明 |
|---|---|---|
| 语音任务(WSS、ACK、重放、恢复) | 支持 | Supported (browser, Node) |
| RTC音频 | 支持 | Publish, subscribe, mute, playback (browser) |
| 数据包 | 支持 | Send and receive |
| 数据流 | 支持 | Send and receive |
| RPC | 支持 | Call and handle |
| DataTrack | 支持 | Supported (livekit-client 2.22.3) |
| Agent | 支持 | Explicit Agent executions and read-only Agent state |
| 状态、设备、错误和释放 | 支持 | Session state, quality, microphone selection, OneSay errors, close |
| 所选模式的媒体加密 | 视环境而定 | Conditional: where the browser can run the packaged worker |
不公开:native room, track and participant objects;native token or connection material;native SDK types;an escape hatch to the native SDK。不支持的能力会返回明确的错误。
参见SDK能力和兼容性。