You can test it just by going to https://aistudio.google.com/generate-speech. You’ll hear right away there’s a cracking/sizzling sound in the background (like old recordings used to have). This wasn’t like this before, one or two weeks ago there was no such issue.
I’m saving in WAV same way I used to, as described in the docs:
async function saveWaveFile(
filename: string,
pcmData: Buffer,
channels = 1,
rate = 24000,
sampleWidth = 2,
): Promise<void> {
return new Promise((resolve, reject) => {
const writer = new wav.FileWriter(filename, {
channels,
sampleRate: rate,
bitDepth: sampleWidth * 8,
});
writer.on("finish", resolve);
writer.on("error", reject);
writer.write(pcmData);
writer.end();
});
}
const audioBuffer = Buffer.from(data, "base64");
Both for Pro and Flash, but most noticeable on Pro
1 Like
Hey - were you able to fix this? Seems like no reply from the devs.
Hi,
Thanks for the detailed report.
Regarding the “cracking/sizzling” sound in AI Studio, I just tested it on my end and I’m not able to hear it. It’s possible this was an intermittent service issue that has since been fixed. Could you please try it again and see if it’s clear for you now?
For the noise in your saved file , Here is something you can try.
Your saveWaveFile function expects raw audio data (PCM), but the API sends encoded audio (like MP3) by default. Writing encoded data as if it were raw data will result in a file that is all static.
1. In your API call, ask for the WAV format directly:
JSON
"outputAudioConfig": {
"audioEncoding": "WAV"
}
2. Then, in your Node.js code,
JavaScript
const fs = require('fs');
// ...
// 'data' is the base64 string from the API
const audioBuffer = Buffer.from(data, "base64");
fs.writeFileSync("output.wav", audioBuffer);
This lets the API do the work of building the .wav file correctly and should completely fix the noise you’re hearing in your saved files.
Let me know if that works for you!