Delphi ChatGPT ChatBot

Published: 31 May 2023
on channel: eSeGeCe
1,571
like

Hello and Welcome to a new SGC e-learning session. Today we will show how to create a ChatBot using the OpenAI API and how to send voice commands to interactuate with the ChatBot and convert the response to Voice.

First we create a new form with 2 buttons and 1 memo. Then we drop a ChatBot component which encapsulates the Transcription and ChatCompletion API which will be used to interactuate with ChatGPT. The ChatBot requires to set the OpenAI Api Key, which can be obtained from OpenAI Servers. We drop 2 additional components, an Audio Recorder component that it's used to capture the microphone audio and create a wave file which will be sent to OpenAI; and a Text To Speech component that converts text to audio, we will use the SpeechToText component that comes with Windows.

Then, we handle the ChatBot events to know when the audio is recording and when is stopped. OnTranscription event returns the text captured by the microphone and OnChatCompletion shows the response returned by the OpenAI ChatCompletion API.

Now, we compile the application and we show a simple example where we say hello to the chatbot and we get a response from him.


Watch video Delphi ChatGPT ChatBot online without registration, duration hours minute second in high quality. This video was added by user eSeGeCe 31 May 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,571 once and liked it like people.