Example of Text To Speech in ASP.NET Core AI AssistView Control
This sample demonstrates the integration of Text-to-Speech functionality with the AI AssistView component. It allows users to convert AI-generated responses into spoken audio using the browser's SpeechSynthesis API, with responses powered by Azure OpenAI.
DEMO
SOURCE
In this example, the AI AssistView component is integrated with Text-to-Speech functionality to enable voice-based interaction with AI-generated responses.
The sample demonstrates the following features:
-
The
responseToolbarSettingsincludes a customRead Aloudbutton that extracts plain text from the AI response and uses the browser'sSpeechSynthesisAPI to vocalize it. -
The
SpeechSynthesisUtteranceinterface is used to manage speech playback, including toggling between play and stop states. -
Additional response toolbar buttons include
Copyto copy the response text, andLikeandNeed Improvementfor user feedback. -
The
toolbarSettingsadds a right-alignedRefreshbutton to clear previous prompts. -
Responses are streamed dynamically using the
addPromptResponsemethod, and thescrollToBottommethod ensures the latest response is always visible. -
Markdown content is rendered using the
Markedplugin for rich formatting in AI responses. -
The
promptSuggestionsprovides AI prompt suggestions to guide user interactions.