На js есть такая функция
writeUTFBytes(view, offset, string) {
let lng = string.length;
for (let i = 0; i < lng; i++) {
view.setUint8(offset + i, string.charCodeAt(i));
}
}
encodeWav(int16Array) {
let buffer = new ArrayBuffer(44 + int16Array.length * 2);
let view = new DataView(buffer);
this.writeUTFBytes(view, 0, 'RIFF');
view.setUint32(4, 44 + int16Array.length * 2, true);
this.writeUTFBytes(view, 8, 'WAVE');
this.writeUTFBytes(view, 12, 'fmt ');
view.setUint32(16, 16, true);
view.setUint16(20, 1, true);
view.setUint16(22, tts_default_options.numChannels, true);
view.setUint32(24, tts_default_options.sampleRate, true);
view.setUint32(28, tts_default_options.sampleRate * 4, true);
view.setUint16(32, 4, true);
view.setUint16(34, 16, true);
this.writeUTFBytes(view, 36, 'data');
view.setUint32(40, int16Array.length * 2, true);
let lng = int16Array.length,
index = 44,
volume = 1;
for (let i = 0; i < lng; i++) {
view.setInt16(index, int16Array[i] * volume, true);
index += 2;
}
return new Blob([view], {
type: 'audio/x-wav'
})
Возможно ее переписать на php ?