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

VoiceAgentConnection interface

一个连接的双向语音代理流。

支持服务器 for await 事件的一次迭代;第二次尝试则丢弃。 提前退出环路(break或 return环体未被捕捉的错误)会作为副作用关闭连接。 未识别的服务器事件类型以 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)

将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)

将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>

继承自 异步可行。[异步迭代器]