Skip to main content

Function: audioFromStream()

audioFromStream(stream, mode?, options?): Promise<UnifiedMessageInput>

Defined in: packages/core/src/multimodal.ts:414

Create an audio input from a ReadableStream

Note: Streams must be consumed before being passed to providers. This helper converts the stream to a Blob first.

Parameters

stream

ReadableStream<Uint8Array<ArrayBufferLike>>

mode?

"transcribe" | "analyze"

options?

AudioOptions & object

Returns

Promise<UnifiedMessageInput>

Examples

const stream = fs.createReadStream('audio.mp3');
const audioInput = await audioFromStream(stream, 'transcribe');
bot.process(audioInput);
const audioInput = await audioFromStream(stream, 'transcribe', {
format: 'mp3',
minSize: 4096
});