-
Notifications
You must be signed in to change notification settings - Fork 0
Quick Start
LucQuebec edited this page Jul 5, 2026
·
5 revisions
From zero to a transcription in five steps.
See Installation. The short version:
dependencies {
implementation("dev.ffmpegkit-maintained:whisper-android:0.1.2")
}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/
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.
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)
}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).
-
transcribeandloadModelaresuspend— 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
releaseModelwhen done to free native memory.