Text To Speech OpenAI

Hi there,

I saw there is a feature request for this.
But given n8n has a Request node, can we use it to run OpenAI text-2-speech endpoint ?
Can someone draft an example on how we can use the binary file created ? Any hint will be really appreciated



1 Like

Hi @Rad, it should be enough to import the curl request from OpenAI’s documentation using the Import cURL button of the HTTP Request node:

curl https://api.openai.com/v1/audio/speech \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "The quick brown fox jumped over the lazy dog.",
    "voice": "alloy"
  }' \
  --output speech.mp3

This works as expected for me:

Instead of hard-coding the API key you could also consider removing the headers (including the key) and using your existing OpenAI credentials instead.

When clicking “View” your browser even renders a little preview:

In a full workflow this could look like so:

Hope this helps!

1 Like

@MutedJam You’re amazing :slight_smile: Thanks

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.