Audio file (mp3) from v1/audio/speech generate wrong mp3 file

Hi, I’m using the curl command to call audio/speech service, but the mp3 generated can’t be played.
Tested the same call on ubuntu and mac os, both with the same result.

curl https://api.openai.com/v1/audio/speech \
  -H "Authorization: Bearer xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "Hello, World!",
    "voice": "alloy",
    "response_format": "mp3"
  }' \
  --output hello-world.mp3

The hello-wold.mp3 file is 0bytes.
I did other tests and sometimes the mp3 have at least some bytes, but they are not working. I don’t have any hint why the file is always corrupted / not properly encoded.

Thank you in advance

1 Like

In node.js, the file output is a Promise and you need to wait for it to finish. Is there a similar mechanism in curl? It is probably like when you fetch a big file.