Delphi Real-Time Translator AI
Channel: eSeGeCe
Date: 2023-06-02

Hello and Welcome to a new eSeGeCe e-learning session. Today we will show how to create a Real-Time Translation Application in Delphi using the OpenAI API and how to convert the response to Voice.

First we create a new form with 2 buttons and 1 memo. Then we drop a Translator component which encapsulates the Translation API which will be used to interactuate with OpenAI. The Translator requires to set the OpenAI Api Key, which can be obtained from the OpenAI Servers. We drop 3 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; an Amazon Text To Speech component that converts text to audio and finally and audio player to play the mp3 file returned by Amazon Polly API.

Then, we handle the Translator events to know when the audio is recording and when is stopped. OnTranslation event returns the text translated when using our own voice in another language different from English.

Now, we compile the application and we show a simple example where we say "Hola, Buenos días, como estás?" in spanish and we get the translation in English.