To build a Translator with voice commands, the following steps are required:
Create a new Translator, 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 translate it.
// ... create the translator component
TsgcAIOpenAITranslator *sgcTranslator = new TsgcAIOpenAITranslator(NULL);
sgcTranslator->OpenAIOptions->ApiKey = "your_openapi_api_key";
// ... create audio recorder and text-to-speech
TsgcAudioRecorderMCI *sgcAudioRecorder = new TsgcAudioRecorderMCI(NULL);
TsgcTextToSpeechSystem *sgcTextToSpeech = new TsgcTextToSpeechSystem(NULL);
// ... assign audio components to translator
sgcTranslator->AudioRecorder = sgcAudioRecorder;
sgcTranslator->TextToSpeech = sgcTextToSpeech;
// ... start the translator, speak with a microphone to capture the audio, and stop to translate it
sgcTranslator->Start();
// ... speak
sgcTranslator->Stop();