Skip to content

dosier/kodio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

198 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central Kotlin License Docs

Android iOS macOS JVM JavaScript Wasm

Caution

This library is still in very early development.

Kodio

Kotlin Multiplatform Audio Library for recording, playback, and transcription with a coroutines-based API.

Features

  • Recording: One-line recording with quality presets
  • Playback: Play recordings with a single method call
  • Multiplatform: JVM, Android, iOS, macOS, JS, Wasm
  • Compose Integration: State holders and UI components
  • Live Waveforms: Real-time amplitude data for visualizations
  • Permission Handling: Built-in permission management
  • File I/O: Save and load WAV files
  • Transcription: Speech-to-text via OpenAI Whisper API

Quick Start

import space.kodio.core.Kodio
import kotlin.time.Duration.Companion.seconds

suspend fun main() {
    // Record audio for 5 seconds
    val recording = Kodio.record(duration = 5.seconds)
    
    // Play it back
    recording.play()
    
    // Save to file
    recording.saveAs(Path("voice_note.wav"))
}

Installation

dependencies {
    // Core library (required)
    implementation("space.kodio:core:0.1.5")
    
    // Optional: Compose state holders and waveform
    implementation("space.kodio.extensions:compose:0.1.5")
    
    // Optional: Material 3 UI components
    implementation("space.kodio.extensions:compose-material3:0.1.5")
    
    // Optional: Audio transcription (OpenAI Whisper)
    implementation("space.kodio.extensions:transcription:0.1.5")
}

Logging

Kodio is silent by default: no log output is produced until you configure it. Consumers decide when and where logs appear, rather than Kodio printing to the console unprompted.

Enable logging at application startup with the built-in platform console writer:

import space.kodio.core.Kodio
import space.kodio.core.logging.LogLevel
import space.kodio.core.logging.platformLogWriter

Kodio.configureLogging {
    minLevel = LogLevel.Debug
    addWriter(platformLogWriter())
}

platformLogWriter() routes to Logcat on Android, NSLog on Apple platforms, the browser console on JS/Wasm, and stdout/stderr on JVM. The same API works across all targets.

To stay silent (the default), do nothing, or explicitly disable:

Kodio.configureLogging { minLevel = LogLevel.None }

Bridge to your own logging backend (Kermit, SLF4J, Crashlytics, etc.) by implementing KodioLogWriter:

Kodio.configureLogging {
    minLevel = LogLevel.Warn
    addWriter { level, tag, message, throwable ->
        MyLogger.log(level.name, tag, message, throwable)
    }
}

Log levels: Trace, Debug, Info, Warn, Error, None. Messages at or above minLevel are forwarded to all registered writers.

See the Logging docs page for full details.

Documentation

dosier.github.io/kodio

License

Apache 2.0

Credits

Inspired by kmp-record.

About

Kotlin multiplatform Audio System Library

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages