Speech API
The GET https://llmfoundry.straive.com/openai/v1/audio/speech API converts text to speech. It accepts the same parameters as the OpenAI API.
model: string, required. One of the available TTS models:tts-1ortts-1-hd.input: string, required. The text to generate audio for. The maximum length is 4096 characters.voice: string, required. The voice to use when generating the audio. Supported voices arealloy,echo,fable,onyx,nova, andshimmer. Previews of the voices are available in the Text to speech guide.response_format: string, optional. Defaults tomp3. The format to audio in. Supported formats aremp3,opus,aac,flac,wav, andpcm.speed: number, optional. Defaults to1. The speed of the generated audio. Select a value from 0.25 to 4.0.
Example:
?model=tts-1&voice=echo&input=Hello%2C%20world
It returns an MP3 file (or the requested format).
HTML
You can use the src attribute to embed the audio in an HTML page:
<audio src="https://llmfoundry.straive.com/openai/v1/audio/speech?model=tts-1&voice=echo&input=Hello%20world" controls></audio>
You can also dynamically set the parameters:
<audio src="" controls></audio>
<script>
  const audio = document.querySelector("audio");
  const params = { model: "tts-1", voice: "echo", input: "Hello world" };
  audio.src = `https://llmfoundry.straive.com/openai/v1/audio/speech?${new URLSearchParams(params).toString()}`;
</script>