Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

OpenAI.audio_speech/2

openai_ex_audio_speech.livemd

OpenAI.audio_speech/2

Mix.install([
  {:openai, path: "/path/to/mix/directory"},
  {:kino, "~> 0.11.2"}
])

Request

openai_config = %OpenAI.Config{
  api_key: System.get_env("OPENAI_API_KEY"),
  organization_key: System.get_env("OPENAI_ORGANIZATION_KEY"),
  http_options: [recv_timeout: :infinity]
}

true
{:ok, binary} =
  OpenAI.audio_speech(
    [
      input: "You know that Voight-Kampf test of yours. Did you ever take that test yourself?",
      model: "tts-1",
      voice: "alloy"
    ],
    openai_config
  )
Kino.Audio.new(binary, :mp3)