To build a ChatBot with voice commands, the following steps are required:
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.
// ... create the chatbot component
sgcChatBot := TsgcAIOpenAIChatBot.Create(nil);
sgcChatBot.OpenAIOptions.ApiKey := 'your_openapi_api_key';
sgcChatBot.ChatBotOptions.Transcription.Language := 'en';
// ... create audio recorder and tex-to-speech
sgcAudioRecorder := TsgcAudioRecorderMCI.Create(nil);
sgcTextToSpeech := TsgcTextToSpeechSystem.Create(nil);
// ... assign audio components to chatbot
sgcChatBot.AudioRecorder := sgcAudioRecorder;
sgcChatBot.TextToSpeech := sgcTextToSpeech;
// ... start the chatbot, speak with a microphone to capture the audio and stop to process the audio
sgcChatBot.Start;
... speak
sgcChatBot.Stop;