Using SmartRealTimeAdapter
Overview
The SmartRealTimeAdapter enables real-time, continuous interaction between the user and the AI model via voice input and spoken responses. This adapter facilitates seamless communication by supporting both the reception of voice commands from the user and the delivery of AI-generated spoken replies. The SmartRealTimeAdapter can be used independently or in conjunction with other adapters.
To use the SmartRealTimeAdapter, you must also configure an instance of the OpenAIEndpointRealtime endpoint. This is the only endpoint supported by the SmartRealTimeAdapter.
Additionally, this adapter requires a browser environment, as it relies on browser capabilities to capture the user’s voice and facilitate real-time communication with the OpenAI endpoint. Therefore, it cannot be used in console or service applications.
Examples
The example below demonstrates a basic approach to creating the SmartRealTimeAdapter and initiating voice listening. In this example, each response from the AI is displayed to the user in an alert box.
var hub = new SmartHub {
Endpoint = new OpenAIEndpointRealtime { ApiKey = "..." }
};
var adapter = new SmartRealtimeAdapter
{
Hub = hub,
};
adapter.AnswerReceived += (s, e) =>
{
AlertBox.Show(e.Text);
};
adapter.StartListening();
Last updated