init(model:input:voice:instructions:responseFormat:speed:)
AudioSpeechQuery.swift:74init(model: Model, input: String, voice: AudioSpeechVoice, instructions: String = "", responseFormat: AudioSpeechResponseFormat = .mp3, speed: Double = 1.0)
init(model: Model, input: String, voice: AudioSpeechVoice, instructions: String = "", responseFormat: AudioSpeechResponseFormat = .mp3, speed: Double = 1.0)
s6OpenAI16AudioSpeechQueryV5model5input5voice12instructions14responseFormat5speedACSS_SSAC0cD5VoiceOSSAC0cd8ResponseK0OSdtcfc
What are these?90YKU
import OpenAI
struct AudioSpeechQuery
Generates audio from the input text. Learn more: OpenAI Speech – Documentation
typealias Model = String
Defines all available OpenAI models supported by the library.
@frozen struct String
A Unicode string value that is a collection of characters.
enum AudioSpeechVoice
Encapsulates the voices available for audio generation.
enum AudioSpeechResponseFormat
Encapsulates the response formats available for audio data.
@frozen struct Double
A double-precision, floating-point value type.
init(from decoder: any Decoder) throws
static func normalizeSpeechSpeed(_ inputSpeed: Double?) -> Double
let input: String
The text to generate audio for. The maximum length is 4096 characters.
let instructions: String?
Control the voice of your generated audio with additional instructions. Does not work with tts-1 or tts-1-hd.
let model: Model
One of the available TTS models: tts-1 or tts-1-hd
let responseFormat: AudioSpeechResponseFormat?
The format to audio in. Supported formats are mp3, opus, aac, flac, and pcm. Defaults to mp3
let speed: Double?
The speed of the generated audio. Select a value from 0.25 to 4.0. 1.0 is the default. Defaults to 1
let voice: AudioSpeechVoice
The voice to use when generating the audio. Supported voices are alloy, echo, fable, onyx, nova, and shimmer. Previews of the voices are available in the Text to speech guide. https://platform.openai.com/docs/guides/text-to-speech/voice-options
enum CodingKeys
enum Speed