CaptureConfig

data class CaptureConfig(val sampleRate: Int, val channels: Int = 1, val chunkDuration: Duration = 100.milliseconds, val pcm: PcmOutput? = PcmOutput(), val file: FileOutput? = null, val device: InputDevice? = null, val voiceProcessing: VoiceProcessing? = null, val interruption: InterruptionMode = InterruptionMode.Pause, val android: AndroidOptions = AndroidOptions(), val ios: IosOptions = IosOptions())(source)

What to capture and where it goes.

The defaults suit speech: 16 kHz mono PCM16 in 100 ms chunks, the format most speech-to-text APIs expect. Set file to also record, or set pcm to null to only record.

Constructors

Link copied to clipboard
constructor(sampleRate: Int, channels: Int = 1, chunkDuration: Duration = 100.milliseconds, pcm: PcmOutput? = PcmOutput(), file: FileOutput? = null, device: InputDevice? = null, voiceProcessing: VoiceProcessing? = null, interruption: InterruptionMode = InterruptionMode.Pause, android: AndroidOptions = AndroidOptions(), ios: IosOptions = IosOptions())

Properties

Link copied to clipboard
Link copied to clipboard

1 (mono) or 2 (stereo). Whether stereo is two real microphones or one duplicated depends on the device, the input and (on Android) the audio source; AndroidAudioSource.Camcorder is the most likely to give real stereo.

Link copied to clipboard

How much audio each AudioChunk holds and how often CaptureSession.level updates.

Link copied to clipboard

Preferred microphone, from AudioCapture.inputDevices. null is the system default.

Link copied to clipboard

A file written while capturing, or null for none.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Raw PCM delivered through CaptureSession.chunks, or null for none.

Link copied to clipboard

Samples per second, per channel. 16 000, 44 100 and 48 000 work on all current phones; Android only guarantees 44 100, and AudioCapture.start throws if the device refuses a rate. AAC files are limited to 8 000–48 000.

Link copied to clipboard

Echo cancellation, noise suppression and gain control, or null for the unprocessed signal. Experimental: see ExperimentalVoiceProcessing.