-
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.0")
}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/
whisper.cpp requires 16 kHz, mono, 16-bit PCM WAV. If your audio is anything
else, resample first (FFmpeg, or record with AudioRecord at 16 kHz):
ffmpeg -i input.mp3 -ar 16000 -ac 1 -c:a pcm_s16le speech.wav
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.