OpenAI Translator

TsgcAIOpenAITranslator turns spoken input in almost any language into speech in the language you choose, English by default. It records the microphone, transcribes the audio with gpt-transcribe, translates the text with a chat model, gives you a chance to review it, then speaks it through a text-to-speech component.

TsgcAIOpenAITranslator

A speech to speech translator in two steps: the recorded audio is transcribed in its original language, then a chat completion translates the text into Language. The source language is detected automatically, so you only choose the target.

Component class

TsgcAIOpenAITranslator

Purpose

Spoken translation into any language

Family

Chat & agents

Platforms

Win32 and Win64

sgcAI is self-contained. This component ships inside sgcAI together with the sgcWebSockets Core runtime it is built on.

Speak in one language, hear another

Link a recorder and a text-to-speech component, set the API key and the target language, call Start.

uses
  sgcAI, sgcAI_OpenAI_Audio_Translator,
  sgcAI_AudioRecorder_MCI, sgcAI_TextToSpeech_System;

var
  oTranslator: TsgcAIOpenAITranslator;
begin
  oTranslator := TsgcAIOpenAITranslator.Create(nil);
  oTranslator.OpenAIOptions.ApiKey := 'sk-...';
  oTranslator.AudioRecorder := sgcAudioRecorderMCI1;
  oTranslator.TextToSpeech  := sgcTextToSpeechSystem1;

  // 1. transcribe, 2. translate the text with a chat model
  oTranslator.TranslatorOptions.Translation.Model := 'gpt-transcribe';
  oTranslator.TranslatorOptions.Translation.ChatModel := 'gpt-6-luna';
  oTranslator.TranslatorOptions.Translation.Language := 'Spanish';
  oTranslator.OnTranslation := TranslatorTranslation;

  oTranslator.Start;   // Stop ends the session
end;

procedure TForm1.TranslatorTranslation(Sender: TObject;
  var Text: string; var Accept: Boolean);
begin
  memoLog.Lines.Add(Text);
  Accept := True;   // set False to skip speaking this segment
end;
// includes: sgcAI.hpp, sgcAI_OpenAI_Audio_Translator.hpp

TsgcAIOpenAITranslator *oTranslator = new TsgcAIOpenAITranslator(NULL);
oTranslator->OpenAIOptions->ApiKey = "sk-...";
oTranslator->AudioRecorder = sgcAudioRecorderMCI1;
oTranslator->TextToSpeech  = sgcTextToSpeechSystem1;

oTranslator->TranslatorOptions->Translation->Model = "gpt-transcribe";
oTranslator->TranslatorOptions->Translation->ChatModel = "gpt-6-luna";
oTranslator->TranslatorOptions->Translation->Language = "Spanish";
oTranslator->OnTranslation = TranslatorTranslation;

oTranslator->Start();

Key properties & methods

The members you reach for most often.

AudioRecorder captures the speech and TextToSpeech speaks the translation. Leave TextToSpeech unassigned and the component simply returns text and restarts capture.

TranslatorOptions

Translation.Model is the transcription model (gpt-transcribe), Translation.ChatModel the chat model that translates the text (gpt-6-luna) and Translation.Language the target language (English). Leave Language empty to get the transcript untranslated.

OpenAIOptions

API key, endpoint, HTTP, retry and logging settings shared with the other OpenAI components.

Session

Start begins capture and Stop ends it. In automatic recorder mode each silence boundary closes a segment and triggers a translation.

Events

OnTranslation hands you the translated text with an Accept flag, so you can log it, correct it or suppress it before it is spoken. OnAudioStart and OnAudioStop track capture.

Output language

Any language the chat model writes. Set Language to a name such as Spanish or Japanese. The default, English, gives the same result as the old whisper-1 translation.

Why two steps? OpenAI removes the /v1/audio/translations endpoint and the whisper-1 model on 2027-02-26, and the newer transcription models do not translate. The component now transcribes and translates with models that stay available, so existing applications keep working. For live speech to speech translation while the user talks, use TsgcAIVoiceTranslator.

Specifications & references

Authoritative sources for the services and protocols this component uses.

Keep exploring

Online HelpFull API reference and usage guide for the sgcAI components.
All sgcAI ComponentsBrowse the full feature matrix of all 15 components.
Download Free TrialTranslate live speech with your own OpenAI key.
PricingSingle, Team and Site licenses, full source code.
Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €1,059/year.
See All-Access pricing

Ready to Get Started?

Download the free trial and add live speech translation to your application.