OpenAI | Speech

Generate spoken audio from text using the Text-to-Speech (TTS) API. Supports multiple voices and output formats.

Simple Example

Generate speech from text and save to a file stream.


OpenAI := TsgcHTTP_API_OpenAI.Create(nil);
OpenAI.OpenAIOptions.ApiKey := 'API_KEY';

oStream := TFileStream.Create('output.mp3', fmCreate);
Try
  OpenAI._CreateSpeech('tts-1', 'Hello, how are you?', 'alloy', oStream);
Finally
  oStream.Free;
End;

Methods