Skip to content

Quick Start

LucQuebec edited this page Jul 5, 2026 · 5 revisions

Quick Start

From zero to a transcription in five steps.

1. Add the dependency

See Installation. The short version:

dependencies {
    implementation("dev.ffmpegkit-maintained:whisper-android:0.1.2")
}

2. Get a model

Download a ggml model (see Model Download). For a first test:

ggml-base.en.bin  (~142 MB, English)

During development, push it to the app's files directory:

adb push ggml-base.en.bin /sdcard/Android/data/<your.app.id>/files/models/

3. Prepare audio

Pass a WAV, MP3 or FLAC file at any sample rate — the library decodes and resamples to 16 kHz mono internally (whisper.cpp's built-in miniaudio decoder, no FFmpeg). No manual conversion needed. For best speed, mono 16 kHz WAV avoids the resampling step, but it's optional.

4. Transcribe

lifecycleScope.launch {
    val modelPath = File(getExternalFilesDir("models"), "ggml-base.en.bin").absolutePath
    val audioPath = File(getExternalFilesDir(null), "speech.wav").absolutePath

    val model  = Whisper.loadModel(this@MainActivity, modelPath)
    val result = Whisper.transcribe(model, audioPath, WhisperConfig(language = "en"))

    println(result.text)
    result.segments.forEach { println("[${it.startMs}ms] ${it.text}") }

    Whisper.releaseModel(model)
}

5. Load from assets instead (optional)

If you bundle the model in src/main/assets/models/:

val model = Whisper.loadModelFromAsset(context, "models/ggml-base.en.bin")

The asset is copied to the cache dir automatically (native code needs a file path).


Tips

  • transcribe and loadModel are suspend — always call them off the main thread (a coroutine, as above).
  • Detect language automatically with WhisperConfig(language = "auto").
  • Translate to English with WhisperConfig(translate = true).
  • Always releaseModel when done to free native memory.

Clone this wiki locally