diff --git a/nodes.py b/nodes.py index 4b5aa81..90b3351 100644 --- a/nodes.py +++ b/nodes.py @@ -95,28 +95,54 @@ def _encode_audio_b64(audio) -> str: return _tensor_to_wav_b64(waveform, audio["sample_rate"]) +def _parse_wav_bytes(audio_bytes: bytes): + """Parse WAV bytes manually to support PCM (fmt=1) and float32 (fmt=3).""" + if audio_bytes[:4] != b"RIFF" or audio_bytes[8:12] != b"WAVE": + raise RuntimeError("Not a valid WAV file") + pos = 12 + fmt_tag = n_channels = sample_rate = sampwidth = 0 + data_offset = data_size = 0 + while pos < len(audio_bytes) - 8: + chunk_id = audio_bytes[pos:pos+4] + chunk_size = struct.unpack_from("