Skip to content

resultWithAudio

resultWithAudio(result, audioData, options?): GadgetExecuteResultWithMedia

Defined in: gadgets/helpers.ts:374

Create a result with a single audio output.

string

Text result string

Raw audio data (MP3, WAV, OGG, etc.)

Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>

AudioOptions

Optional MIME type, description, duration, cost

GadgetExecuteResultWithMedia

A GadgetExecuteResultWithMedia

const speech = await generateSpeech(text);
return resultWithAudio(
`Generated speech for: "${text.slice(0, 50)}..."`,
speech,
{ mimeType: "audio/mp3", durationMs: 5000 }
);