你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。

VoiceAgentConnection interface

实时语音会话。

用一个 for await 循环读取服务器事件。 第二个迭代器投掷。 离开环路会关闭连接。 未识别的事件类型以 VoiceAgentUnknownEvent 的形式出现;格式错误的事件因协议错误而失败。

扩展

AsyncIterable<VoiceAgentRealtimeEvent>

属性

closed

连接关闭后问题解决。

state

当前连接状态。

方法

cancelResponse(VoiceAgentCancelResponseOptions)

取消正在进行的回复。

clearInputAudio(VoiceAgentEventOptions)

清除缓冲输入音频。

clearOutputAudio(VoiceAgentEventOptions)

在服务时清除待处理的音频。

close(number, string)

优雅地关闭了WebSocket连接。

commitAudio(VoiceAgentEventOptions)

提交缓冲的输入音频。

configureSession(VoiceAgentSessionUpdateConfig, VoiceAgentSessionUpdateOptions)

更新:支持的实时会话设置。

dispose()

释放连接。 等价于闭合()。

requestResponse(VoiceAgentResponseOptions)

请求新回复。

sendAudio(ArrayBuffer | Uint8Array, VoiceAgentEventOptions)

将原始音频字节发送到输入缓冲区。 SDK 负责处理 base64 编码。

sendEvent(VoiceAgentClientEvent, VoiceAgentSendOptions)

发送实时客户端事件。

sendText(string, VoiceAgentSendTextOptions)

添加用户文本项,并默认请求响应。

sendToolOutput(string, string, VoiceAgentSendToolOutputOptions)

返回客户端执行的函数结果给代理。

继承的方法

[asyncIterator]()

属性详细信息

closed

连接关闭后问题解决。

closed: Promise<VoiceAgentCloseResult>

属性值

state

当前连接状态。

state: VoiceAgentConnectionState

属性值

方法详细信息

cancelResponse(VoiceAgentCancelResponseOptions)

取消正在进行的回复。

function cancelResponse(options?: VoiceAgentCancelResponseOptions): Promise<void>

参数

返回

Promise<void>

clearInputAudio(VoiceAgentEventOptions)

清除缓冲输入音频。

function clearInputAudio(options?: VoiceAgentEventOptions): Promise<void>

参数

返回

Promise<void>

clearOutputAudio(VoiceAgentEventOptions)

在服务时清除待处理的音频。

function clearOutputAudio(options?: VoiceAgentEventOptions): Promise<void>

参数

返回

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>

参数

返回

Promise<void>

configureSession(VoiceAgentSessionUpdateConfig, VoiceAgentSessionUpdateOptions)

更新:支持的实时会话设置。

function configureSession(session: VoiceAgentSessionUpdateConfig, options?: VoiceAgentSessionUpdateOptions): Promise<void>

参数

返回

Promise<void>

dispose()

释放连接。 等价于闭合()。

function dispose(): Promise<void>

返回

Promise<void>

requestResponse(VoiceAgentResponseOptions)

请求新回复。

function requestResponse(options?: VoiceAgentResponseOptions): Promise<void>

参数

返回

Promise<void>

sendAudio(ArrayBuffer | Uint8Array, VoiceAgentEventOptions)

将原始音频字节发送到输入缓冲区。 SDK 负责处理 base64 编码。

function sendAudio(audio: ArrayBuffer | Uint8Array, options?: VoiceAgentEventOptions): Promise<void>

参数

audio

ArrayBuffer | Uint8Array

返回

Promise<void>

sendEvent(VoiceAgentClientEvent, VoiceAgentSendOptions)

发送实时客户端事件。

function sendEvent(event: VoiceAgentClientEvent, options?: VoiceAgentSendOptions): Promise<void>

参数

返回

Promise<void>

sendText(string, VoiceAgentSendTextOptions)

添加用户文本项,并默认请求响应。

function sendText(text: string, options?: VoiceAgentSendTextOptions): Promise<void>

参数

text

string

返回

Promise<void>

sendToolOutput(string, string, VoiceAgentSendToolOutputOptions)

返回客户端执行的函数结果给代理。

function sendToolOutput(callId: string, output: string, options?: VoiceAgentSendToolOutputOptions): Promise<void>

参数

callId

string

output

string

返回

Promise<void>

继承的方法详细信息

[asyncIterator]()

function [asyncIterator](): AsyncIterator<VoiceAgentRealtimeEvent, any, any>

返回

AsyncIterator<VoiceAgentRealtimeEvent, any, any>

继承自 异步可行。[异步传承器]