
Lightweight audio capture producing canonical 16-bit mono WAV buffers for transcription and AI pipelines, with unified API and extensible event hooks for error handling.
Wav Recorder is a lightweight Kotlin Multiplatform library that captures audio from the system microphone and returns it as a WAV-formatted kotlinx.io.Buffer. It focuses on predictable WAV output for speech pipelines and AI-driven applications without bundling higher-level speech tooling.
Recorder instance via platformRecorder, start/stop, and receive a WAV buffer you can persist or stream.isAvailable = false.WavRecorderEventHandler to observe initialisation and recording failures (useful for UI messaging or analytics).kotlin {
sourceSets {
commonMain.dependencies {
implementation("de.findusl:wav-recorder:0.1.1")
}
}
}Ensure mavenCentral() is present in your repository list.
import de.findusl.wavrecorder.platformRecorder
import kotlinx.io.readByteArray
val recorder = platformRecorder
require(recorder.isAvailable) { "Recording is not supported on this device." }
recorder.startRecording()
// ... wait or collect input ...
val wavBuffer = recorder.stopRecording().getOrThrow()
val wavBytes: ByteArray = wavBuffer.readByteArray()
recorder.close()android.permission.RECORD_AUDIO before invoking startRecording().close() when you no longer need the recorder to release microphone resources.Implement WavRecorderEventHandler (assign to WavRecorderEventHandler.INSTANCE) to surface issues such as Windows initialisation problems or runtime recording failures:
WavRecorderEventHandler.INSTANCE = object : WavRecorderEventHandler {
override fun failedToInitializeOnWindows(e: Exception) {
// Show a toast, log to analytics, etc.
}
override fun errorWhileRecording(e: Exception) { /* ... */ }
}AudioRecord, dynamically picks a supported sample rate, outputs mono, 16-bit WAV.javax.sound.sampled.TargetDataLine with a 44.1 kHz mono configuration.isAvailable returns false until native backends are added.Planned improvements include native backends (Linux/iOS) and higher-level streaming helpers. Issues and pull requests are welcome—check the existing workflows in .github/workflows if you plan to extend CI or publishing.
This project is licensed under the MIT License.
Wav Recorder is a lightweight Kotlin Multiplatform library that captures audio from the system microphone and returns it as a WAV-formatted kotlinx.io.Buffer. It focuses on predictable WAV output for speech pipelines and AI-driven applications without bundling higher-level speech tooling.
Recorder instance via platformRecorder, start/stop, and receive a WAV buffer you can persist or stream.isAvailable = false.WavRecorderEventHandler to observe initialisation and recording failures (useful for UI messaging or analytics).kotlin {
sourceSets {
commonMain.dependencies {
implementation("de.findusl:wav-recorder:0.1.1")
}
}
}Ensure mavenCentral() is present in your repository list.
import de.findusl.wavrecorder.platformRecorder
import kotlinx.io.readByteArray
val recorder = platformRecorder
require(recorder.isAvailable) { "Recording is not supported on this device." }
recorder.startRecording()
// ... wait or collect input ...
val wavBuffer = recorder.stopRecording().getOrThrow()
val wavBytes: ByteArray = wavBuffer.readByteArray()
recorder.close()android.permission.RECORD_AUDIO before invoking startRecording().close() when you no longer need the recorder to release microphone resources.Implement WavRecorderEventHandler (assign to WavRecorderEventHandler.INSTANCE) to surface issues such as Windows initialisation problems or runtime recording failures:
WavRecorderEventHandler.INSTANCE = object : WavRecorderEventHandler {
override fun failedToInitializeOnWindows(e: Exception) {
// Show a toast, log to analytics, etc.
}
override fun errorWhileRecording(e: Exception) { /* ... */ }
}AudioRecord, dynamically picks a supported sample rate, outputs mono, 16-bit WAV.javax.sound.sampled.TargetDataLine with a 44.1 kHz mono configuration.isAvailable returns false until native backends are added.Planned improvements include native backends (Linux/iOS) and higher-level streaming helpers. Issues and pull requests are welcome—check the existing workflows in .github/workflows if you plan to extend CI or publishing.
This project is licensed under the MIT License.