VoiceAgentLiveConnection interface
GPT Liveの音声セッション。
1つの for await ループでイベントを読むか、 on、 off、 once リスナーを利用できます。
ループを離れるとセッションが終了します。 受信する音声チャンクはbase64文字列です。
- Extends
-
AsyncIterable<VoiceAgentLiveEvent>
プロパティ
| closed | 接続が切断された際に解決し、利用可能な場合はサービス確認およびエラーの詳細を表示します。 |
| session | 最新のセッション設定。 connect() が戻り次第利用可能。 |
| session |
サービスから提供された永続化された会話 ID を含む元の起動イベント。 |
| state | 現在の接続状態。 |
メソッド
継承されたメソッド
| [async |
プロパティの詳細
closed
接続が切断された際に解決し、利用可能な場合はサービス確認およびエラーの詳細を表示します。
closed: Promise<VoiceAgentLiveCloseResult>
プロパティ値
Promise<VoiceAgentLiveCloseResult>
session
最新のセッション設定。 connect() が戻り次第利用可能。
session: VoiceAgentLiveSessionResource
プロパティ値
sessionStarted
サービスから提供された永続化された会話 ID を含む元の起動イベント。
sessionStarted: LiveServerEventLiveSessionStarted
プロパティ値
state
メソッドの詳細
appendCommentary(string, VoiceAgentLiveAppendOptions)
モデルがユーザーに伝えるテキストを追加します。 これはコンテキストであり、ユーザーメッセージではありません。
function appendCommentary(content: string, options?: VoiceAgentLiveAppendOptions): Promise<void>
パラメーター
- content
-
string
- options
- VoiceAgentLiveAppendOptions
戻り値
Promise<void>
appendInstructions(string, VoiceAgentLiveAppendOptions)
ユーザーメッセージではなく、セッションに指示を追加します。
function appendInstructions(content: string, options?: VoiceAgentLiveAppendOptions): Promise<void>
パラメーター
- content
-
string
- options
- VoiceAgentLiveAppendOptions
戻り値
Promise<void>
appendThinking(string, VoiceAgentLiveAppendOptions)
モデルに話してもらうことなく背景コンテキストを追加します。 これを秘密を隠すために使わないでください。
function appendThinking(content: string, options?: VoiceAgentLiveAppendOptions): Promise<void>
パラメーター
- content
-
string
- options
- VoiceAgentLiveAppendOptions
戻り値
Promise<void>
close(number, string)
セッションを終了し、サービス確認を待ちます。 接続が失敗した場合や完了が確認されなかった場合(ソケットがすでに閉じられている場合も含む)拒否します。
function close(code?: number, reason?: string): Promise<void>
パラメーター
- code
-
number
- reason
-
string
戻り値
Promise<void>
configureSession(LiveSessionUpdateParams, VoiceAgentEventOptions)
委任バックエンド設定とトランスクリプトトリガーを更新します。 オーディオ形式、モデル、および委任所有者は変更できません。
function configureSession(session: LiveSessionUpdateParams, options?: VoiceAgentEventOptions): Promise<void>
パラメーター
- session
- LiveSessionUpdateParams
- options
- VoiceAgentEventOptions
戻り値
Promise<void>
dispose()
セッションを閉じます。 閉じる()に相当します。
function dispose(): Promise<void>
戻り値
Promise<void>
muteInputAudio(VoiceAgentEventOptions)
モデルが入力音声を処理するのを停止します。 Liveにはコミットやクリア用の入力バッファがありません。
function muteInputAudio(options?: VoiceAgentEventOptions): Promise<void>
パラメーター
- options
- VoiceAgentEventOptions
戻り値
Promise<void>
off<K>(K, VoiceAgentLiveEventHandler<K>)
以前に登録されたリスナーを削除します。
function off<K>(type: K, handler: VoiceAgentLiveEventHandler<K>): this
パラメーター
- type
-
K
- handler
戻り値
this
on<K>(K, VoiceAgentLiveEventHandler<K>)
その後のイベント用のリスナーを追加します。 起動イベントには connect オプション onEvent を使用し、スタートアップメタデータには sessionStarted を読みます。
function on<K>(type: K, handler: VoiceAgentLiveEventHandler<K>): this
パラメーター
- type
-
K
- handler
戻り値
this
once<K>(K, VoiceAgentLiveEventHandler<K>)
1回実行するリスナーを追加します。
function once<K>(type: K, handler: VoiceAgentLiveEventHandler<K>): this
パラメーター
- type
-
K
- handler
戻り値
this
requestResponse(VoiceAgentEventOptions)
Responses バックエンドに応答を求めます。 応答の委任が必要です。
function requestResponse(options?: VoiceAgentEventOptions): Promise<void>
パラメーター
- options
- VoiceAgentEventOptions
戻り値
Promise<void>
send(VoiceAgentLiveClientEvent, VoiceAgentSendOptions)
ライブコマンドを送信します。 session.startを送信しないでください;サービスがセッションを開始します。
function send(event: VoiceAgentLiveClientEvent, options?: VoiceAgentSendOptions): Promise<void>
パラメーター
- options
- VoiceAgentSendOptions
戻り値
Promise<void>
sendAudio(ArrayBuffer | Uint8Array, VoiceAgentEventOptions)
WAVやその他のファイルヘッダーなしで、設定済みの入力形式で生の音声を送信します。
function sendAudio(audio: ArrayBuffer | Uint8Array, options?: VoiceAgentEventOptions): Promise<void>
パラメーター
- audio
-
ArrayBuffer | Uint8Array
- options
- VoiceAgentEventOptions
戻り値
Promise<void>
sendEvent(VoiceAgentLiveClientEvent, VoiceAgentSendOptions)
送信用のエイリアス()。
function sendEvent(event: VoiceAgentLiveClientEvent, options?: VoiceAgentSendOptions): Promise<void>
パラメーター
- options
- VoiceAgentSendOptions
戻り値
Promise<void>
sendResponseItem(Record<string, unknown>, VoiceAgentEventOptions)
セッションが応答委任を使用したときに会話アイテムを追加します。
function sendResponseItem(item: Record<string, unknown>, options?: VoiceAgentEventOptions): Promise<void>
パラメーター
- item
-
Record<string, unknown>
- options
- VoiceAgentEventOptions
戻り値
Promise<void>
sendToolOutput(string, string, VoiceAgentSendToolOutputOptions)
関数結果を Responses バックエンドに送信し、デフォルトでフォローアップ応答を要求します。
function sendToolOutput(callId: string, output: string, options?: VoiceAgentSendToolOutputOptions): Promise<void>
パラメーター
- callId
-
string
- output
-
string
- options
- VoiceAgentSendToolOutputOptions
戻り値
Promise<void>
unmuteInputAudio(VoiceAgentEventOptions)
モデルオーディオ入力を再開します。
function unmuteInputAudio(options?: VoiceAgentEventOptions): Promise<void>
パラメーター
- options
- VoiceAgentEventOptions
戻り値
Promise<void>
継承済みメソッドの詳細
[asyncIterator]()
function [asyncIterator](): AsyncIterator<VoiceAgentLiveEvent, any, any>
戻り値
AsyncIterator<VoiceAgentLiveEvent, any, any>
受け継いだ 非同期イテラブル。[非同期イテレーター]