VoiceLiveClient class

يوفر عميل VoiceLive إدارة الجلسات لقدرات الذكاء الاصطناعي الحواري في الوقت الحقيقي.

يعمل هذا العميل كمصنع لإنشاء مثيلات VoiceLiveSession، التي تتعامل مع اتصالات WebSocket الفعلية والتفاعلات الفورية مع الخدمة.

المنشئون

VoiceLiveClient(string, TokenCredential | KeyCredential, VoiceLiveClientOptions)

ينشئ نسخة من VoiceLiveClient مع نقطة النهاية وبيانات الاعتماد.

الخصائص

apiVersion
endpoint

الأساليب

createSession(RequestSession, CreateSessionOptions)

ينشئ جلسة صوتية جديدة للتواصل الصوتي في الوقت الحقيقي مع تكوين الجلسة.

createSession(SessionTarget, CreateSessionOptions)

ينشئ جلسة VoiceLiveSession جديدة باستخدام هدف جلسة (نموذج أو وكيل).

مثال

جلسة تركز على النماذج

import { DefaultAzureCredential } from "@azure/identity";
import { VoiceLiveClient } from "@azure/ai-voicelive";

const credential = new DefaultAzureCredential();
const endpoint = "https://your-resource.cognitiveservices.azure.com";
const client = new VoiceLiveClient(endpoint, credential);

const session = client.createSession({ model: "gpt-4o-realtime-preview" });

مثال

جلسة تركز على الوكيل

import { DefaultAzureCredential } from "@azure/identity";
import { VoiceLiveClient } from "@azure/ai-voicelive";

const credential = new DefaultAzureCredential();
const endpoint = "https://your-resource.cognitiveservices.azure.com";
const client = new VoiceLiveClient(endpoint, credential);

const session = client.createSession({
  agent: { agentName: "my-agent", projectName: "my-project" },
});
createSession(string, CreateSessionOptions)

ينشئ جلسة VoiceLiveSession جديدة للتواصل الصوتي في الوقت الحقيقي.

startSession(RequestSession, StartSessionOptions)

ينشئ ويربط فورا جلسة VoiceLiveSession جديدة مع تكوين الجلسة.

startSession(SessionTarget, StartSessionOptions)

ينشئ ويربط فورا جلسة VoiceLiveSession جديدة باستخدام هدف الجلسة.

مثال

جلسة تركز على النماذج

import { DefaultAzureCredential } from "@azure/identity";
import { VoiceLiveClient } from "@azure/ai-voicelive";

const credential = new DefaultAzureCredential();
const endpoint = "https://your-resource.cognitiveservices.azure.com";
const client = new VoiceLiveClient(endpoint, credential);

const session = await client.startSession({ model: "gpt-4o-realtime-preview" });

مثال

جلسة تركز على الوكيل

import { DefaultAzureCredential } from "@azure/identity";
import { VoiceLiveClient } from "@azure/ai-voicelive";

const credential = new DefaultAzureCredential();
const endpoint = "https://your-resource.cognitiveservices.azure.com";
const client = new VoiceLiveClient(endpoint, credential);

const session = await client.startSession({
  agent: { agentName: "my-agent", projectName: "my-project" },
});
startSession(string, StartSessionOptions)

ينشئ ويربط فورا جلسة VoiceLiveSession جديدة.

تفاصيل المنشئ

VoiceLiveClient(string, TokenCredential | KeyCredential, VoiceLiveClientOptions)

ينشئ نسخة من VoiceLiveClient مع نقطة النهاية وبيانات الاعتماد.

new VoiceLiveClient(endpoint: string, credential: TokenCredential | KeyCredential, options?: VoiceLiveClientOptions)

المعلمات

endpoint

string

رابط نقطة نهاية خدمة Voice Live

credential

TokenCredential | KeyCredential

Azure TokenCredential أو KeyCredential للمصادقة

options
VoiceLiveClientOptions

التكوين الاختياري للعميل

تفاصيل الخاصية

apiVersion

string apiVersion

قيمة الخاصية

string

endpoint

string endpoint

قيمة الخاصية

string

تفاصيل الأسلوب

createSession(RequestSession, CreateSessionOptions)

ينشئ جلسة صوتية جديدة للتواصل الصوتي في الوقت الحقيقي مع تكوين الجلسة.

function createSession(sessionConfig: RequestSession, sessionOptions?: CreateSessionOptions): VoiceLiveSession

المعلمات

sessionConfig
RequestSession

تكوين الجلسة بما في ذلك النموذج والإعدادات الأخرى

sessionOptions
CreateSessionOptions

تكوين اختياري خاص بهذه الجلسة

المرتجعات

نسخة جديدة من VoiceLiveSession جاهزة للاتصال

createSession(SessionTarget, CreateSessionOptions)

ينشئ جلسة VoiceLiveSession جديدة باستخدام هدف جلسة (نموذج أو وكيل).

مثال

جلسة تركز على النماذج

import { DefaultAzureCredential } from "@azure/identity";
import { VoiceLiveClient } from "@azure/ai-voicelive";

const credential = new DefaultAzureCredential();
const endpoint = "https://your-resource.cognitiveservices.azure.com";
const client = new VoiceLiveClient(endpoint, credential);

const session = client.createSession({ model: "gpt-4o-realtime-preview" });

مثال

جلسة تركز على الوكيل

import { DefaultAzureCredential } from "@azure/identity";
import { VoiceLiveClient } from "@azure/ai-voicelive";

const credential = new DefaultAzureCredential();
const endpoint = "https://your-resource.cognitiveservices.azure.com";
const client = new VoiceLiveClient(endpoint, credential);

const session = client.createSession({
  agent: { agentName: "my-agent", projectName: "my-project" },
});
function createSession(target: SessionTarget, sessionOptions?: CreateSessionOptions): VoiceLiveSession

المعلمات

target
SessionTarget

هدف الجلسة يحدد إما نموذجا أو وكيلا

sessionOptions
CreateSessionOptions

تكوين اختياري خاص بهذه الجلسة

المرتجعات

نسخة جديدة من VoiceLiveSession جاهزة للاتصال

createSession(string, CreateSessionOptions)

ينشئ جلسة VoiceLiveSession جديدة للتواصل الصوتي في الوقت الحقيقي.

function createSession(model: string, sessionOptions?: CreateSessionOptions): VoiceLiveSession

المعلمات

model

string

اسم النموذج المستخدم للجلسة (مثلا: "gpt-4o-realtime-preview")

sessionOptions
CreateSessionOptions

تكوين اختياري خاص بهذه الجلسة

المرتجعات

نسخة جديدة من VoiceLiveSession جاهزة للاتصال

startSession(RequestSession, StartSessionOptions)

ينشئ ويربط فورا جلسة VoiceLiveSession جديدة مع تكوين الجلسة.

function startSession(sessionConfig: RequestSession, sessionOptions?: StartSessionOptions): Promise<VoiceLiveSession>

المعلمات

sessionConfig
RequestSession

تكوين الجلسة بما في ذلك النموذج والإعدادات الأخرى

sessionOptions
StartSessionOptions

تكوين اختياري خاص بهذه الجلسة

المرتجعات

Promise<VoiceLiveSession>

مثيل VoiceLiveSession متصل

startSession(SessionTarget, StartSessionOptions)

ينشئ ويربط فورا جلسة VoiceLiveSession جديدة باستخدام هدف الجلسة.

مثال

جلسة تركز على النماذج

import { DefaultAzureCredential } from "@azure/identity";
import { VoiceLiveClient } from "@azure/ai-voicelive";

const credential = new DefaultAzureCredential();
const endpoint = "https://your-resource.cognitiveservices.azure.com";
const client = new VoiceLiveClient(endpoint, credential);

const session = await client.startSession({ model: "gpt-4o-realtime-preview" });

مثال

جلسة تركز على الوكيل

import { DefaultAzureCredential } from "@azure/identity";
import { VoiceLiveClient } from "@azure/ai-voicelive";

const credential = new DefaultAzureCredential();
const endpoint = "https://your-resource.cognitiveservices.azure.com";
const client = new VoiceLiveClient(endpoint, credential);

const session = await client.startSession({
  agent: { agentName: "my-agent", projectName: "my-project" },
});
function startSession(target: SessionTarget, sessionOptions?: StartSessionOptions): Promise<VoiceLiveSession>

المعلمات

target
SessionTarget

هدف الجلسة يحدد إما نموذجا أو وكيلا

sessionOptions
StartSessionOptions

تكوين اختياري خاص بهذه الجلسة

المرتجعات

Promise<VoiceLiveSession>

مثيل VoiceLiveSession متصل

startSession(string, StartSessionOptions)

ينشئ ويربط فورا جلسة VoiceLiveSession جديدة.

function startSession(model: string, sessionOptions?: StartSessionOptions): Promise<VoiceLiveSession>

المعلمات

model

string

اسم النموذج المستخدم للجلسة (مثلا: "gpt-4o-realtime-preview")

sessionOptions
StartSessionOptions

تكوين اختياري خاص بهذه الجلسة

المرتجعات

Promise<VoiceLiveSession>

مثيل VoiceLiveSession متصل