Skip to main content
Use voice() to send a voice note. It uses the same input shape as attachment: a path or a Buffer plus optional metadata.
import { voice } from "spectrum-ts";

// From a file path
await space.send(voice("/path/to/note.m4a"));

// From a buffer - duration in seconds is optional but useful for waveform UIs
await space.send(voice(buffer, {
  name: "note.m4a",
  mimeType: "audio/mp4",
  duration: 12,
}));
Platforms that don’t support voice notes typically downgrade to a regular audio attachment. If the MIME type can’t be inferred and options.mimeType is omitted, the builder throws at send time.
FieldTypeDescription
mimeTypestringThe audio MIME type, such as audio/mp4.
namestring (optional)Filename for the underlying clip.
durationnumber (optional)Length in seconds.
sizenumber (optional)Byte length, when known up front.
read()() => Promise<Buffer>Materialize the bytes.
stream()() => Promise<ReadableStream>Stream the bytes. Prefer this for large clips.