Skip to content

Commit aee230c

Browse files
committed
Dump raw bytes not tensor
Signed-off-by: Samuel Monson <[email protected]>
1 parent ec7071b commit aee230c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/guidellm/data/utils/functions.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,24 +341,21 @@ def encode_audio(
341341
sample_rate=encode_sample_rate if sample_rate != encode_sample_rate else None,
342342
)
343343

344-
audio_buffer = io.BytesIO()
345-
torch.save(audio_tensor, audio_buffer)
346-
audio_buffer.seek(0)
347-
decoded_audio = audio_buffer.read()
344+
encoded_audio = audio_tensor.numpy().tobytes()
348345

349346
return {
350347
"type": "audio_base64" if b64encode else "audio_file",
351348
"audio": (
352-
base64.b64encode(decoded_audio).decode("utf-8")
349+
base64.b64encode(encoded_audio).decode("utf-8")
353350
if b64encode
354-
else decoded_audio
351+
else encoded_audio
355352
),
356353
"file_name": file_name,
357354
"format": audio_format,
358355
"mimetype": f"audio/{format_val}",
359356
"audio_samples": samples.sample_rate,
360357
"audio_seconds": samples.duration_seconds,
361-
"audio_bytes": len(decoded_audio),
358+
"audio_bytes": len(encoded_audio),
362359
}
363360

364361

0 commit comments

Comments
 (0)