From sgcWebSockets 2023.5.0 building Voice ChatBots is more easy using OpenAI APIs and Text-To-Speech APIs from Windows, Google or Amazon.
Chatbots and Virtual Assistants are Applications that can converse with humans in a natural, human-like manner. These can be used for customer support, handling queries, and providing information on a website or mobile app.
To build a ChatBot with voice commands, the following steps are required:
Properties
Events
Create a new ChatBot, using the default Text-To-Speech from Microsoft Windows. Use Start to Start the recording of the audio and Stop to Stop the recording and send the audio to the OpenAI API and return a response from ChatGPT.
123456789101112131415// ... create the chatbot componentsgcChatBot := TsgcAIOpenAIChatBot.Create(nil);sgcChatBot.OpenAIOptions.ApiKey := 'your_openapi_api_key';sgcChatBot.ChatBotOptions.Transcription.Language := 'en';// ... create audio recorder and tex-to-speechsgcAudioRecorder := TsgcAudioRecorderMCI.Create(nil);sgcTextToSpeech := TsgcTextToSpeechSystem.Create(nil);// ... assign audio components to chatbotsgcChatBot.AudioRecorder := sgcAudioRecorder;sgcChatBot.TextToSpeech := sgcTextToSpeech;// ... start the chatbot, speak with a microphone to capture the audio and stop to process the audiosgcChatBot.Start;... speaksgcChatBot.Stop;
Find below the source code of the ChatBot Application Demo showing the main features of the ChatBot built with sgcWebSockets library for windows.
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.