OpenAITTSClient

org.llm4s.speech.tts.provider.OpenAITTSClient
See theOpenAITTSClient companion object
final class OpenAITTSClient(config: TTSConfig, httpClient: Llm4sHttpClient) extends TextToSpeech

OpenAI text-to-speech (POST /v1/audio/speech).

Asks for response_format = pcm, which OpenAI documents as raw 24 kHz, 16-bit, mono little-endian samples, so GeneratedAudio.data is headerless PCM described by an honest AudioMeta - the same shape org.llm4s.speech.tts.Tacotron2TextToSpeech produces. Write it out with org.llm4s.speech.io.WavFileGenerator.saveAsWav.

With options.outputFormat = AudioFormat.Mp3 it asks for response_format = mp3 instead and returns the MP3 bytes untouched (see org.llm4s.speech.AudioFormat.Mp3).

options.voice overrides the configured voice; options.speakingRate is sent as speed (OpenAI accepts 0.25 to 4.0).

Value parameters

config

configuration from org.llm4s.speech.config.SpeechConfigLoader.tts

httpClient

HTTP transport, replaceable in tests

Attributes

Companion
object
Source
OpenAITTSClient.scala
Graph
Supertypes
trait TextToSpeech
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def synthesize(text: String, options: TTSOptions): Result[GeneratedAudio]

Attributes

Definition Classes
Source
OpenAITTSClient.scala

Concrete fields

override val name: String

Attributes

Source
OpenAITTSClient.scala