VoiceAgentConnection interface
一個連接的雙向語音代理串流。
支援伺服器事件的 for await 一次迭代;第二次嘗試則會丟棄。
提前退出迴路(break或 return迴路體未被捕捉的錯誤)會作為副作用關閉連接。
未識別的伺服器事件類型以 VoiceAgentUnknownEvent 形式傳送,且不會中斷串流。 畸形事件仍會因協議錯誤而失敗。
- Extends
-
AsyncIterable<VoiceAgentRealtimeEvent>
方法
| cancel |
取消正在進行中的回應。 |
| clear |
清除緩衝的輸入音訊。 |
| clear |
在禮拜時清除待處理的音訊。 |
| close(number, string) | 優雅地關閉 WebSocket 連線。 |
| commit |
提交緩衝的輸入音訊。 |
| configure |
更新支援即時會話設定。 |
| dispose() | 這樣就能解除連結。 等價於 close()。 |
| request |
請求新的回應。 |
| send |
將 base64 編碼的音訊位元組附加到輸入緩衝區。 |
| send |
傳送任何產生的客戶端協定事件。 |
| send |
新增使用者文字項目,並預設要求回應。 |
| send |
回傳客戶端執行的函式結果給代理。 |
繼承的方法
| [async |
屬性詳細資料
closed
state
方法詳細資料
cancelResponse(VoiceAgentCancelResponseOptions)
取消正在進行中的回應。
function cancelResponse(options?: VoiceAgentCancelResponseOptions): Promise<void>
參數
- options
- VoiceAgentCancelResponseOptions
傳回
Promise<void>
clearInputAudio(VoiceAgentEventOptions)
清除緩衝的輸入音訊。
function clearInputAudio(options?: VoiceAgentEventOptions): Promise<void>
參數
- options
- VoiceAgentEventOptions
傳回
Promise<void>
clearOutputAudio(VoiceAgentEventOptions)
在禮拜時清除待處理的音訊。
function clearOutputAudio(options?: VoiceAgentEventOptions): Promise<void>
參數
- options
- VoiceAgentEventOptions
傳回
Promise<void>
close(number, string)
優雅地關閉 WebSocket 連線。
function close(code?: number, reason?: string): Promise<void>
參數
- code
-
number
- reason
-
string
傳回
Promise<void>
commitAudio(VoiceAgentEventOptions)
提交緩衝的輸入音訊。
function commitAudio(options?: VoiceAgentEventOptions): Promise<void>
參數
- options
- VoiceAgentEventOptions
傳回
Promise<void>
configureSession(VoiceAgentSessionUpdateConfig, VoiceAgentSessionUpdateOptions)
更新支援即時會話設定。
function configureSession(session: VoiceAgentSessionUpdateConfig, options?: VoiceAgentSessionUpdateOptions): Promise<void>
參數
- session
- VoiceAgentSessionUpdateConfig
- options
- VoiceAgentSessionUpdateOptions
傳回
Promise<void>
dispose()
這樣就能解除連結。 等價於 close()。
function dispose(): Promise<void>
傳回
Promise<void>
requestResponse(VoiceAgentResponseOptions)
請求新的回應。
function requestResponse(options?: VoiceAgentResponseOptions): Promise<void>
參數
- options
- VoiceAgentResponseOptions
傳回
Promise<void>
sendAudio(ArrayBuffer | Uint8Array, VoiceAgentEventOptions)
將 base64 編碼的音訊位元組附加到輸入緩衝區。
function sendAudio(audio: ArrayBuffer | Uint8Array, options?: VoiceAgentEventOptions): Promise<void>
參數
- audio
-
ArrayBuffer | Uint8Array
- options
- VoiceAgentEventOptions
傳回
Promise<void>
sendEvent(VoiceAgentClientEvent, VoiceAgentSendOptions)
傳送任何產生的客戶端協定事件。
function sendEvent(event: VoiceAgentClientEvent, options?: VoiceAgentSendOptions): Promise<void>
參數
- event
- VoiceAgentClientEvent
- options
- VoiceAgentSendOptions
傳回
Promise<void>
sendText(string, VoiceAgentSendTextOptions)
新增使用者文字項目,並預設要求回應。
function sendText(text: string, options?: VoiceAgentSendTextOptions): Promise<void>
參數
- text
-
string
- options
- VoiceAgentSendTextOptions
傳回
Promise<void>
sendToolOutput(string, string, VoiceAgentSendToolOutputOptions)
回傳客戶端執行的函式結果給代理。
function sendToolOutput(callId: string, output: string, options?: VoiceAgentSendToolOutputOptions): Promise<void>
參數
- callId
-
string
- output
-
string
- options
- VoiceAgentSendToolOutputOptions
傳回
Promise<void>
繼承的方法的詳細資料
[asyncIterator]()
function [asyncIterator](): AsyncIterator<VoiceAgentRealtimeEvent, any, any>
傳回
AsyncIterator<VoiceAgentRealtimeEvent, any, any>
繼承自 非同步運算者。[非同步運算器]