openai_speech
Generates audio from a text description and other attributes, using the OpenAI API.
This processor sends a text description along with attributes such as the voice type and audio format to the OpenAI API for speech generation. By default it submits the entire message payload as the input text, unless you customize this using the input field.
# Config fields, showing default values
processor:
label: ""
openai_speech:
api_key: "" # No default (required)
input: ""
model: "" # No default (required)
response_format: mp3
server_address: https://api.openai.com/v1
voice: "" # No default (required)
Examples
- Speech from message payload
- Speech from a field
Generate speech from the text in each message payload using the tts-1 model and the alloy voice.
processor:
openai_speech:
server_address: https://api.openai.com/v1
api_key: "${OPENAI_API_KEY}"
model: tts-1
voice: alloy
Generate high definition speech from a specific field, choosing a different voice and requesting the opus audio format.
processor:
openai_speech:
server_address: https://api.openai.com/v1
api_key: "${OPENAI_API_KEY}"
model: tts-1-hd
input: "${! this.text }"
voice: nova
response_format: opus
Fields
api_key
The API key for the OpenAI API. :::warning Secret This field contains sensitive information that usually shouldn't be added to a config directly, read our secrets page for more info. :::
Type: string
input
A text description of the audio you want to generate. The input field accepts a maximum of 4096 characters. When not set, the entire message payload is used as the input text.
Type: string
model
The name of the OpenAI model to use, for example tts-1 or tts-1-hd.
Type: string
response_format
The format to generate audio in. Supported values are mp3, opus, aac, flac, wav, and pcm. This field supports interpolation functions.
Type: string
Default: "mp3"
server_address
The OpenAI API endpoint that the processor sends requests to. Set this to target a different OpenAI-compatible service.
Type: string
Default: "https://api.openai.com/v1"
voice
The type of voice to use when generating the audio, for example alloy, echo, fable, onyx, nova, or shimmer. This field supports interpolation functions.
Type: string