79599853

Date: 2025-04-30 08:20:04
Score: 2
Natty:
Report link

I get some idea from this post: https://stackoverflow.com/a/65326693/22397626

So you first install this npm package: https://www.npmjs.com/package/wavefile?activeTab=readme and then use below code:

const wavefile = require('wavefile');
let audio = await this.openai.audio.speech.create({
                        model: "gpt-4o-mini-tts",
                        voice: "ash",
                        input: 'speech',
                        response_format: "wav",
});

let audioBuffer = Buffer.from(await mp3.arrayBuffer());
let wav = new wavefile.WaveFile(audioBuffer)
                    wav.toBitDepth('8')
                    wav.toSampleRate(8000)
                    wav.toMuLaw()
let payload = Buffer.from(wav.data.samples).toString('base64');
Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Jack Li