Speech
Speech generation is an experimental feature.
generateSpeech
function to generate speech from text using a speech model.
Settings
Voice Selection
Different models support different voices. Refer to your provider’s documentation for available voices:Output Format
You can specify the desired output format for the audio:Speech Speed
Some models support adjusting the speed of the generated speech:Language Setting
You can specify the language for speech generation (provider support varies):Instructions
Some models accept additional instructions to guide the speech generation:Provider-Specific Settings
You can set model-specific settings with theproviderOptions parameter:
Retries
ThegenerateSpeech function accepts an optional maxRetries parameter
that you can use to set the maximum number of retries.
It defaults to 2 retries (3 attempts in total). You can set it to 0 to disable retries.
Abort Signals and Timeouts
generateSpeech accepts an optional abortSignal parameter of
type AbortSignal
that you can use to abort the speech generation process or set a timeout.
Custom Headers
generateSpeech accepts an optional headers parameter of type Record<string, string>
that you can use to add custom headers to the speech generation request.
Response Information
ThegenerateSpeech function returns comprehensive response information: