transcribe

suspend fun transcribe(samples: FloatArray, sampleRate: Int = SAMPLE_RATE, channels: Int = 1, options: TranscriptionOptions = TranscriptionOptions.DEFAULT): TranscriptionResult(source)

Transcribes interleaved float PCM in [-1, 1].

16 kHz mono input is passed to whisper.cpp zero-copy; any other sampleRate / channels is downmixed and resampled natively first. Input shorter than 1000 ms is zero-padded to 1000 ms (empty input yields silence).

Parameters

samples

interleaved samples; samples.size must be a multiple of channels.

sampleRate

input sample rate in Hz, 1000..384000.

channels

interleaved channel count, 1..8.

Throws

for malformed audio or options the native layer rejects (e.g. unknown language).

if the engine is closed.

kotlinx.coroutines.CancellationException

if the calling coroutine was cancelled.


suspend fun transcribe(samples: ShortArray, sampleRate: Int = SAMPLE_RATE, channels: Int = 1, options: TranscriptionOptions = TranscriptionOptions.DEFAULT): TranscriptionResult(source)

Transcribes interleaved signed 16-bit PCM (normalized as sample / 32768). The array is read in place by the native converter; see the FloatArray overload for the remaining semantics.